Skip to content

Commit 7be859a

Browse files
authored
Fix layout of navbar at various different widths. (#41)
* Fix layout of navbar at various different widths. * Remove dead space between buttons. * Remove space before menu when no logo. * User component hide names when extra small Flxes #35
1 parent 285d4f3 commit 7be859a

File tree

5 files changed

+39
-22
lines changed

5 files changed

+39
-22
lines changed

changelog.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ SciReactUI Changelog
44
[vNext] - date
55
--------------------
66

7+
### Added
8+
- Breadcrumbs takes object for total control over names and links
9+
710
### Fixed
8-
- Stopped flicker between themes when starting an app in dark mode.
11+
- Stopped flicker between colour modes when starting an app in dark mode.
912
- Footer links stopped from moving on hover when only showing links.
10-
- Footer links now correctly center horizontally.
13+
- Footer links now correctly center horizontally, if needed.
14+
- NavBar positions items correctly in multiple screen widths.
1115

1216
### Changed
1317
- Footer links now align with copyright when there is no logo.

src/components/ColourSchemeButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const ColourSchemeButton = (props: IconButtonProps) => {
1818
sx={{
1919
height: 35,
2020
width: 35,
21+
marginLeft: "10px !important",
2122
borderRadius: "5px",
2223
backgroundColor: theme.palette.primary.light,
2324
color: theme.palette.primary.contrastText,

src/components/Navbar.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { NavLink, NavLinks, Navbar } from "./Navbar";
55

66
import logoImageDark from "../public/generic/logo-dark.svg";
77
import logoImageLight from "../public/generic/logo-light.svg";
8+
import { ColourSchemeButton } from "./ColourSchemeButton";
89

910
const meta: Meta<typeof Navbar> = {
1011
title: "SciReactUI/Navigation/Navbar",
@@ -39,6 +40,7 @@ export const All: Story = {
3940
user={{ name: "Name", fedid: "FedID" }}
4041
color={"white"}
4142
/>,
43+
<ColourSchemeButton key="colourScheme" />,
4244
],
4345
logo: "theme",
4446
},

src/components/Navbar.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import {
33
Box,
44
BoxProps,
5+
Container,
56
Drawer,
67
LinkProps,
78
Link,
89
IconButton,
9-
Paper,
1010
Stack,
1111
useTheme,
1212
} from "@mui/material";
@@ -39,12 +39,11 @@ const NavLink = ({ children, ...props }: LinkProps) => {
3939
borderBottom: "solid 4px",
4040
},
4141
textDecoration: "none",
42-
px: 2,
43-
bgcolor: { md: "none" },
4442
alignItems: "center",
4543
display: "flex",
46-
borderTop: "4px solid transparent",
44+
padding: "13px 3px 0",
4745
borderBottom: "4px solid transparent",
46+
backgroundColor: { md: "none" },
4847
color: theme.palette.primary.contrastText,
4948
}}
5049
{...props}
@@ -67,6 +66,7 @@ const NavLinks = ({ children }: NavLinksProps) => {
6766
color: theme.palette.primary.contrastText,
6867
display: { md: "none" },
6968
order: -1,
69+
marginLeft: "0 !important",
7070
"&:hover": { filter: "brightness(90%);" },
7171
}}
7272
size={"small"}
@@ -80,6 +80,7 @@ const NavLinks = ({ children }: NavLinksProps) => {
8080
sx={{
8181
height: "100%",
8282
display: { xs: "none", md: "flex" },
83+
marginLeft: "0 !important",
8384
}}
8485
component="nav"
8586
spacing={4}
@@ -122,19 +123,21 @@ const Navbar = ({ children, logo, ...props }: NavbarProps) => {
122123
}
123124

124125
return (
125-
<Box top="0" zIndex={1} width="100%" {...props}>
126-
<Paper
127-
sx={{
128-
display: "flex",
129-
backgroundColor: theme.vars.palette.primary.main,
130-
px: { xs: "1rem", md: "7.5vw" },
131-
height: 50,
132-
width: "100%",
133-
alignItems: "center",
134-
justifyContent: "space-between",
135-
borderRadius: 0,
136-
}}
137-
>
126+
<Box
127+
top="0"
128+
zIndex={1}
129+
width="100%"
130+
height="50px"
131+
sx={{
132+
display: "flex",
133+
alignItems: "center",
134+
justifyContent: "space-between",
135+
borderRadius: 0,
136+
backgroundColor: theme.vars.palette.primary.main,
137+
}}
138+
{...props}
139+
>
140+
<Container maxWidth="lg" sx={{ height: "100%" }}>
138141
<Stack
139142
direction="row"
140143
spacing={8}
@@ -146,6 +149,7 @@ const Navbar = ({ children, logo, ...props }: NavbarProps) => {
146149
maxWidth="5rem"
147150
sx={{
148151
"&:hover": { filter: "brightness(80%);" },
152+
marginRight: { xs: "0", md: "50px" },
149153
}}
150154
>
151155
<ImageColorSchemeSwitch image={logo} />
@@ -154,7 +158,7 @@ const Navbar = ({ children, logo, ...props }: NavbarProps) => {
154158
) : null}
155159
{children}
156160
</Stack>
157-
</Paper>
161+
</Container>
158162
</Box>
159163
);
160164
};

src/components/User.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const User = ({ user, onLogin, onLogout, avatar, color }: UserProps) => {
6161
border: "none",
6262
cursor: "pointer",
6363
minWidth: 0,
64+
marginLeft: "10px !important",
6465
"&:hover": {
6566
opacity: 0.8,
6667
},
@@ -79,7 +80,12 @@ const User = ({ user, onLogin, onLogout, avatar, color }: UserProps) => {
7980
}}
8081
/>
8182
)}
82-
<div style={{ padding: 10 }}>
83+
<Box
84+
sx={{
85+
padding: "5px",
86+
display: { xs: "none", sm: "block" },
87+
}}
88+
>
8389
<Typography
8490
fontSize="0.75rem"
8591
textTransform="none"
@@ -100,7 +106,7 @@ const User = ({ user, onLogin, onLogout, avatar, color }: UserProps) => {
100106
{user.fedid}
101107
</Typography>
102108
)}
103-
</div>
109+
</Box>
104110
</Stack>
105111
</Button>
106112
{onLogout && (

0 commit comments

Comments
 (0)