From 044cc33268556e90ce75763003172fbaf7655f20 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Sat, 30 Nov 2019 18:12:07 +0400 Subject: [PATCH] Make mobile sidebar responsive --- components/detailed-roadmap/index.js | 26 +++++++++++++-- components/detailed-roadmap/style.js | 47 ++++++++++++++++++++++++++++ components/site-nav/index.js | 2 +- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/components/detailed-roadmap/index.js b/components/detailed-roadmap/index.js index 1cceccbff..fb73e780f 100644 --- a/components/detailed-roadmap/index.js +++ b/components/detailed-roadmap/index.js @@ -1,12 +1,17 @@ -import { PageHeader, RoadmapMeta, ShareRoadmap, Sidebar, Summary, SummaryContainer } from './style'; +import { useState } from 'react'; +import classNames from 'classnames'; +import { PageHeader, RoadmapMeta, ShareRoadmap, Sidebar, Summary, SummaryContainer, MobileNavHeader, SidebarButton, MobileSidebar, MobileSidebarWrap } from './style'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faFacebookSquare, faTwitterSquare, faRedditSquare, faGithubSquare } from '@fortawesome/free-brands-svg-icons' +import { faBars } from '@fortawesome/free-solid-svg-icons' import { getFacebookShareUrl } from 'lib/url'; import { ShareIcon } from 'components/share-icon'; import { getRedditShareUrl, getTwitterShareUrl } from 'lib/url'; import siteConfig from "storage/site"; const DetailedRoadmap = ({ roadmap }) => { + const [menuActive, setMenuState] = useState(false); + const roadmapPages = Object.keys(roadmap.sidebar || {}).map(groupTitle => { return (
@@ -51,8 +56,25 @@ const DetailedRoadmap = ({ roadmap }) => {
+ + +
+ setMenuState((prevMenuActive) => !prevMenuActive)}> + + Getting Job Ready + +
+ +
+ + { roadmapPages } + +
+
+
+ - + { roadmapPages }
diff --git a/components/detailed-roadmap/style.js b/components/detailed-roadmap/style.js index 92d4c9997..e248bea04 100644 --- a/components/detailed-roadmap/style.js +++ b/components/detailed-roadmap/style.js @@ -49,6 +49,27 @@ export const ShareRoadmap = styled.div` } `; +export const MobileNavHeader = styled.div` + padding: 10px 0; + display: flex; + align-items: center; + position: relative; +`; + +export const SidebarButton = styled.button` + background: transparent; + border: none !important; + box-shadow: none !important; + outline: none !important; + -webkit-appearance: none; + display: flex; + align-items: center; + + svg { + margin-right: 10px; + } +`; + export const Sidebar = styled.div` border-left: 1px solid #efefef; padding-bottom: 150px; @@ -107,3 +128,29 @@ export const Sidebar = styled.div` } } `; + +export const MobileSidebarWrap = styled.div` + position: absolute; + z-index: 999; + background: white; + width: 100%; + left: 0; + bottom: 100%; + overflow-y: scroll; + box-shadow: rgba(0, 0, 0, 0.1) 0 10px 20px; + top: calc(100% + 1px); + transition: bottom 0.5s ease 0s; + + &.visible { + bottom: -50vh; + } +`; + +export const MobileSidebar = styled(Sidebar)` + margin-left: 12px; + padding-bottom: 20px; + + .links-group { + width: auto; + } +`; diff --git a/components/site-nav/index.js b/components/site-nav/index.js index de973d5f6..f1470296b 100644 --- a/components/site-nav/index.js +++ b/components/site-nav/index.js @@ -12,7 +12,7 @@ const SiteNav = () => (
Roadmaps Guides - FAQ + FAQ Subscribe