From d9be05165fad1fe07f51dbccc47b0fe2e675ee86 Mon Sep 17 00:00:00 2001 From: enes Date: Thu, 29 Aug 2024 17:18:32 +0200 Subject: [PATCH] feat(mobile): tabs and scrolling --- src/layouts/StickySideColumns.module.scss | 30 ++++++++- src/layouts/StickySideColumns.tsx | 82 +++++++++++++++++++---- 2 files changed, 99 insertions(+), 13 deletions(-) diff --git a/src/layouts/StickySideColumns.module.scss b/src/layouts/StickySideColumns.module.scss index 4defd59..6a16522 100644 --- a/src/layouts/StickySideColumns.module.scss +++ b/src/layouts/StickySideColumns.module.scss @@ -9,12 +9,18 @@ grid-auto-flow: column; grid-auto-columns: 100%; + // Hide Scrollbar and let's use tabs to navigate + -ms-overflow-style: none; /* Internet Explorer 10+ */ + scrollbar-width: none; /* Firefox */ + &::-webkit-scrollbar { + display: none; /* Safari and Chrome */ + } overflow-x: auto; overscroll-behavior-inline: contain; - scroll-snap-type: inline mandatory; > * { + scroll-margin-top: $header-height + $body-vertical-padding; scroll-snap-align: start; } } @@ -54,3 +60,25 @@ overflow-y: auto; } } + +.navTabs { + display: none; + position: fixed; + left: 0; + bottom: 0; + right: 0; + z-index: 2; + background: $overlay-background-color; + box-shadow: 0 0 4px 0 rgb(0, 0, 0, 0.1); + + padding: 5px; + gap: 5px; + + @media only screen and (max-width: 767px) { + display: flex; + } + + > li { + flex-grow: 1; + } +} diff --git a/src/layouts/StickySideColumns.tsx b/src/layouts/StickySideColumns.tsx index d27ad4b..493a97e 100644 --- a/src/layouts/StickySideColumns.tsx +++ b/src/layouts/StickySideColumns.tsx @@ -1,6 +1,13 @@ -import { PropsWithChildren, ReactNode } from 'react' +import { PropsWithChildren, ReactNode, useRef, useState } from 'react' import styles from './StickySideColumns.module.scss' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { + faFile, + faFileCirclePlus, + faToolbox +} from '@fortawesome/free-solid-svg-icons' +import { Button } from '@mui/material' interface StickySideColumnsProps { left?: ReactNode @@ -12,19 +19,70 @@ export const StickySideColumns = ({ right, children }: PropsWithChildren) => { + const ref = useRef(null) + const [tab, setTab] = useState('nav-content') + const handleNavClick = (id: string) => { + setTab(id) + const x = document.getElementById(id)?.offsetLeft + if (ref.current) { + ref.current.scrollTo({ + left: x, + behavior: 'smooth' + }) + } + } + const isActive = (id: string) => id === tab + return ( -
-
-
{left}
-
-
-
- {children} + <> +
+ + +
-
-
{right}
-
-
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+ ) }