-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve responsiveness for navigation [CFISO-1555] (#2805)
* refactor: render navbar complete as fullscreen on storybook * feat: add mobile navigation to complete story * refactor: improve responsiveness on navbar * feat: add separate story for responsiveness * chore: update to latest version * feat: hide secondary nav children except search * docs: use only navbar compound elements * feat: prevent overflow of submenu on mobile * feat: prevent header overflow with long space names * feat: avoid overflow on small desktop screens * feat: increase icon size for mobile devices --------- Co-authored-by: Kathrin <[email protected]>
- Loading branch information
Showing
15 changed files
with
380 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
6 changes: 5 additions & 1 deletion
6
packages/components/navbar/src/NavbarMenu/NavbarMenu.styles.ts
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { css } from 'emotion'; | ||
import { mqs } from '../utils.styles'; | ||
|
||
export const getNavbarMenuStyles = () => ({ | ||
menuList: css({ | ||
minWidth: '250px', | ||
minWidth: 0, | ||
[mqs.xsmall]: { | ||
minWidth: '250px', | ||
}, | ||
}), | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/components/navbar/src/NavbarSubmenu/NavbarMenu.styles.ts
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,21 @@ | ||
import tokens from '@contentful/f36-tokens'; | ||
import { css } from 'emotion'; | ||
import { mqs } from '../utils.styles'; | ||
|
||
export const getNavbarSubmenuStyles = () => ({ | ||
navbarMenuItem: css({ | ||
display: 'flex', | ||
justifyContent: 'flex-start', | ||
alignItems: 'center', | ||
gap: tokens.spacingXs, | ||
}), | ||
menuList: css({ | ||
minWidth: 0, | ||
marginLeft: '-24px', | ||
marginTop: '10px', | ||
[mqs.xsmall]: { | ||
minWidth: '250px', | ||
margin: 0, | ||
}, | ||
}), | ||
}); |
41 changes: 41 additions & 0 deletions
41
packages/components/navbar/src/NavbarSubmenu/NavbarSubmenu.tsx
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,41 @@ | ||
import React from 'react'; | ||
import { Menu, type MenuListProps, type MenuProps } from '@contentful/f36-menu'; | ||
import { getNavbarSubmenuStyles } from './NavbarMenu.styles'; | ||
import { | ||
NavbarItemIcon, | ||
type NavbarItemIconProps, | ||
} from '../NavbarItemIcon/NavbarItemIcon'; | ||
import { Flex } from '@contentful/f36-core'; | ||
|
||
export type NavbarSubmenuProps = { | ||
title: string; | ||
icon?: NavbarItemIconProps['icon']; | ||
children?: React.ReactNode; | ||
} & Pick<MenuListProps, 'testId'> & | ||
Pick<MenuProps, 'onOpen' | 'onClose'>; | ||
|
||
export const NavbarSubmenu = (props: NavbarSubmenuProps) => { | ||
const { | ||
title, | ||
icon, | ||
children, | ||
testId = 'cf-ui-navbar-submenu-list', | ||
onOpen, | ||
onClose, | ||
} = props; | ||
const styles = getNavbarSubmenuStyles(); | ||
|
||
return ( | ||
<Menu.Submenu onOpen={onOpen} onClose={onClose}> | ||
<Menu.SubmenuTrigger> | ||
<Flex className={styles.navbarMenuItem}> | ||
{icon && <NavbarItemIcon icon={icon} />} | ||
<span>{title}</span> | ||
</Flex> | ||
</Menu.SubmenuTrigger> | ||
<Menu.List className={styles.menuList} testId={testId}> | ||
{children} | ||
</Menu.List> | ||
</Menu.Submenu> | ||
); | ||
}; |
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.