From 38212dcde99fad25ff221a7f0387a541541769a6 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 27 Apr 2023 06:22:37 -0500 Subject: [PATCH] chore: refactor to move section dropdown to separate component --- src/app/components/NavBar.module.css | 22 ------- src/app/components/NavBar.tsx | 60 +------------------ src/app/components/SectionDropdown.module.css | 21 +++++++ src/app/components/SectionDropdown.tsx | 58 ++++++++++++++++++ 4 files changed, 82 insertions(+), 79 deletions(-) create mode 100644 src/app/components/SectionDropdown.module.css create mode 100644 src/app/components/SectionDropdown.tsx diff --git a/src/app/components/NavBar.module.css b/src/app/components/NavBar.module.css index 00bcdef..3a44ffb 100644 --- a/src/app/components/NavBar.module.css +++ b/src/app/components/NavBar.module.css @@ -77,28 +77,6 @@ } } -.dropdownSelect { - color: #64adac; - background-color: inherit; - border: none; - border-radius: 5px; - cursor: pointer; - font-size: 1rem; - font-weight: bold; - padding: 0 1rem; -} - -.dropdownSelect:focus-visible { - outline: none; -} - -.selectItem { - color: #64adac; - cursor: pointer; - font-weight: bold; - margin: 1rem; -} - .navbarToggle { cursor: pointer; display: none; diff --git a/src/app/components/NavBar.tsx b/src/app/components/NavBar.tsx index b31fd32..b728ed0 100644 --- a/src/app/components/NavBar.tsx +++ b/src/app/components/NavBar.tsx @@ -1,10 +1,11 @@ 'use client'; import Link from 'next/link'; -import { Fragment, useState } from 'react'; +import { useState } from 'react'; import { themes, useThemeContext } from '../theme'; -import { Doc, DocsStructure } from '../types/types'; +import { DocsStructure } from '../types/types'; import styles from './NavBar.module.css'; +import SectionDropdown from './SectionDropdown'; function VersionsDropdown({ version, @@ -94,61 +95,6 @@ function VersionsDropdown({ ); } -function SectionDropdownGroup({ doc }: { doc: Doc }) { - return ( - - {doc.copy && doc.example && ( - - )} - {doc.children && doc.children.length > 0 && ( - - {doc.children.map(child => ( - - ))} - - )} - - ); -} - -function SectionDropdown({ - version, -}: { - version: DocsStructure; -}) { - const handleSelectChange = (e: any) => { - const selectedOption = e.target.value; - location.hash = selectedOption - .replaceAll(' ', '-') - .toLowerCase(); - }; - - return ( - - ); -} - export default function NavBar({ version, }: { diff --git a/src/app/components/SectionDropdown.module.css b/src/app/components/SectionDropdown.module.css new file mode 100644 index 0000000..6893287 --- /dev/null +++ b/src/app/components/SectionDropdown.module.css @@ -0,0 +1,21 @@ +.dropdownSelect { + color: #64adac; + background-color: inherit; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 1rem; + font-weight: bold; + padding: 0 1rem; +} + +.dropdownSelect:focus-visible { + outline: none; +} + +.selectItem { + color: #64adac; + cursor: pointer; + font-weight: bold; + margin: 1rem; +} \ No newline at end of file diff --git a/src/app/components/SectionDropdown.tsx b/src/app/components/SectionDropdown.tsx new file mode 100644 index 0000000..f188cd3 --- /dev/null +++ b/src/app/components/SectionDropdown.tsx @@ -0,0 +1,58 @@ +import { Fragment } from 'react'; +import { Doc, DocsStructure } from '../types/types'; +import styles from './SectionDropdown.module.css'; + +function SectionDropdownGroup({ doc }: { doc: Doc }) { + return ( + + {doc.copy && doc.example && ( + + )} + {doc.children && doc.children.length > 0 && ( + + {doc.children.map(child => ( + + ))} + + )} + + ); +} + +export default function SectionDropdown({ + version, +}: { + version: DocsStructure; +}) { + const handleSelectChange = (e: any) => { + const selectedOption = e.target.value; + location.hash = selectedOption + .replaceAll(' ', '-') + .toLowerCase(); + }; + + return ( + + ); +}