Skip to content

Commit

Permalink
feat: new variant for navbar account notif (#2750)
Browse files Browse the repository at this point in the history
* feat: introduce new notification 'info' variant for NavbarAccount component

* chore: changeset
  • Loading branch information
bgutsol committed May 13, 2024
1 parent 5c4a294 commit 2d0ff52
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-islands-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@contentful/f36-navbar': minor
---

Introduce new notification 'info' variant for NavbarAccount component
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EntryIcon, AssetIcon } from '@contentful/f36-icons';
export default function WithAccountNotificationNavbarExample() {
const notificationVariant = 'warning';

// Try 'negative' notifification variant
// Try 'negative' or 'info' notifification variant
// const notificationVariant = 'negative'

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import tokens from '@contentful/f36-tokens';
import { NavbarAccountProps } from './NavbarAccount';
import { getGlowOnFocusStyles } from '../utils.styles';

const notificationVarianColorMap: Record<
NavbarAccountProps['notificationVariant'],
string
> = {
warning: tokens.colorWarning,
negative: tokens.colorNegative,
info: tokens.blue500,
};

export const getNavbarAccountStyles = () => ({
root: css(
{
Expand Down Expand Up @@ -37,8 +46,7 @@ export const getNavbarAccountStyles = () => ({
width: tokens.spacingS,
borderRadius: '50%',
border: `2px solid ${tokens.gray900}`,
backgroundColor:
variant === 'negative' ? tokens.colorNegative : tokens.colorWarning,
backgroundColor: notificationVarianColorMap[variant],
transform: 'translate(30%, -30%)',
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type NavbarAccountOwnProps = CommonProps & {
/**
* @default 'warning'
*/
notificationVariant?: 'warning' | 'negative';
notificationVariant?: 'warning' | 'negative' | 'info';
};

export type NavbarAccountProps = PropsWithHTMLElement<
Expand Down
13 changes: 13 additions & 0 deletions packages/components/navbar/stories/Navbar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,19 @@ export const WithAccountNotification: Story<NavbarProps> = () => {
<MainItems />
</Navbar>
</Flex>

<Flex flexDirection="column">
<SectionHeading as="h3" marginBottom="spacingS">
Info
</SectionHeading>

<Navbar
switcher={<Switcher />}
account={<Account hasNotification notificationVariant="info" />}
>
<MainItems />
</Navbar>
</Flex>
</Flex>
);
};
Expand Down

0 comments on commit 2d0ff52

Please sign in to comment.