dwysokinski.me/src/components/Layout/Navbar.js

122 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-01-17 08:31:50 +00:00
import React from 'react';
import { graphql, useStaticQuery } from 'gatsby';
2021-01-17 08:31:50 +00:00
import classnames from 'classnames';
import { ROUTE } from '@config/routing';
import smoothScroll from '@utils/smoothScroll';
import { HEADER_ID } from '@features/IndexPage/components/Header/Header';
import { SECTION_ID as PORTFOLIO_SECTION_ID } from '@features/IndexPage/components/Portfolio/Portfolio';
import { SECTION_ID as CONTACT_SECTION_ID } from '@features/IndexPage/components/Contact';
2020-07-13 12:02:40 +00:00
2021-01-17 08:31:50 +00:00
import { makeStyles } from '@material-ui/core/styles';
import { AppBar, Toolbar, Container, Link } from '@material-ui/core';
import { Link as GatsbyLink } from 'gatsby-theme-material-ui';
2020-07-13 12:02:40 +00:00
function Navbar({ className, ...rest }) {
2021-01-17 08:31:50 +00:00
const classes = useStyles();
const data = useStaticQuery(graphql`
{
logo: file(base: { eq: "logo.svg" }) {
publicURL
}
}
`);
2020-07-13 12:02:40 +00:00
return (
<AppBar
component="nav"
position="static"
{...rest}
className={classnames(classes.appBar, className)}
>
<Container>
<Toolbar className={classes.toolbar} disableGutters>
<div className={classes.titleContainer}>
<GatsbyLink
title="Strona główna"
color="inherit"
to={ROUTE.INDEX_PAGE}
>
<img
className={classes.logo}
src={data.logo.publicURL}
alt="logo"
/>
</GatsbyLink>
2020-07-13 12:02:40 +00:00
</div>
<div className={classes.divider} />
<div className={classes.linkContainer}>
<Link
title="Start"
color="inherit"
2021-01-17 08:31:50 +00:00
href={'#' + HEADER_ID}
onClick={smoothScroll(HEADER_ID)}
>
Start
</Link>
<Link
title="Portfolio"
color="inherit"
2021-01-17 08:31:50 +00:00
href={'#' + PORTFOLIO_SECTION_ID}
onClick={smoothScroll(PORTFOLIO_SECTION_ID)}
>
Portfolio
</Link>
<Link
title="Contact"
color="inherit"
2021-01-17 08:31:50 +00:00
href={'#' + CONTACT_SECTION_ID}
onClick={smoothScroll(CONTACT_SECTION_ID)}
>
Contact
</Link>
2020-07-13 12:02:40 +00:00
</div>
</Toolbar>
</Container>
</AppBar>
2021-01-17 08:31:50 +00:00
);
2020-07-13 12:02:40 +00:00
}
const useStyles = makeStyles(theme => ({
appBar: {
2021-01-17 08:31:50 +00:00
backgroundColor: 'transparent',
color: '#fff',
boxShadow: 'none',
},
linkContainer: {
2021-01-17 08:31:50 +00:00
'& > *:not(:last-child)': {
marginRight: theme.spacing(2),
},
2021-01-17 08:31:50 +00:00
[theme.breakpoints.down('xs')]: {
'& > *:not(:last-child)': {
marginRight: theme.spacing(1),
},
},
},
logo: {
2021-01-17 08:31:50 +00:00
width: '56px',
height: 'auto',
[theme.breakpoints.down('xs')]: {
width: '48px',
},
},
divider: {
flexGrow: 1,
},
link: {
2021-01-17 08:31:50 +00:00
width: '100%',
},
titleContainer: {
2021-01-17 08:31:50 +00:00
display: 'flex',
alignItems: 'center',
'& > *:not(:last-child)': {
marginRight: theme.spacing(1),
},
},
toolbar: {
padding: theme.spacing(2, 0),
2021-01-17 08:31:50 +00:00
fontSize: '1.25rem',
},
2021-01-17 08:31:50 +00:00
}));
2021-01-17 08:31:50 +00:00
export default Navbar;