Skip to content

Commit 521a9ff

Browse files
authored
Merge pull request #1022 from openmsupply/1018-update-nav-style
Update navigation style
2 parents ac4f105 + 7504157 commit 521a9ff

File tree

5 files changed

+74
-45
lines changed

5 files changed

+74
-45
lines changed

client/packages/common/src/styles/theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const themeOptions = {
132132
},
133133
},
134134
drawer: {
135-
selectedBackgroundColor: 'transparent',
135+
selectedBackgroundColor: '#fff',
136136
},
137137
saveButtonRow: { height: 40 },
138138
footer: { height: 32 },

client/packages/common/src/ui/components/navigation/AppNavLink/AppNavLink.tsx

+58-37
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,25 @@ const StyledListItem = styled<
4040
FC<ListItemProps & { isSelected: boolean; to: string }>
4141
>(ListItem, {
4242
shouldForwardProp: prop => prop !== 'isSelected',
43-
})(({ theme, isSelected }) => ({
44-
...getListItemCommonStyles(),
45-
backgroundColor: isSelected
46-
? theme.mixins.drawer.selectedBackgroundColor
47-
: 'transparent',
48-
boxShadow: isSelected ? theme.shadows[3] : 'none',
49-
marginTop: 5,
50-
'&:hover': {
51-
boxShadow: theme.shadows[8],
52-
},
53-
}));
43+
})(({ theme, isSelected }) =>
44+
isSelected
45+
? {
46+
...getListItemCommonStyles(),
47+
backgroundColor: theme.mixins.drawer.selectedBackgroundColor,
48+
boxShadow: theme.shadows[3],
49+
fontWeight: 'bold',
50+
marginTop: 5,
51+
}
52+
: {
53+
...getListItemCommonStyles(),
54+
backgroundColor: 'transparent',
55+
marginTop: 5,
56+
'&:hover': {
57+
boxShadow: theme.shadows[3],
58+
backgroundColor: theme.palette.background.toolbar,
59+
},
60+
}
61+
);
5462

5563
export interface AppNavLinkProps {
5664
badgeProps?: BadgeProps;
@@ -78,6 +86,7 @@ export const AppNavLink: FC<AppNavLinkProps> = props => {
7886

7987
const selected = useSelectedNavMenuItem(to, !!end, drawer.isOpen);
8088
const isSelectedParentItem = inactive && !!useMatch({ path: `${to}/*` });
89+
const showMenuSectionIcon = inactive && drawer.isOpen;
8190
const handleClick = () => {
8291
// reset the clicked nav path when navigating
8392
// otherwise the child menu remains open
@@ -129,9 +138,22 @@ export const AppNavLink: FC<AppNavLinkProps> = props => {
129138
component={CustomLink}
130139
>
131140
<ListItemIcon sx={{ minWidth: 20 }}>{icon}</ListItemIcon>
141+
{showMenuSectionIcon && (
142+
<ChevronDownIcon
143+
className="menu_section_icon"
144+
sx={{
145+
color: 'gray.main',
146+
fontSize: '1rem',
147+
marginLeft: 0.5,
148+
stroke: theme => theme.palette.gray.main,
149+
strokeWidth: 1.5,
150+
transform: 'rotate(-90deg)',
151+
}}
152+
/>
153+
)}
132154
<Box className="navLinkText">
133-
<Box width={10} />
134-
155+
{!end && <Box width={4} />}
156+
{!showMenuSectionIcon && <Box width={4} />}
135157
<Badge
136158
{...badgeProps}
137159
sx={{
@@ -149,34 +171,33 @@ export const AppNavLink: FC<AppNavLinkProps> = props => {
149171
>
150172
<ListItemText
151173
primary={text}
152-
sx={
153-
isSelectedParentItem
154-
? {
155-
'& .MuiTypography-root': { fontWeight: 'bold' },
156-
flexGrow: 0,
157-
}
158-
: { flexGrow: 0 }
159-
}
174+
sx={{
175+
'& .MuiTypography-root': {
176+
fontWeight:
177+
selected || isSelectedParentItem ? 'bold' : 'normal',
178+
color: isSelectedParentItem ? 'primary.main' : undefined,
179+
},
180+
flexGrow: 0,
181+
}}
160182
/>
161183
</Badge>
162-
{end && (
163-
<ListItemIcon
184+
185+
<ListItemIcon
186+
sx={{
187+
minWidth: 20,
188+
display: selected && drawer.isOpen ? 'flex' : 'none',
189+
alignItems: 'center',
190+
}}
191+
className="chevron"
192+
>
193+
<ChevronDownIcon
164194
sx={{
165-
minWidth: 20,
166-
display: selected ? 'flex' : 'none',
167-
alignItems: 'center',
195+
transform: 'rotate(-90deg)',
196+
fontSize: '1rem',
197+
color: 'primary.main',
168198
}}
169-
className="chevron"
170-
>
171-
<ChevronDownIcon
172-
sx={{
173-
transform: 'rotate(-90deg)',
174-
fontSize: '1rem',
175-
color: 'primary.main',
176-
}}
177-
/>
178-
</ListItemIcon>
179-
)}
199+
/>
200+
</ListItemIcon>
180201
</Box>
181202
</ListItemButton>
182203
</StyledListItem>

client/packages/common/src/ui/components/navigation/AppNavSection.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ export const AppNavSection: FC<
1313
sx={
1414
isActive
1515
? {
16+
'& .menu_section_icon': { transform: 'unset' },
1617
'& .MuiCollapse-root': {
18+
marginLeft: '48px',
1719
marginTop: -1.5,
20+
borderLeft: '1px solid',
21+
borderColor: 'gray.light',
22+
paddingLeft: 1,
1823
},
1924
'& .MuiCollapse-wrapperInner > ul > li.MuiListItem-root': {
2025
height: 30,
21-
marginLeft: 1,
26+
paddingLeft: 1,
27+
paddingRight: 2,
28+
'& .MuiListItemIcon-root': { minWidth: 0 },
2229
},
23-
'& .navLinkText': {
24-
flex: 1,
25-
},
26-
'& .MuiListItem-root:hover .chevron': {
27-
display: 'flex',
30+
'& div > ul > li.MuiListItem-root': {
31+
width: 165,
32+
'& .MuiTypography-root': {
33+
maxWidth: 135,
34+
},
2835
},
2936
}
3037
: {}

client/packages/host/src/components/AppDrawer/AppDrawer.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const StyledDrawer = styled(Box, {
115115
'& .MuiDrawer-paper': openedMixin(theme),
116116
'& .navLinkText': {
117117
display: 'inline-flex',
118+
flex: 1,
118119
},
119120
'& div > ul > li': {
120121
width: 220,

client/packages/host/src/components/Navigation/CatalogueNav.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const CatalogueNav: FC = () => {
2222
<AppNavLink
2323
end={false}
2424
to={AppRoute.Catalogue}
25-
icon={<ListIcon color="primary" />}
25+
icon={<ListIcon color="primary" style={{ width: 20 }} />}
2626
text={t('catalogue')}
2727
inactive
2828
/>

0 commit comments

Comments
 (0)