Skip to content

Commit

Permalink
Merge pull request #8453 from google/enhancement/8448-ads-new-badge
Browse files Browse the repository at this point in the history
  • Loading branch information
nfmohit authored Apr 3, 2024
2 parents 5ab0163 + d8c8881 commit b129701
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
28 changes: 22 additions & 6 deletions assets/js/components/NewBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* External dependencies
*/
import PropTypes from 'prop-types';
import classnames from 'classnames';

/**
* WordPress dependencies
Expand All @@ -38,8 +39,24 @@ function NewBadge( {
tooltipTitle,
learnMoreLink,
forceOpen,
hasLeftSpacing,
hasNoSpacing,
onLearnMoreClick = () => {},
} ) {
const badgeComponent = (
<Badge
className={ classnames( 'googlesitekit-new-badge', {
'googlesitekit-new-badge--has-no-spacing': hasNoSpacing,
} ) }
label={ __( 'New', 'google-site-kit' ) }
hasLeftSpacing={ hasLeftSpacing }
/>
);

if ( ! tooltipTitle ) {
return badgeComponent;
}

return (
<Tooltip
tooltipClassName="googlesitekit-new-badge__tooltip"
Expand All @@ -63,19 +80,18 @@ function NewBadge( {
interactive
open={ forceOpen }
>
<Badge
className="googlesitekit-new-badge"
label={ __( 'New', 'google-site-kit' ) }
/>
{ badgeComponent }
</Tooltip>
);
}

NewBadge.propTypes = {
tooltipTitle: PropTypes.string.isRequired,
learnMoreLink: PropTypes.string.isRequired,
tooltipTitle: PropTypes.string,
learnMoreLink: PropTypes.string,
forceOpen: PropTypes.bool,
onLearnMoreClick: PropTypes.func,
hasLeftSpacing: PropTypes.bool,
hasNoSpacing: PropTypes.bool,
};

export default NewBadge;
2 changes: 2 additions & 0 deletions assets/js/components/settings/SettingsActiveModule/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { Grid, Row, Cell } from '../../../material-components';
import { useKeyCodesInside } from '../../../hooks/useKeyCodesInside';
import ModuleIcon from '../../ModuleIcon';
import Badge from '../../Badge';
import NewBadge from '../../NewBadge';
import { trackEvent } from '../../../util';
import useViewContext from '../../../hooks/useViewContext';
import ConnectedIcon from '../../../../svg/icons/connected.svg';
Expand Down Expand Up @@ -172,6 +173,7 @@ export default function Header( { slug } ) {
hasLeftSpacing
/>
) }
{ slug === 'ads' && <NewBadge hasLeftSpacing /> }
</div>
</Cell>

Expand Down
2 changes: 2 additions & 0 deletions assets/js/components/settings/SetupModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import Spinner from '../Spinner';
import Link from '../Link';
import Badge from '../Badge';
import ModuleSettingsWarning from '../notifications/ModuleSettingsWarning.js';
import NewBadge from '../NewBadge.js';
import { CORE_SITE } from '../../googlesitekit/datastore/site/constants';
import { CORE_MODULES } from '../../googlesitekit/modules/datastore/constants';
import { CORE_LOCATION } from '../../googlesitekit/datastore/location/constants';
Expand Down Expand Up @@ -118,6 +119,7 @@ export default function SetupModule( { slug, name, description } ) {
label={ __( 'Experimental', 'google-site-kit' ) }
/>
) }
{ slug === 'ads' && <NewBadge hasNoSpacing /> }
</div>
</div>
<p className="googlesitekit-settings-connect-module__text">
Expand Down
8 changes: 8 additions & 0 deletions assets/sass/components/global/_googlesitekit-new-badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
margin-left: 6px;
padding: 4px 8px;
text-transform: none;

&.googlesitekit-new-badge--has-no-spacing {
margin-left: 0;
}
}

.googlesitekit-new-badge.googlesitekit-badge--has-left-spacing {
margin-left: 12px;
}

.googlesitekit-tooltip.MuiTooltip-tooltip.googlesitekit-new-badge__tooltip {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b129701

Please sign in to comment.