Navbar gray when dark mode
All checks were successful
Build and Deploy to Web Server / deploy (push) Successful in 13m27s

This commit is contained in:
2025-08-11 18:04:58 +09:30
parent e45c898ca1
commit 8535965ea7

View File

@@ -24,12 +24,14 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
"mx-auto border-b-1 border-solid px-4 shadow-lg transition", "mx-auto border-b-1 border-solid px-4 shadow-lg transition",
navbarDisplay == "transparent" navbarDisplay == "transparent"
? "border-gray-500 bg-transparent" ? "border-gray-500 bg-transparent"
: "border-white bg-white" : "border-white bg-white dark:border-gray-700 dark:bg-gray-700 dark:text-white"
]} ]}
> >
<div class="flex h-12 items-center justify-between"> <div class="flex h-12 items-center justify-between">
<!-- Logo --> <!-- Logo -->
<div class="font-header flex-shrink-0 text-2xl font-bold uppercase"> <div
class="font-header text-primary flex-shrink-0 text-2xl font-bold uppercase"
>
<a href="/" aria-label="Go home" <a href="/" aria-label="Go home"
>{person.names.first} {person.names.last}</a >{person.names.first} {person.names.last}</a
> >
@@ -50,7 +52,9 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
href={link.href} href={link.href}
class:list={[ class:list={[
"font-header font-medium uppercase transition hover:text-gray-300", "font-header font-medium uppercase transition hover:text-gray-300",
pathName === link.href ? "text-primary" : "text-gray-500" pathName === link.href
? "text-primary"
: "text-gray-500 dark:text-white"
]} ]}
aria-current={pathName === link.href ? "page" : undefined} aria-current={pathName === link.href ? "page" : undefined}
> >
@@ -64,7 +68,7 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
<div class="md:hidden"> <div class="md:hidden">
<button <button
id="menu-toggle" id="menu-toggle"
class="text-2xl text-gray-500 focus:outline-none" class="text-2xl text-gray-500 focus:outline-none dark:text-white"
> >
</button> </button>
@@ -75,7 +79,7 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
<!-- Mobile Menu --> <!-- Mobile Menu -->
<div <div
id="mobile-menu" id="mobile-menu"
class="hidden space-y-2 bg-white px-4 pt-4 pb-4 font-medium shadow-lg md:hidden" class="hidden space-y-2 bg-white px-4 pt-4 pb-4 font-medium shadow-lg md:hidden dark:bg-gray-600 dark:text-white"
> >
{ {
links.map((link) => ( links.map((link) => (
@@ -83,7 +87,9 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
href={link.href} href={link.href}
class:list={[ class:list={[
"block transition hover:text-gray-300", "block transition hover:text-gray-300",
pathName === link.href ? "text-primary" : "text-gray-500" pathName === link.href
? "text-primary"
: "text-gray-500 dark:text-white"
]} ]}
aria-current={pathName === link.href ? "page" : undefined} aria-current={pathName === link.href ? "page" : undefined}
> >
@@ -134,12 +140,24 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
if (navbar) { if (navbar) {
if (window.scrollY === 0 && window.navbarDisplay === "transparent") { if (window.scrollY === 0 && window.navbarDisplay === "transparent") {
// At top - make navbar transparent // At top - make navbar transparent
navbar.classList.remove("bg-white", "border-white"); navbar.classList.remove(
"bg-white",
"border-white",
"dark:bg-gray-700",
"dark:border-gray-700",
"dark:text-white"
);
navbar.classList.add("bg-transparent", "border-gray-500"); navbar.classList.add("bg-transparent", "border-gray-500");
} else { } else {
// Scrolled down - add background color // Scrolled down - add background color
navbar.classList.remove("bg-transparent", "border-gray-500"); navbar.classList.remove("bg-transparent", "border-gray-500");
navbar.classList.add("bg-white", "border-white"); navbar.classList.add(
"bg-white",
"border-white",
"dark:bg-gray-700",
"dark:border-gray-700",
"dark:text-white"
);
} }
} }
}; };