Skip to content

Commit

Permalink
Make the navigation header bolder
Browse files Browse the repository at this point in the history
- simpler overall color palette and higher contrast
- also a cool scroll triggered effect
  • Loading branch information
honzaflash committed Oct 12, 2023
1 parent 3f3dda8 commit 7032432
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/layouts/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/jsx-no-comment-textnodes */
// The title is supposed to imitate a code source file header
import { AppBar, Box, Container, Link, Tab, Tabs, Toolbar, Typography } from '@mui/material'
import { AppBar, Box, Container, Link, Tab, Tabs, Toolbar, Typography, useScrollTrigger } from '@mui/material'
import { useLocation, useNavigate } from 'react-router-dom'
import { GithubIcon } from '../icons/GithubIcon'
import { LinkedinIcon } from '../icons/LinkedinIcon'
Expand All @@ -20,8 +20,15 @@ const tabs: { label: string, path: string }[] = [
export const Navigation = () => {
const { pathname } = useLocation()
const navigate = useNavigate()

const scrollIsAtTop = !useScrollTrigger({ threshold: 20, disableHysteresis: true })

return(
<AppBar sx={{ backgroundImage: 'none' }}>
<AppBar sx={({ palette }) => ({
backgroundImage: 'none',
background: palette.background.default,
transition: 'background 200ms',
})}>
<Container sx={{ px: { xs: 3, md: 20 }}}>
<Toolbar sx={{ p: { xs: 0 } }}>
<Typography
Expand Down Expand Up @@ -65,6 +72,18 @@ export const Navigation = () => {
</Link>
<Link href="https://github.com/honzaflash" target="_blank"><GithubIcon /></Link>
</Box>
<Box component="span" sx={({ palette }) => ({
position: 'absolute',
// width: '100%',
width: '0%',
height: '2px',
bottom: 0,
left: 'calc(-50vw + 50%)',
backgroundColor: '#49B53F70',
...(!scrollIsAtTop && { width: '100vw', left: 'calc(-50vw + 50%)', backgroundColor: palette.primary.main }),
transition: '200ms ',
transitionProperty: 'width, left, background-color',
})} />
</Toolbar>
</Container>
</AppBar>
Expand Down

0 comments on commit 7032432

Please sign in to comment.