From a5224475701ed1d3fcfd54c1255bc830ee8e432c Mon Sep 17 00:00:00 2001 From: z0x Date: Wed, 7 May 2025 10:01:47 -0400 Subject: [PATCH] refactor: update footer, revamp theme toggle, add head metadata, post navigation spacing --- src/components/Footer.astro | 15 ++-- src/components/Head.astro | 56 +++----------- src/components/Header.astro | 12 +-- src/components/PostNavigation.astro | 23 +++--- src/components/TableOfContentsHeading.astro | 26 ------- src/components/ThemeToggle.astro | 85 +++++++++++++++++++++ src/components/ui/mode-toggle.tsx | 47 ------------ src/layouts/Layout.astro | 8 +- src/styles/global.css | 1 - 9 files changed, 129 insertions(+), 144 deletions(-) delete mode 100644 src/components/TableOfContentsHeading.astro create mode 100644 src/components/ThemeToggle.astro delete mode 100644 src/components/ui/mode-toggle.tsx diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 305a3c9..24d5c01 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -11,12 +11,17 @@ import SocialIcons from "./SocialIcons.astro";--- class="flex flex-col items-center justify-center gap-y-2 sm:flex-row sm:justify-between" >
- - © {new Date().getFullYear()} • z0x + + © {new Date().getFullYear()} All rights reserved. - -

- All rights reserved. + +

+ z0x

diff --git a/src/components/Head.astro b/src/components/Head.astro index 2c7dd6e..44cf21d 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -1,10 +1,4 @@ --- -import "@fontsource-variable/geist"; -import "@fontsource-variable/geist-mono"; -import "../styles/callout.css"; -import "../styles/global.css"; -import "../styles/typography.css"; - import { ClientRouter } from "astro:transitions"; import { SITE } from "@/consts"; @@ -16,15 +10,18 @@ interface Props { const canonicalURL = new URL(Astro.url.pathname, Astro.site); -const { title, description, image = "/static/twitter-card.png" } = Astro.props; +const { title, description } = Astro.props; --- - - + + + + + + {title} @@ -69,38 +72,3 @@ const { title, description, image = "/static/twitter-card.png" } = Astro.props; - - diff --git a/src/components/Header.astro b/src/components/Header.astro index 4e3ad28..81d1f17 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,7 +1,7 @@ --- import Container from "@/components/Container.astro"; import Link from "@/components/Link.astro"; -import { ModeToggle } from "@/components/ui/mode-toggle"; +import ThemeToggle from "@/components/ThemeToggle.astro"; import { SITE } from "@/consts"; --- @@ -11,15 +11,11 @@ import { SITE } from "@/consts"; >
- + {SITE.title}
- -
+
- + \ No newline at end of file diff --git a/src/components/PostNavigation.astro b/src/components/PostNavigation.astro index a3394fa..852e28e 100644 --- a/src/components/PostNavigation.astro +++ b/src/components/PostNavigation.astro @@ -12,7 +12,7 @@ const { prevPost, nextPost } = Astro.props; href={nextPost ? `/blog/${nextPost.id}` : '#'} class={cn( buttonVariants({ variant: 'outline' }), - 'rounded-xl group flex items-center justify-start w-full h-full', + 'rounded-xl group flex items-center justify-start size-full', !nextPost && 'pointer-events-none opacity-50 cursor-not-allowed', )} aria-disabled={!nextPost} @@ -23,28 +23,27 @@ const { prevPost, nextPost } = Astro.props; class="size-4 transition-transform group-hover:-translate-x-1" /> -
+
Next Post - {nextPost?.data.title || 'Latest post!'} + + {nextPost?.data.title || 'Latest post!'} +
-
- Previous Post - {prevPost?.data.title || 'Last post!'} +
+ Previous Post + + {prevPost?.data.title || 'Last post!'} +
- - {heading.text} - - { - heading.subheadings.length > 0 && ( -
    - {heading.subheadings.map((subheading: Heading) => ( - - ))} -
- ) - } - diff --git a/src/components/ThemeToggle.astro b/src/components/ThemeToggle.astro new file mode 100644 index 0000000..88d4a39 --- /dev/null +++ b/src/components/ThemeToggle.astro @@ -0,0 +1,85 @@ +--- +import { Button } from "@/components/ui/button"; +import { Icon } from "astro-icon/components"; +--- + + + + + + \ No newline at end of file diff --git a/src/components/ui/mode-toggle.tsx b/src/components/ui/mode-toggle.tsx deleted file mode 100644 index 0e171d9..0000000 --- a/src/components/ui/mode-toggle.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { Button } from "@/components/ui/button"; -import { Moon, Sun } from "lucide-react"; -import * as React from "react"; - -export function ModeToggle() { - const [theme, setTheme] = React.useState<"theme-light" | "dark" | "system">( - "theme-light", - ); - - React.useEffect(() => { - const isDarkMode = document.documentElement.classList.contains("dark"); - setTheme(isDarkMode ? "dark" : "theme-light"); - }, []); - - React.useEffect(() => { - const isDark = theme === "dark"; - - document.documentElement.classList.add("disable-transitions"); - document.documentElement.classList[isDark ? "add" : "remove"]("dark"); - - window - .getComputedStyle(document.documentElement) - .getPropertyValue("opacity"); - - requestAnimationFrame(() => { - document.documentElement.classList.remove("disable-transitions"); - }); - }, [theme]); - - const toggleTheme = () => { - setTheme(theme === "dark" ? "theme-light" : "dark"); - }; - - return ( - - ); -} diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 87e692c..8546e70 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,4 +1,10 @@ --- +import "@/styles/callout.css"; +import "@/styles/global.css"; +import "@/styles/typography.css"; +import "@fontsource-variable/geist"; +import "@fontsource-variable/geist-mono"; + import Footer from "@/components/Footer.astro"; import Head from "@/components/Head.astro"; import Header from "@/components/Header.astro"; @@ -19,7 +25,7 @@ const { title, description } = Astro.props;
diff --git a/src/styles/global.css b/src/styles/global.css index aa3767b..43fc2c6 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -86,7 +86,6 @@ } } - .disable-transitions, .disable-transitions * { @apply transition-none!; }