From a0b00485bc09ccca85a8059b639928cbeb0e81fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pr=C3=A3t!k=20K=C3=A0b=C3=A1d=C3=A9?= Date: Thu, 18 Apr 2024 04:01:20 +0000 Subject: [PATCH 1/2] #867 Created Dropdown Options --- app/tag-data.json | 21 +---------------- components/Header.tsx | 2 ++ components/MobileNav.tsx | 19 ++++++++++++---- components/NavOptions.tsx | 47 +++++++++++++++++++++++++++++++++++++++ data/headerNavLinks.ts | 8 +++++++ 5 files changed, 73 insertions(+), 24 deletions(-) create mode 100644 components/NavOptions.tsx diff --git a/app/tag-data.json b/app/tag-data.json index 7bacbaf8c4..bbe15acaae 100644 --- a/app/tag-data.json +++ b/app/tag-data.json @@ -1,20 +1 @@ -{ - "markdown": 1, - "code": 1, - "features": 1, - "next-js": 6, - "math": 1, - "ols": 1, - "github": 1, - "guide": 5, - "tailwind": 3, - "hello": 1, - "holiday": 1, - "canada": 1, - "images": 1, - "feature": 2, - "writings": 1, - "book": 1, - "reflection": 1, - "multi-author": 1 -} +{"markdown":1,"code":1,"features":1,"next-js":6,"math":1,"ols":1,"github":1,"guide":5,"tailwind":3,"hello":1,"holiday":1,"canada":1,"images":1,"feature":2,"writings":1,"book":1,"reflection":1,"multi-author":1} \ No newline at end of file diff --git a/components/Header.tsx b/components/Header.tsx index 362b7cdd9d..4e703425ca 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -5,6 +5,7 @@ import Link from './Link' import MobileNav from './MobileNav' import ThemeSwitch from './ThemeSwitch' import SearchButton from './SearchButton' +import { NavOptions } from './NavOptions' const Header = () => { return ( @@ -37,6 +38,7 @@ const Header = () => { {link.title} ))} + diff --git a/components/MobileNav.tsx b/components/MobileNav.tsx index b777b822c6..16f37c33b3 100644 --- a/components/MobileNav.tsx +++ b/components/MobileNav.tsx @@ -2,7 +2,7 @@ import { useState } from 'react' import Link from './Link' -import headerNavLinks from '@/data/headerNavLinks' +import headerNavLinks, { headerNavOptions } from '@/data/headerNavLinks' const MobileNav = () => { const [navShow, setNavShow] = useState(false) @@ -36,9 +36,8 @@ const MobileNav = () => {
))} + {headerNavOptions.children && ( + headerNavOptions.children.map((link) => ( +
+ + {link.title} + +
+ )))}
diff --git a/components/NavOptions.tsx b/components/NavOptions.tsx new file mode 100644 index 0000000000..c79cfe236a --- /dev/null +++ b/components/NavOptions.tsx @@ -0,0 +1,47 @@ +'use client' + +import { Fragment, useEffect, useState } from 'react' +import { useTheme } from 'next-themes' +import { Menu, RadioGroup, Transition } from '@headlessui/react' +import { headerNavOptions } from '@/data/headerNavLinks' +import Link from 'next/link' + +export const NavOptions = () => { + return ( +
+ +
+ {headerNavOptions.title && ( + + {headerNavOptions.title} + + )} +
+ + +
+ {headerNavOptions.children && headerNavOptions.children.map((link) => ( + + + {link.title} + + + ))} +
+
+
+
+
+ ) +} \ No newline at end of file diff --git a/data/headerNavLinks.ts b/data/headerNavLinks.ts index 8ca9493dbb..7005935f75 100644 --- a/data/headerNavLinks.ts +++ b/data/headerNavLinks.ts @@ -6,4 +6,12 @@ const headerNavLinks = [ { href: '/about', title: 'About' }, ] +export const headerNavOptions = { + title: 'Dropdown', children: [ + {href: '/projects', title: 'Projects',}, + {href: '/about', title: 'About',}, + ] +} + + export default headerNavLinks From c6e2fb1f3b80a393adeb4610e9516b6050e12203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pr=C3=A3t!k=20K=C3=A0b=C3=A1d=C3=A9?= Date: Mon, 22 Apr 2024 07:24:51 +0000 Subject: [PATCH 2/2] prettier `fix` --- app/tag-data.json | 2 +- components/Header.tsx | 2 +- components/MobileNav.tsx | 9 +++++---- components/NavOptions.tsx | 23 ++++++++++++----------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/tag-data.json b/app/tag-data.json index bbe15acaae..e35862a4fd 100644 --- a/app/tag-data.json +++ b/app/tag-data.json @@ -1 +1 @@ -{"markdown":1,"code":1,"features":1,"next-js":6,"math":1,"ols":1,"github":1,"guide":5,"tailwind":3,"hello":1,"holiday":1,"canada":1,"images":1,"feature":2,"writings":1,"book":1,"reflection":1,"multi-author":1} \ No newline at end of file +{"markdown":1,"code":1,"features":1,"next-js":6,"math":1,"ols":1,"github":1,"guide":5,"tailwind":3,"holiday":1,"canada":1,"images":1,"feature":2,"writings":1,"book":1,"reflection":1,"multi-author":1} \ No newline at end of file diff --git a/components/Header.tsx b/components/Header.tsx index 4e703425ca..a8db0a39d2 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -38,7 +38,7 @@ const Header = () => { {link.title} ))} - + diff --git a/components/MobileNav.tsx b/components/MobileNav.tsx index 16f37c33b3..0fbec479da 100644 --- a/components/MobileNav.tsx +++ b/components/MobileNav.tsx @@ -36,8 +36,9 @@ const MobileNav = () => {
))} - {headerNavOptions.children && ( + {headerNavOptions.children && headerNavOptions.children.map((link) => (
{ {link.title}
- )))} + ))}
diff --git a/components/NavOptions.tsx b/components/NavOptions.tsx index c79cfe236a..8e390bfe97 100644 --- a/components/NavOptions.tsx +++ b/components/NavOptions.tsx @@ -28,20 +28,21 @@ export const NavOptions = () => { >
- {headerNavOptions.children && headerNavOptions.children.map((link) => ( - - - {link.title} - - - ))} + {headerNavOptions.children && + headerNavOptions.children.map((link) => ( + + + {link.title} + + + ))}
) -} \ No newline at end of file +}