-
Notifications
You must be signed in to change notification settings - Fork 93
LF-4807 - Update main navigation styling #3894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,16 +22,11 @@ import styles from './styles.module.scss'; | |
| import { getLanguageFromLocalStorage } from '../../../util/getLanguageFromLocalStorage'; | ||
|
|
||
| const MenuItem = forwardRef(({ history, onClick, path, children, className }, ref) => { | ||
| const isActive = matchPath(history.location.pathname, path); | ||
| return ( | ||
| <ListItemButton | ||
| onClick={onClick ?? (() => history.push(path))} | ||
| className={clsx( | ||
| styles.listItem, | ||
| matchPath(history.location.pathname, path) | ||
| ? styles.activeListItem | ||
| : styles.inactiveListItem, | ||
| className, | ||
| )} | ||
| className={clsx(styles.listItem, isActive && styles.active, className)} | ||
| ref={ref} | ||
| > | ||
| {children} | ||
|
|
@@ -44,15 +39,23 @@ MenuItem.displayName = 'MenuItem'; | |
| const SubMenu = ({ compact, children, isExpanded, ...props }) => { | ||
| if (compact) { | ||
| return ( | ||
| <Menu open={isExpanded} {...props}> | ||
| <Menu | ||
| open={isExpanded} | ||
| className={clsx(styles.list, styles.subList, styles.tertiary)} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </Menu> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Collapse in={isExpanded} timeout="auto" unmountOnExit> | ||
| <List component="div" disablePadding className={styles.subList}> | ||
| <List | ||
| component="div" | ||
| disablePadding | ||
| className={clsx(styles.list, styles.subList, styles.tertiary)} | ||
| > | ||
| {children} | ||
| </List> | ||
| </Collapse> | ||
|
|
@@ -84,12 +87,12 @@ const SideMenuContent = ({ history, closeDrawer, isCompact, hasBeenExpanded }) = | |
| <div | ||
| role="presentation" | ||
| className={clsx( | ||
| styles.container, | ||
| isCompact && styles.compactContainer, | ||
| !isCompact && hasBeenExpanded && styles.expandedContainer, | ||
| styles.sideMenuContent, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename css styles -- "container" seemed to generic to understand while working on it. This component function is called sideMenuContent so I labeled it as such for understanding while working on PR. |
||
| isCompact && styles.compactSideMenuContent, | ||
| !isCompact && hasBeenExpanded && styles.expandedSideMenuContent, | ||
| )} | ||
| > | ||
| <List className={styles.list}> | ||
| <List className={clsx(styles.list, styles.primary)}> | ||
| <ListItemButton | ||
| onClick={() => handleClick('/')} | ||
| className={clsx(styles.listItem, styles.logoListItem)} | ||
|
|
@@ -99,85 +102,80 @@ const SideMenuContent = ({ history, closeDrawer, isCompact, hasBeenExpanded }) = | |
| </div> | ||
| </ListItemButton> | ||
| {mainActions.map(({ icon, label, path, subMenu, key, badge }) => { | ||
| if (!subMenu) { | ||
| if (subMenu) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swapped the placement of the returns -- Rendering the exception is now done in the if statement instead of being the default. |
||
| return ( | ||
| <MenuItem | ||
| history={history} | ||
| key={key} | ||
| path={path} | ||
| onClick={() => onMenuItemClick(path)} | ||
| > | ||
| <ListItemIcon className={styles.icon}>{icon}</ListItemIcon> | ||
| <ListItemText | ||
| primary={label} | ||
| className={clsx( | ||
| styles.listItemText, | ||
| styles.animatedContent, | ||
| isCompact && styles.hiddenContent, | ||
| )} | ||
| /> | ||
| {!isCompact && badge} | ||
| </MenuItem> | ||
| <React.Fragment key={key}> | ||
| <MenuItem | ||
| history={history} | ||
| onClick={() => toggleExpanded(key)} | ||
| path={path} | ||
| ref={(el) => (expandableItemsRef.current[key] = el)} | ||
| > | ||
| <ListItemIcon className={styles.icon}>{icon}</ListItemIcon> | ||
| <ListItemText | ||
| primary={label} | ||
| className={clsx( | ||
| styles.listItemText, | ||
| styles.animatedContent, | ||
| isCompact && styles.hiddenContent, | ||
| )} | ||
| /> | ||
| {!isCompact && badge} | ||
| <ExpandMore | ||
| className={clsx( | ||
| styles.expandCollapseIcon, | ||
| expandedIds.includes(key) && styles.collapseIcon, | ||
| isCompact && styles.compactExpandIcon, | ||
| )} | ||
| /> | ||
| </MenuItem> | ||
| <SubMenu | ||
| compact={isCompact} | ||
| isExpanded={expandedIds.includes(key)} | ||
| onClose={resetExpanded} | ||
| anchorEl={expandableItemsRef.current[key]} | ||
| anchorOrigin={{ | ||
| vertical: 'top', | ||
| horizontal: 'right', | ||
| }} | ||
| > | ||
| {subMenu.map(({ label: subMenuLabel, path: subMenuPath, key: subMenuKey }) => { | ||
| return ( | ||
| <MenuItem | ||
| history={history} | ||
| key={subMenuKey} | ||
| path={subMenuPath} | ||
| className={styles.subItem} | ||
| onClick={() => | ||
| isCompact ? onMenuItemClick(subMenuPath) : handleClick(subMenuPath) | ||
| } | ||
| > | ||
| <ListItemText primary={subMenuLabel} className={styles.subItemText} /> | ||
| </MenuItem> | ||
| ); | ||
| })} | ||
| </SubMenu> | ||
| </React.Fragment> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <React.Fragment key={key}> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same - Swapped the placement of the returns -- Rendering the exception is now done in the if statement instead of being the default. |
||
| <MenuItem | ||
| history={history} | ||
| onClick={() => toggleExpanded(key)} | ||
| path={path} | ||
| ref={(el) => (expandableItemsRef.current[key] = el)} | ||
| > | ||
| <ListItemIcon className={styles.icon}>{icon}</ListItemIcon> | ||
| <ListItemText | ||
| primary={label} | ||
| className={clsx( | ||
| styles.listItemText, | ||
| styles.animatedContent, | ||
| isCompact && styles.hiddenContent, | ||
| )} | ||
| /> | ||
| {!isCompact && badge} | ||
| <ExpandMore | ||
| className={clsx( | ||
| styles.expandCollapseIcon, | ||
| expandedIds.includes(key) && styles.collapseIcon, | ||
| isCompact && styles.compactExpandIcon, | ||
| )} | ||
| /> | ||
| </MenuItem> | ||
| <SubMenu | ||
| compact={isCompact} | ||
| isExpanded={expandedIds.includes(key)} | ||
| onClose={resetExpanded} | ||
| anchorEl={expandableItemsRef.current[key]} | ||
| anchorOrigin={{ | ||
| vertical: 'top', | ||
| horizontal: 'right', | ||
| }} | ||
| > | ||
| {subMenu.map(({ label: subMenuLabel, path: subMenuPath, key: subMenuKey }) => { | ||
| return ( | ||
| <MenuItem | ||
| history={history} | ||
| key={subMenuKey} | ||
| path={subMenuPath} | ||
| className={styles.subItem} | ||
| onClick={() => | ||
| isCompact ? onMenuItemClick(subMenuPath) : handleClick(subMenuPath) | ||
| } | ||
| > | ||
| <ListItemText primary={subMenuLabel} className={styles.subItemText} /> | ||
| </MenuItem> | ||
| ); | ||
| })} | ||
| </SubMenu> | ||
| </React.Fragment> | ||
| <MenuItem history={history} key={key} path={path} onClick={() => onMenuItemClick(path)}> | ||
| <ListItemIcon className={styles.icon}>{icon}</ListItemIcon> | ||
| <ListItemText | ||
| primary={label} | ||
| className={clsx( | ||
| styles.listItemText, | ||
| styles.animatedContent, | ||
| isCompact && styles.hiddenContent, | ||
| )} | ||
| /> | ||
| {!isCompact && badge} | ||
| </MenuItem> | ||
| ); | ||
| })} | ||
| </List> | ||
| <List className={styles.list}> | ||
| <List className={clsx(styles.list, styles.secondary)}> | ||
| {adminActions.map(({ icon, label, path, key }) => { | ||
| return ( | ||
| <MenuItem | ||
|
|
@@ -230,7 +228,7 @@ const PureSideMenu = ({ | |
| }; | ||
|
|
||
| return isMobile ? ( | ||
| <div className={styles.sideMenu}> | ||
| <div className={styles.drawer}> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CSS classname rename -- sideMenu was too generic to follow while updating -- this is the drawer version of the side menu only. |
||
| <Drawer | ||
| isOpen={isDrawerOpen} | ||
| onClose={onDrawerClose} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inactiveListItem styles now applied to base style.