From 5eeba20302008eac38e29b1b994aa1c578dfc61b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 18 Apr 2023 22:51:50 -0500 Subject: [PATCH] feat: add mobile navigation dropdown --- src/app/components/Main.module.css | 17 ------- src/app/components/NavBar.module.css | 38 +++++++++++++++- src/app/components/NavBar.tsx | 64 +++++++++++++++++++++++++-- src/app/components/SideBar.module.css | 16 +++++++ src/app/components/SideBar.tsx | 5 ++- 5 files changed, 116 insertions(+), 24 deletions(-) diff --git a/src/app/components/Main.module.css b/src/app/components/Main.module.css index bdab4b8..6580b02 100644 --- a/src/app/components/Main.module.css +++ b/src/app/components/Main.module.css @@ -9,23 +9,6 @@ scrollbar-color: transparent #0b3766; } -.container::-webkit-scrollbar { - background-color: transparent; -} - -.container::-webkit-scrollbar-thumb { - background-color: transparent; - border-radius: 10px; -} - -.container:hover::-webkit-scrollbar-thumb { - background-color: #0b3766; -} - -.container:hover::-webkit-scrollbar { - background-color: #043160; -} - .divider { width: 100%; height: 1px; diff --git a/src/app/components/NavBar.module.css b/src/app/components/NavBar.module.css index c74756d..99a78c0 100644 --- a/src/app/components/NavBar.module.css +++ b/src/app/components/NavBar.module.css @@ -1,8 +1,8 @@ .nav { display: flex; - justify-content: flex-end; + justify-content: space-between; align-items: center; - padding: 1rem; + padding: 1rem 0; width: 100%; max-width: 1450px; margin: 0 auto; @@ -11,6 +11,7 @@ .navList { display: flex; list-style: none; + padding: 0 1rem 0 0; } .navItem { @@ -57,4 +58,37 @@ .chevron { margin-left: 0.5rem; +} + +.sectionDropdown { + display: none; +} + +@media screen and (max-width: 1000px) { + .sectionDropdown { + display: block; + } +} + +.dropdownSelect { + color: #64adac; + background-color: #05254a; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 1rem; + font-weight: bold; + padding: 0 1rem; +} + +.dropdownSelect:focus-visible { + outline: none; +} + +.selectItem { + background-color: #05254a; + color: #64adac; + cursor: pointer; + font-weight: bold; + margin: 1rem; } \ No newline at end of file diff --git a/src/app/components/NavBar.tsx b/src/app/components/NavBar.tsx index 2ec8813..e8dfd39 100644 --- a/src/app/components/NavBar.tsx +++ b/src/app/components/NavBar.tsx @@ -1,8 +1,8 @@ 'use client'; import Link from 'next/link.js'; -import { useState } from 'react'; -import { DocsStructure } from '../types/types.js'; +import { Fragment, useState } from 'react'; +import { Doc, DocsStructure } from '../types/types.js'; import styles from './NavBar.module.css'; function VersionsDropdown({ @@ -93,8 +93,59 @@ function VersionsDropdown({ ); } -function SectionDropdown({ section }: { section: string }) { - return <>>; +function SectionDropdownGroup({ doc }: { doc: Doc }) { + return ( + + {doc.copy && doc.example && ( + + {doc.title} + + )} + {doc.children && doc.children.length > 0 && ( + + {doc.children.map(child => ( + + {child.title} + + ))} + + )} + + ); +} + +function SectionDropdown({ + version, +}: { + version: DocsStructure; +}) { + const handleSelectChange = (e: any) => { + const selectedOption = e.target.value; + location.hash = selectedOption + .replaceAll(' ', '-') + .toLowerCase(); + }; + + return ( + + {version.docs.map(doc => { + return ( + + ); + })} + + ); } export default function NavBar({ @@ -104,6 +155,11 @@ export default function NavBar({ }) { return ( + + + + + diff --git a/src/app/components/SideBar.module.css b/src/app/components/SideBar.module.css index 5d7449f..189d3b5 100644 --- a/src/app/components/SideBar.module.css +++ b/src/app/components/SideBar.module.css @@ -8,6 +8,12 @@ scrollbar-color: transparent #0b3766; } +@media screen and (max-width: 1000px) { + .container { + display: none; + } +} + .container::-webkit-scrollbar { background-color: transparent; } @@ -21,6 +27,10 @@ background-color: #0b3766; } +.container::-webkit-scrollbar-corner { + background-color: transparent; +} + .link { text-decoration: none; } @@ -80,6 +90,12 @@ justify-content: space-between; align-items: center; gap: 3rem; + flex: 1 1 auto; +} + +.chevronContainer { + display: flex; + justify-content: center; } .chevron { diff --git a/src/app/components/SideBar.tsx b/src/app/components/SideBar.tsx index b58c5f3..47a8eb2 100644 --- a/src/app/components/SideBar.tsx +++ b/src/app/components/SideBar.tsx @@ -24,7 +24,10 @@ function TreeNode({ doc }: { doc: Doc }) { > {doc.title} - setIsExpanded(!isExpanded)}> + setIsExpanded(!isExpanded)} + > {isExpanded ? (