Skip to content

Commit

Permalink
feat: Hide sidenav for small widths
Browse files Browse the repository at this point in the history
  • Loading branch information
timglaser committed Jun 17, 2020
1 parent b74b2aa commit db6443b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/GlobalHeader.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

@media screen and (max-width: 1240px) {
.global-header-container {
padding: 0 28px;
padding: 0 1rem;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Layout = ({ children }) => (
<>
<GlobalHeader />
<div className={styles.layout}>
<Sidebar pages={pages} />
<Sidebar className={styles.sidebar} pages={pages} />
<main>{children}</main>
</div>
<Footer />
Expand Down
18 changes: 18 additions & 0 deletions src/components/Layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,22 @@
grid-gap: 1rem;
max-width: 1200px;
margin: 0 auto;
padding-top: 1rem;
}

@media (max-width: 760px) {
.layout {
display: block;
}

.sidebar {
display: none;
}
}

@media screen and (max-width: 1240px) {
.layout {
padding-left: 1rem;
padding-right: 1rem;
}
}
9 changes: 2 additions & 7 deletions src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const renderNav = (pages, depthLevel = 0) => {
});
};

const Sidebar = ({ className, pages, isOpen }) => (
<aside className={cx(styles.sidebar, className, { [styles.isOpen]: isOpen })}>
const Sidebar = ({ className, pages }) => (
<aside className={cx(styles.sidebar, className)}>
<Link to="/" className={styles.logo} />
<nav role="navigation" aria-label="Sidebar">
<ul className={styles.listNav}>{renderNav(pages)}</ul>
Expand All @@ -61,11 +61,6 @@ const Sidebar = ({ className, pages, isOpen }) => (
Sidebar.propTypes = {
className: PropTypes.string,
pages: PropTypes.arrayOf(link).isRequired,
isOpen: PropTypes.bool,
};

Sidebar.defaultProps = {
isOpen: false,
};

export default Sidebar;
16 changes: 0 additions & 16 deletions src/components/Sidebar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,10 @@
cursor: pointer;
width: 3rem;
display: none;

@media (max-width: 760px) {
display: block;
}
}

nav {
margin-top: 1rem;

@media (max-width: 760px) {
display: none;
}
}

&.isOpen {
nav {
@media (max-width: 760px) {
display: block;
}
}
}
}

Expand Down

0 comments on commit db6443b

Please sign in to comment.