1+ import { clsx } from "clsx" ;
12import PropTypes from "prop-types" ;
23import { Component } from "react" ;
34import CloseIcon from "../../styles/icons/cross.svg" ;
45import Link from "../Link/Link.jsx" ;
5- import "./SidebarMobile.scss" ;
66
77// TODO: Check to make sure all pages are shown and properly sorted
88export default class SidebarMobile extends Component {
@@ -20,28 +20,34 @@ export default class SidebarMobile extends Component {
2020
2121 render ( ) {
2222 const { isOpen, toggle } = this . props ;
23- const openMod = isOpen ? " sidebar-mobile--visible" : "" ;
24-
2523 this . _toggleBodyListener ( isOpen ) ;
2624
2725 return (
2826 < nav
29- className = { `sidebar-mobile${ openMod } ` }
27+ className = { clsx (
28+ "sidebar-mobile fixed w-[300px] h-screen z-[100] top-0 overflow-y-auto overflow-x-hidden [-webkit-overflow-scrolling:touch] transition-transform duration-500 ease-[cubic-bezier(0.23,1,0.32,1)] md:hidden" ,
29+ isOpen
30+ ? "sidebar-mobile--visible translate-x-0"
31+ : "[transform:translate3d(calc(-100%+5px),0,0)]" ,
32+ ) }
3033 ref = { ( ref ) => ( this . _container = ref ) }
3134 onTouchStart = { this . _handleTouchStart }
3235 onTouchMove = { this . _handleTouchMove }
3336 onTouchEnd = { this . _handleTouchEnd }
3437 >
3538 < div
36- className = "sidebar-mobile__toggle"
39+ className = { clsx (
40+ "absolute top-[45px] bottom-0 w-[32px] left-[285px]" ,
41+ isOpen && "hidden" ,
42+ ) }
3743 onTouchStart = { this . _handleTouchStart }
3844 onTouchMove = { this . _handleOpenerTouchMove }
3945 onTouchEnd = { this . _handleTouchEnd }
4046 />
4147
42- < div className = "sidebar-mobile__content " >
48+ < div className = "relative w-[285px] h-screen overflow-x-hidden py-1 bg-white shadow-[0_0_15px_rgba(0,0,0,0.2)] " >
4349 < button
44- className = "sidebar-mobile__close"
50+ className = "sidebar-mobile__close absolute cursor-pointer border-none right-[22px] top-[10px] text-[1.3em] bg-[#175d96] text-white w-[30px] h-[30px] flex items-center justify-center rounded-full transition-colors duration-150 [-webkit-tap-highlight-color:transparent] hover:bg-[#135d96] "
4551 onClick = { toggle . bind ( null , false ) }
4652 aria-label = "Close navigation menu"
4753 >
@@ -72,18 +78,23 @@ export default class SidebarMobile extends Component {
7278 pathname = window . location . pathname ;
7379 }
7480
75- return this . props . sections . map ( ( section ) => {
81+ return this . props . sections . map ( ( section , index ) => {
7682 const active = section . url !== "/" && pathname . startsWith ( section . url ) ;
7783
7884 return (
7985 < div
80- className = { `sidebar-mobile__section ${
81- active ? "sidebar-mobile__section--active" : ""
82- } `}
86+ className = { clsx (
87+ "border-l-2 pb-[0.5em]" ,
88+ active ? "border-blue-200" : "border-transparent" ,
89+ ) }
8390 key = { section . url }
8491 >
8592 < Link
86- className = "sidebar-mobile__section-header"
93+ className = { clsx (
94+ "uppercase pt-[0.75em] px-4 pb-[0.25em] font-semibold block text-[1.1rem]" ,
95+ active ? "text-[#465E69]" : "text-[#2B3A42]" ,
96+ index > 0 && "border-t border-gray-200" ,
97+ ) }
8798 key = { section . url }
8899 to = { section . url }
89100 onClick = { this . props . toggle . bind ( null , false ) }
@@ -117,9 +128,12 @@ export default class SidebarMobile extends Component {
117128 return (
118129 < Link
119130 key = { url }
120- className = { `sidebar-mobile__page sidebar-mobile__section-child ${
121- active ? "sidebar-mobile__page--active" : ""
122- } `}
131+ className = { clsx (
132+ "block py-[0.5em] px-[17px] capitalize [-webkit-tap-highlight-color:transparent] ml-[20px]" ,
133+ active
134+ ? "text-gray-900 font-semibold bg-[#f1f4f4]"
135+ : "text-gray-600 hover:text-gray-600 active:text-gray-900 active:font-semibold active:bg-[#f1f4f4]" ,
136+ ) }
123137 to = { url }
124138 onClick = { this . props . toggle . bind ( null , false ) }
125139 >
@@ -146,7 +160,7 @@ export default class SidebarMobile extends Component {
146160 this . _initialTouchPosition . y = event . touches [ 0 ] . pageY ;
147161
148162 // For instant transform along with the touch
149- this . _container . classList . add ( "no-delay " ) ;
163+ this . _container . classList . add ( "!duration-0 " ) ;
150164 } ;
151165
152166 _handleTouchMove = ( event ) => {
@@ -182,7 +196,7 @@ export default class SidebarMobile extends Component {
182196 const threshold = 20 ;
183197
184198 // Free up all the inline styling
185- this . _container . classList . remove ( "no-delay " ) ;
199+ this . _container . classList . remove ( "!duration-0 " ) ;
186200 this . _container . style . transform = "" ;
187201
188202 // are we open?
0 commit comments