Skip to content

Commit c2ebb7a

Browse files
authored
Merge pull request #1549 from Northeastern-Electric-Racing/1480-shrinking-title-on-mobile-screens
#1480: Shortened title on smaller screens
2 parents 3dafb0f + 23b8cda commit c2ebb7a

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/frontend/src/layouts/NavTopBar/NavTopBar.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,27 @@ import { LayoutProps } from '../LayoutProps';
1515
import { IconButton } from '@mui/material';
1616
import { GridMenuIcon } from '@mui/x-data-grid';
1717
import { useCurrentUser } from '../../hooks/users.hooks';
18+
import { useEffect, useState } from 'react';
1819

19-
const textColor = 'white';
20-
const background = '#ef4345';
20+
const TEXT_COLOR = 'white';
21+
const BACKGROUND = '#ef4345';
22+
const MOBILE_WIDTH_THRESHOLD = 550;
2123

2224
interface NavTopBarProps extends LayoutProps {
2325
handleDrawerOpen: () => void;
2426
}
2527

2628
const NavTopBar: React.FC<NavTopBarProps> = ({ open, handleDrawerOpen }) => {
29+
const [width, setWidth] = useState(window.innerWidth);
30+
useEffect(() => {
31+
window.addEventListener('resize', () => {
32+
setWidth(window.innerWidth);
33+
});
34+
});
2735
const user = useCurrentUser();
2836
return (
2937
<NERAppBar position="fixed" open={open}>
30-
<Toolbar disableGutters sx={{ height: 68, px: 1, background, color: textColor }}>
38+
<Toolbar disableGutters sx={{ height: 68, px: 1, BACKGROUND, color: TEXT_COLOR }}>
3139
<IconButton
3240
color="inherit"
3341
aria-label="open drawer"
@@ -49,16 +57,16 @@ const NavTopBar: React.FC<NavTopBarProps> = ({ open, handleDrawerOpen }) => {
4957
alt="Northeastern Electric Racing Logo"
5058
src="/NER-Logo-App-Icon.png"
5159
/>
52-
<Typography variant="h4" fontSize={30} component="div" sx={{ flexGrow: 1, paddingLeft: 2, color: textColor }}>
53-
FinishLine by NER
60+
<Typography variant="h4" fontSize={30} component="div" sx={{ flexGrow: 1, paddingLeft: 2, color: TEXT_COLOR }}>
61+
{width > MOBILE_WIDTH_THRESHOLD ? 'FinishLine by NER' : 'FinishLine'}
5462
</Typography>
5563
</Box>
5664
</Link>
5765
</Box>
5866
<Typography
5967
variant="body1"
6068
sx={{
61-
color: textColor,
69+
color: TEXT_COLOR,
6270
'@media (max-width: 600px)': {
6371
display: 'none' // Hide the text on screens with width less than 600 pixels
6472
}

0 commit comments

Comments
 (0)