feat(navbar) update navbar

This commit is contained in:
lumither committed 2024-05-29 18:36:55 +08:00
1 parent 99d76f0a8c
commit a59f6d7ae0
7 files changed
+144 -18

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import React from 'react';
const Archive = () => {
return (
<div>
</div>
);
};
export default Archive;
+1 -1
View File
@@ -4,7 +4,7 @@ import Generate from '@/app/blog/post/[id]/generate';
function BlogReader({ params }: { params: { id: string } }) { function BlogReader({ params }: { params: { id: string } }) {
return ( return (
<div className={ `mx-7 my-7 w-full` }> <div className={ `w-full` }>
<Generate id={ params.id } /> <Generate id={ params.id } />
</div> </div>
); );
+3 -1
View File
@@ -3,6 +3,7 @@ import './globals.css';
import React from 'react'; import React from 'react';
import { ThemeProvider as NextThemesProvider } from 'next-themes'; import { ThemeProvider as NextThemesProvider } from 'next-themes';
import Navbar from '@/components/Navbar'; import Navbar from '@/components/Navbar';
import Footer from '@/components/Footer';
export const metadata: Metadata = { export const metadata: Metadata = {
@@ -21,8 +22,9 @@ export default function RootLayout({
<NextThemesProvider attribute="class" defaultTheme="dark"> <NextThemesProvider attribute="class" defaultTheme="dark">
<div className={ `justify-center flex flex-row w-full` }> <div className={ `justify-center flex flex-row w-full` }>
<Navbar /> <Navbar />
<div className={ `flex-auto max-w-[1024px]` }> <div className={ `flex flex-col flex-auto max-w-[1024px]` }>
{ children } { children }
<Footer />
</div> </div>
</div> </div>
</NextThemesProvider> </NextThemesProvider>
+11
View File
@@ -0,0 +1,11 @@
import React from 'react';
const Search = () => {
return (
<div>
</div>
);
};
export default Search;
+11
View File
@@ -0,0 +1,11 @@
import React from 'react';
const Tags = () => {
return (
<div>
</div>
);
};
export default Tags;
+83 -15
View File
@@ -14,6 +14,7 @@ import {
} from 'react-icons/io5'; } from 'react-icons/io5';
import Link from 'next/link'; import Link from 'next/link';
import ThemeSwitcher from '@/components/ThemeSwitcher'; import ThemeSwitcher from '@/components/ThemeSwitcher';
import { usePathname } from 'next/navigation';
const entries: { display_name: string; href: string; icon: React.ReactNode }[] = [ const entries: { display_name: string; href: string; icon: React.ReactNode }[] = [
{ {
@@ -39,7 +40,7 @@ const entries: { display_name: string; href: string; icon: React.ReactNode }[] =
{ {
icon: <IoFileTrayFull size={ `20px` }></IoFileTrayFull>, icon: <IoFileTrayFull size={ `20px` }></IoFileTrayFull>,
display_name: 'Archive', display_name: 'Archive',
href: '/Archive' href: '/archive'
}, },
{ {
icon: <IoSearch size={ `20px` }></IoSearch>, icon: <IoSearch size={ `20px` }></IoSearch>,
@@ -48,9 +49,21 @@ const entries: { display_name: string; href: string; icon: React.ReactNode }[] =
} }
]; ];
const connections: { label: string, href: string, icon: React.ReactNode }[] = [
{
label: 'Github',
href: 'https://github.com/Lumither',
icon: <IoLogoGithub size={ `30px` } />
},
{
label: 'email',
href: 'mailto:lumither@outlook.com',
icon: <IoMail size={ `30px` } />
}
];
function Navbar() { function Navbar() {
const [ scrolled, setScrolled ] = useState(false); const [ scrolled, setScrolled ] = useState(false);
useEffect(() => { useEffect(() => {
const handleScroll = () => { const handleScroll = () => {
const isScrolled = window.scrollY > 0; const isScrolled = window.scrollY > 0;
@@ -63,11 +76,43 @@ function Navbar() {
}, []); }, []);
const path = usePathname();
const [ shownPath, setShownPath ] = useState(path);
useEffect(() => {
let trimmed_path = path.split(`/`)[1];
if (trimmed_path === '') {
setShownPath('HOME');
} else {
setShownPath(trimmed_path.toUpperCase());
}
}, [ path ]);
const minMobileWidth: number = 768;
const [ isMobile, setIsMobile ] = useState(false);
useEffect(() => {
const updateMobileWidth = () => {
if (window.innerWidth <= minMobileWidth) {
setIsMobile(true);
} else {
setIsMobile(false);
}
};
updateMobileWidth();
window.addEventListener('resize', updateMobileWidth);
return () => {
window.removeEventListener('resize', updateMobileWidth);
};
}, []);
return ( return (
<> <>
<div <div
className={ `flex flex-col w-full max-w-[256px] mr-2 ml-8 min-h-screen max-h-screen pt-8 sticky` }> className={ `flex flex-col w-auto md:w-full min-w-[50px] max-w-[256px] mr-2 ml-8 min-h-screen max-h-screen pt-8 sticky` }>
<div className={ `fixed min-h-screen h-full` }> <div className={ `fixed min-h-screen h-full` }>
<div className={ `hidden md:block` }>
<div className={ `flex justify-center items-center my-7` }> <div className={ `flex justify-center items-center my-7` }>
<Image <Image
src={ 'https://avatars.githubusercontent.com/u/46409277?v=4' } src={ 'https://avatars.githubusercontent.com/u/46409277?v=4' }
@@ -79,34 +124,51 @@ function Navbar() {
></Image> ></Image>
</div> </div>
<div>
<p className={ `font-bold text-2xl` }>Lumither Tao</p> <p className={ `font-bold text-2xl` }>Lumither Tao</p>
<p className={ `text-xl text-zinc-500 dark:text-zinc-400` }>Ad Astra</p> <p className={ `text-xl text-zinc-500 dark:text-zinc-400` }>Ad Astra</p>
</div>
</div>
<div className={ `flex flex-row items-center my-4 space-x-2` }> <div>
<Link href={ 'https://github.com/Lumither' } aria-label={ `GitHub` }> <ul className={ `flex flex-col space-y-2 md:space-y-0 md:flex-row items-center my-4 md:space-x-2` }>
<IoLogoGithub size={ `30px` } /> {
</Link> connections.map((conn, key) => (
<Link href={ 'mailto:lumither@outlook.com' } aria-label={ `email` }> <li key={ key }>
<IoMail size={ `30px` } /> <Button as={ Link }
</Link> href={ conn.href }
aria-label={ conn.label }
variant={ `light` }
color={ `default` }
className={ `w-fit` }
isIconOnly
>
{ conn.icon }
</Button>
</li>
))
}
</ul>
</div> </div>
<div <div
className={ `mt-8 -ml-3` }> className={ `mt-8 ml-0 md:-ml-3` }>
<ul className={ `flex flex-col space-y-2` }> <ul className={ `flex flex-col space-y-2` }>
{ {
entries.map((meta, key) => ( entries.map((meta, key) => (
<li key={ key }> <li key={ key }>
<Button startContent={ meta.icon } <Button
as={ Link } as={ Link }
variant={ `light` } variant={ `light` }
color={ `default` } color={ `default` }
fullWidth fullWidth
className={ 'flex justify-start' } isIconOnly={ isMobile }
// className={ `w-full` } className={ 'flex md:justify-start w-fit md:w-full' }
aria-label={ `navbar: ${ meta.display_name }` } aria-label={ `navbar: ${ meta.display_name }` }
href={ meta.href }> href={ meta.href }>
<p className={ `font-bold` }>{ meta.display_name }</p> { meta.icon }
<p className={ `font-bold hidden md:block` }>{ meta.display_name }</p>
</Button> </Button>
</li> </li>
)) ))
@@ -114,6 +176,12 @@ function Navbar() {
</ul> </ul>
</div> </div>
<div className={ `mt-8 md:hidden` }>
<p className={ `sideways-lr font-bold text-2xl text-zinc-500 dark:text-zinc-400` }>
{ shownPath }
</p>
</div>
<div <div
className={ `absolute bottom-8 mb-8` } className={ `absolute bottom-8 mb-8` }
> >
+24 -1
View File
@@ -1,6 +1,7 @@
import { nextui } from '@nextui-org/react'; import { nextui } from '@nextui-org/react';
import type { Config } from 'tailwindcss'; import type { Config } from 'tailwindcss';
import plugin from 'tailwindcss/plugin';
const config: Config = { const config: Config = {
content: [ content: [
@@ -30,6 +31,28 @@ const config: Config = {
} }
} }
} }
) ] ),
plugin(function ({ addUtilities, addComponents, e, config }) {
addUtilities(
{
'.horizontal-tb': {
writingMode: 'horizontal-tb'
},
'.vertical-rl': {
writingMode: 'vertical-rl'
},
'.vertical-lr': {
writingMode: 'vertical-lr'
},
'.sideways-lr': {
writingMode: 'sideways-lr'
},
'.sideways-rl': {
writingMode: 'sideways-rl'
}
}
);
})
]
}; };
export default config; export default config;