From c707539938cf127c9b9bde3267aa7d5c34f2ed08 Mon Sep 17 00:00:00 2001 From: Francisco Javier Arceo Date: Wed, 8 Jul 2026 10:13:27 -0400 Subject: [PATCH] feat: Add dark mode support to website and blog Adds a theme toggle (sun/moon icon) to the navigation bar with localStorage persistence and prefers-color-scheme detection. Replaces all hardcoded light-mode colors with CSS custom properties that adapt under a [data-theme="dark"] selector. Includes flash-prevention via an inline script that sets the theme before first paint. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Francisco Javier Arceo --- infra/website/src/components/Navigation.astro | 80 +++++++++++++++--- infra/website/src/layouts/BaseLayout.astro | 12 ++- infra/website/src/layouts/BlogLayout.astro | 15 +++- infra/website/src/pages/blog/[slug].astro | 20 ++--- infra/website/src/pages/blog/index.astro | 8 +- infra/website/src/styles/global.css | 81 ++++++++++++++----- 6 files changed, 165 insertions(+), 51 deletions(-) diff --git a/infra/website/src/components/Navigation.astro b/infra/website/src/components/Navigation.astro index a5987bf6348..143fcbc047f 100644 --- a/infra/website/src/components/Navigation.astro +++ b/infra/website/src/components/Navigation.astro @@ -14,11 +14,29 @@ COMMUNITY - +
@@ -38,7 +56,7 @@ top: 0; left: 0; right: 0; - background-color: white; + background-color: var(--color-nav-bg); z-index: 1000; } @@ -80,6 +98,35 @@ margin-left: 32px; } + .nav-right { + display: flex; + align-items: center; + gap: 4px; + padding-right: var(--content-padding); + } + + .theme-toggle { + background: none; + border: none; + padding: 8px; + cursor: pointer; + color: var(--color-text); + display: flex; + align-items: center; + justify-content: center; + opacity: 0.7; + transition: opacity 0.2s ease; + } + + .theme-toggle:hover { + opacity: 1; + } + + .icon-sun { display: none; } + .icon-moon { display: block; } + :global([data-theme="dark"]) .icon-sun { display: block; } + :global([data-theme="dark"]) .icon-moon { display: none; } + .mobile-menu-button { display: block; background: none; @@ -87,7 +134,6 @@ padding: 8px; cursor: pointer; color: var(--color-text); - margin-right: var(--content-padding); } @media (min-width: 1024px) { @@ -95,7 +141,7 @@ display: flex; align-items: center; } - + .mobile-menu-button { display: none; } @@ -104,9 +150,9 @@ .mobile-menu { display: none; width: 100%; - background: white; + background: var(--color-nav-bg); padding: 16px 0; - border-top: 1px solid #eee; + border-top: 1px solid var(--color-border); position: absolute; top: 52px; left: 0; @@ -122,17 +168,27 @@ } .mobile-menu a:hover { - background-color: #f5f5f5; + background-color: var(--color-nav-hover); } \ No newline at end of file diff --git a/infra/website/src/layouts/BaseLayout.astro b/infra/website/src/layouts/BaseLayout.astro index 05d940005ba..96e30a6aee2 100644 --- a/infra/website/src/layouts/BaseLayout.astro +++ b/infra/website/src/layouts/BaseLayout.astro @@ -52,7 +52,17 @@ const { - + +
diff --git a/infra/website/src/layouts/BlogLayout.astro b/infra/website/src/layouts/BlogLayout.astro index c5f8379fc80..9fe68a9daa7 100644 --- a/infra/website/src/layouts/BlogLayout.astro +++ b/infra/website/src/layouts/BlogLayout.astro @@ -14,7 +14,7 @@ const { frontmatter } = Astro.props;

{frontmatter.title}

{frontmatter.date && ( -