-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
289 changed files
with
9,841 additions
and
1,749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* NewBadge component. | ||
* | ||
* Site Kit by Google, Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Fragment } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Tooltip } from 'googlesitekit-components'; | ||
import Badge from './Badge'; | ||
import Link from './Link'; | ||
|
||
function NewBadge( { tooltipTitle, learnMoreLink, forceOpen } ) { | ||
return ( | ||
<Tooltip | ||
tooltipClassName="googlesitekit-new-badge__tooltip" | ||
title={ | ||
<Fragment> | ||
{ tooltipTitle } | ||
<br /> | ||
<Link href={ learnMoreLink } external> | ||
{ __( 'Learn more', 'google-site-kit' ) } | ||
</Link> | ||
</Fragment> | ||
} | ||
placement="top" | ||
enterTouchDelay={ 0 } | ||
leaveTouchDelay={ 5000 } | ||
interactive | ||
open={ forceOpen } | ||
> | ||
<Badge | ||
className="googlesitekit-new-badge" | ||
label={ __( 'New', 'google-site-kit' ) } | ||
/> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
NewBadge.propTypes = { | ||
tooltipTitle: PropTypes.string.isRequired, | ||
learnMoreLink: PropTypes.string.isRequired, | ||
forceOpen: PropTypes.bool, | ||
}; | ||
|
||
export default NewBadge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* NewBadge Component Stories. | ||
* | ||
* Site Kit by Google, Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import NewBadge from './NewBadge'; | ||
|
||
const Template = ( args ) => <NewBadge { ...args } />; | ||
|
||
export const NewBadgeDefault = Template.bind( {} ); | ||
NewBadgeDefault.storyName = 'Default'; | ||
NewBadgeDefault.args = { | ||
tooltipTitle: 'This is a tooltip title', | ||
learnMoreLink: 'https://www.google.com', | ||
}; | ||
|
||
export const NewBadgeLongTitle = Template.bind( {} ); | ||
NewBadgeLongTitle.storyName = 'Long Title'; | ||
NewBadgeLongTitle.args = { | ||
tooltipTitle: | ||
'This is a tooltip title that is very long and will wrap to multiple lines. This should still display as a single paragraph and the link will be displayed under the title.', | ||
learnMoreLink: 'https://www.google.com', | ||
}; | ||
|
||
export const NewBadgeForceOpen = Template.bind( {} ); | ||
NewBadgeForceOpen.storyName = 'Force Open'; | ||
NewBadgeForceOpen.args = { | ||
tooltipTitle: | ||
'This is a tooltip that is forced to be open all the time using the forceOpen prop. This is useful for testing the tooltip in Storybook.', | ||
learnMoreLink: 'https://www.google.com', | ||
forceOpen: true, | ||
}; | ||
NewBadgeForceOpen.scenario = { | ||
label: 'Global/NewBadge', | ||
}; | ||
|
||
export default { | ||
title: 'Components/NewBadge', | ||
component: NewBadge, | ||
decorators: [ | ||
( Story ) => ( | ||
<div | ||
style={ { | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'flex-end', | ||
height: '200px', | ||
} } | ||
> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.