Skip to content

feat(website): add light/dark mode with polished theme switching - #84

Merged
fum4 merged 1 commit into
masterfrom
LOCAL-4/light_dark_mode_on_website
Mar 18, 2026
Merged

fum4 merged 1 commit into
masterfrom
LOCAL-4/light_dark_mode_on_website

Conversation

@fum4

@fum4 fum4 commented Mar 18, 2026 •

Copy link
Copy Markdown
Owner
  • pill-shaped toggle with filled sun/moon icons and subtle thumb indicator
  • solid accent-colored buttons in light mode with gentle darker hover states
  • terminal and CLI blocks stay dark in both modes for visual consistency
  • nav bar uses a slightly darker background to differentiate from page content
  • download card matches nav tone in light mode
  • highlighted text gets colored pill treatment in light mode
  • footer links centered with spacer to balance the logo
  • prevent horizontal overflow on mobile via html overflow-x hidden

Summary by CodeRabbit

  • New Features
    • Introduced light theme with comprehensive styling across all website components
    • Added theme toggle button in navigation for seamless switching between light and dark modes
    • Theme preference automatically persists across sessions
    • Visual consistency and proper contrast maintained throughout the light theme experience

- pill-shaped toggle with filled sun/moon icons and subtle thumb indicator
- solid accent-colored buttons in light mode with gentle darker hover states
- terminal and CLI blocks stay dark in both modes for visual consistency
- nav bar uses a slightly darker background to differentiate from page content
- download card matches nav tone in light mode
- highlighted text gets colored pill treatment in light mode
- footer links centered with spacer to balance the logo
- prevent horizontal overflow on mobile via html overflow-x hidden
@fum4 fum4 self-assigned this Mar 18, 2026
@vercel

vercel Bot commented Mar 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openkit Ready Ready Preview, Comment Mar 18, 2026 5:36pm

@coderabbitai

coderabbitai Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request introduces comprehensive light theme support to the website. It adds a theme toggle button in the navigation, implements theme persistence using localStorage, updates the meta theme color dynamically, and applies light-theme CSS overrides across all major components for visual consistency.

Changes

Cohort / File(s) Summary
Theme Toggle & Persistence
apps/website/src/components/Nav.astro, apps/website/src/layouts/Layout.astro
Introduces theme toggle UI in navigation with moon/sun icons; adds JavaScript for theme switching with localStorage persistence and meta theme color updates based on light/dark preference.
Global Styling Foundation
apps/website/src/styles/global.css
Establishes light theme variant with color tokens, adjusts overflow, animations, buttons, links, menus, and component-specific overrides for consistent light mode appearance.
Component Light Theme Overrides
apps/website/src/components/Download.astro, apps/website/src/components/Features.astro, apps/website/src/components/Hero.astro, apps/website/src/components/HowItWorks.astro, apps/website/src/pages/getting-started.astro
Adds light theme CSS selectors adjusting colors, backgrounds, borders, and contrast for terminals, badges, highlights, interactive elements, and code blocks.
Logo & Footer Restructuring
apps/website/src/components/Footer.astro, apps/website/src/components/Nav.astro
Changes SVG logo stroke from fixed hex color to currentColor for theme adaptation; restructures footer version into footer-right container with responsive styling and light theme adjustments.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Nav as Nav Toggle
    participant JS as Theme Logic
    participant DOM as Document
    participant Storage as localStorage
    participant CSS as Stylesheets

    User->>Nav: Click theme toggle button
    Nav->>JS: Trigger theme switch handler
    JS->>Storage: Read current theme preference
    JS->>DOM: Get documentElement
    JS->>DOM: Set data-theme attribute (light/dark)
    JS->>Storage: Persist theme choice
    JS->>DOM: Update meta theme-color content
    DOM->>CSS: Apply [data-theme="light"] selectors
    CSS->>User: Render light theme visuals
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A toggle was born in the nav so neat,
Light and dark themes now compete,
localStorage holds the choice we make,
From sun to moon, for goodness' sake! 🌙☀️

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main objective of the pull request: adding light/dark mode theme switching to the website.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch LOCAL-4/light_dark_mode_on_website
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Claude Review

🟠 Medium

  1. No system preference change listener (apps/website/src/layouts/Layout.astro:59-65, apps/website/src/components/Nav.astro:87-94): The inline script reads prefers-color-scheme on page load, but there's no matchMedia change listener. If a user hasn't explicitly chosen a theme and changes their OS preference while the page is open, the site won't react. Consider adding a change listener on the matchMedia object (only when no stored preference exists).

  2. Hardcoded color values throughout instead of CSS variables (multiple files): The light mode overrides are full of hardcoded hex values like #0d9488, #0b867b, #111827, #6b7280, #f0f2f5, #1a1d24, etc. Many of these repeat across Hero.astro, Features.astro, Nav.astro, getting-started.astro, and global.css. Since the PR already defines CSS variables in global.css (--accent: #0d9488, --text-muted: #6b7280, etc.), these component styles should reference the variables instead. This will make future theme tweaks a single-place change rather than a multi-file hunt.

  3. Magic number for footer-right width (apps/website/src/components/Footer.astro:111): width: 83px is a magic number with no explanation. If this exists to balance the layout against the left logo, add a comment explaining the intent, or use a more robust centering approach (e.g., flex with equal-width side containers).

  4. Non-null assertion on DOM element (apps/website/src/components/Nav.astro:87): document.getElementById("theme-toggle")! will throw at runtime if the element is missing. Use a null check instead:

    const toggle = document.getElementById("theme-toggle");
    if (toggle) { toggle.addEventListener("click", () => { ... }); }

🟡 Minor

  1. Duplicate step light-mode styles (apps/website/src/components/HowItWorks.astro:94-101 and apps/website/src/components/Hero.astro:503-510): The :global([data-theme="light"]) .step:hover and .step-num overrides are identical in both files. If these share the same class names, one will override the other depending on load order. Consider consolidating into global.css or verifying they're scoped to different elements.

  2. var in inline script (apps/website/src/layouts/Layout.astro:59-65): The inline IIFE uses var. Since this is an is:inline script (not processed by Astro's bundler), var works but const/let are also fine in all supported browsers and signal intent better.

  3. Terminal light-mode overrides could be a single scoped block (apps/website/src/components/Hero.astro:449-505): The ~20 individual :global([data-theme="light"]) .terminal-* rules could be grouped under a comment or, if Astro supports it, nested to improve readability. Not a functional issue, just maintenance ergonomics.

  4. overflow-x: hidden on html (apps/website/src/styles/global.css:66): This was added alongside the theme work but isn't obviously related to light/dark mode. If it fixes a horizontal scroll issue, it should be in a separate commit or at least noted. Also, overflow-x: hidden on html can interfere with position: sticky in some browsers.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
apps/website/src/components/Hero.astro (1)

502-509: Remove or relocate unused .step theme overrides.

Line [502]-Line [509] target .step/.step-num, but this component does not render those classes. Keeping them here adds noise and makes ownership unclear.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/website/src/components/Hero.astro` around lines 502 - 509, Remove the
unused theme overrides for the .step and .step-num selectors from Hero.astro;
these rules are not used by this component and add noise. Either delete the
block referencing :global([data-theme="light"]) .step and .step-num from
Hero.astro, or relocate those declarations into the stylesheet or component that
actually renders .step/.step-num (e.g., the Steps/StepList component or a shared
global styles file) to keep ownership clear.
apps/website/src/styles/global.css (1)

292-295: Prefer theme tokens over hard-coded hover shades.

Line [293] and Line [294] hard-code #0b867b, which can drift from the rest of the accent system. Consider introducing a dedicated token (e.g., --accent-hover) in theme blocks and using it here.

♻️ Proposed refactor
 :root {
+  --accent-hover: `#5eead4`;
 }

 [data-theme="light"] {
+  --accent-hover: `#0b867b`;
 }

 [data-theme="light"] .download-split:hover {
-  border-color: `#0b867b`;
-  background: `#0b867b`;
+  border-color: var(--accent-hover);
+  background: var(--accent-hover);
   transform: translateY(-1px);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/website/src/styles/global.css` around lines 292 - 295, Replace the
hard-coded hover color in the [data-theme="light"] .download-split:hover rule by
consuming a theme CSS variable (e.g., --accent-hover) instead of `#0b867b`: add
the --accent-hover token to the theme blocks where other accent tokens live (for
light theme) and then use var(--accent-hover) for both border-color and
background in the .download-split:hover selector so hover styling follows the
shared accent token.
apps/website/src/components/Footer.astro (1)

111-116: Consider replacing the fixed spacer width with layout-based centering.

Line [112] uses a hard-coded 83px spacer, which may become misaligned as brand/version content changes. A grid-based center column is more robust.

💡 Optional layout refactor
 .footer-inner {
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
+  display: grid;
+  grid-template-columns: 1fr auto 1fr;
+  align-items: center;
 }

+.footer-brand { justify-self: start; }
+.footer-links { justify-self: center; }
 .footer-right {
-  width: 83px;
+  width: auto;
   flex-shrink: 0;
   display: flex;
-  justify-content: flex-end;
+  justify-content: flex-end;
+  justify-self: end;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/website/src/components/Footer.astro` around lines 111 - 116, The fixed
83px spacer in .footer-right can cause misalignment as content changes; replace
the hard-coded width with a layout-based centering approach: remove width: 83px
from .footer-right and switch the parent footer layout to a three-column CSS
Grid (e.g., grid-template-columns: 1fr auto 1fr) or make
.footer-left/.footer-right flexible so the center column naturally centers the
brand/version; update related selectors (.footer, .footer-right, .footer-center)
accordingly so the center content is always centered without relying on a fixed
spacer.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/website/src/components/Nav.astro`:
- Around line 45-68: The theme toggle button (id="theme-toggle",
class="theme-toggle") needs an accessible pressed state: add
aria-pressed="false" (or true) initial attribute and update it whenever the
theme changes; in the JS that handles the toggle (the click handler that
currently toggles theme and any init routine that reads saved theme) set
themeToggleElement.setAttribute('aria-pressed', isDark.toString()) and also
update the aria-label if you prefer dynamic labels; ensure the page-load
initialization code reads the current theme and synchronizes aria-pressed on the
element with id "theme-toggle".

In `@apps/website/src/layouts/Layout.astro`:
- Around line 57-65: Wrap the localStorage access in a try/catch inside the IIFE
to guard against SecurityError or other exceptions when calling
localStorage.getItem("theme"); if an error occurs or the retrieved value is not
"light" or "dark", ignore it and fall back to prefersDark for theme selection;
then continue to call document.documentElement.setAttribute("data-theme", theme)
and update the meta element (document.getElementById("meta-theme-color")) as
before. Ensure the variables stored, prefersDark, and theme remain in scope and
that any caught error is swallowed (no throw) so theme initialization always
runs.

---

Nitpick comments:
In `@apps/website/src/components/Footer.astro`:
- Around line 111-116: The fixed 83px spacer in .footer-right can cause
misalignment as content changes; replace the hard-coded width with a
layout-based centering approach: remove width: 83px from .footer-right and
switch the parent footer layout to a three-column CSS Grid (e.g.,
grid-template-columns: 1fr auto 1fr) or make .footer-left/.footer-right flexible
so the center column naturally centers the brand/version; update related
selectors (.footer, .footer-right, .footer-center) accordingly so the center
content is always centered without relying on a fixed spacer.

In `@apps/website/src/components/Hero.astro`:
- Around line 502-509: Remove the unused theme overrides for the .step and
.step-num selectors from Hero.astro; these rules are not used by this component
and add noise. Either delete the block referencing :global([data-theme="light"])
.step and .step-num from Hero.astro, or relocate those declarations into the
stylesheet or component that actually renders .step/.step-num (e.g., the
Steps/StepList component or a shared global styles file) to keep ownership
clear.

In `@apps/website/src/styles/global.css`:
- Around line 292-295: Replace the hard-coded hover color in the
[data-theme="light"] .download-split:hover rule by consuming a theme CSS
variable (e.g., --accent-hover) instead of `#0b867b`: add the --accent-hover token
to the theme blocks where other accent tokens live (for light theme) and then
use var(--accent-hover) for both border-color and background in the
.download-split:hover selector so hover styling follows the shared accent token.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a466a2f-0114-48b2-8ea7-a87761a57d75

📥 Commits

Reviewing files that changed from the base of the PR and between e39dad3 and 8f43b04.

📒 Files selected for processing (9)
  • apps/website/src/components/Download.astro
  • apps/website/src/components/Features.astro
  • apps/website/src/components/Footer.astro
  • apps/website/src/components/Hero.astro
  • apps/website/src/components/HowItWorks.astro
  • apps/website/src/components/Nav.astro
  • apps/website/src/layouts/Layout.astro
  • apps/website/src/pages/getting-started.astro
  • apps/website/src/styles/global.css

Comment on lines +45 to +68
<button
type="button"
class="theme-toggle"
id="theme-toggle"
aria-label="Toggle light/dark mode"
>
<span class="toggle-track">
<span class="toggle-thumb"></span>
<svg class="toggle-icon icon-moon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="none">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
<svg class="toggle-icon icon-sun" width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="none">
<circle cx="12" cy="12" r="6.5"></circle>
<rect x="10.75" y="0.5" width="2.5" height="3.5" rx="1.25"></rect>
<rect x="10.75" y="20" width="2.5" height="3.5" rx="1.25"></rect>
<rect x="3" y="4" width="2.5" height="3.5" rx="1.25" transform="rotate(-45 4.25 5.75)"></rect>
<rect x="17.25" y="18.25" width="2.5" height="3.5" rx="1.25" transform="rotate(-45 18.5 20)"></rect>
<rect x="0.5" y="10.75" width="3.5" height="2.5" rx="1.25"></rect>
<rect x="20" y="10.75" width="3.5" height="2.5" rx="1.25"></rect>
<rect x="4" y="17.25" width="3.5" height="2.5" rx="1.25" transform="rotate(-45 5.75 18.5)"></rect>
<rect x="18.25" y="4" width="3.5" height="2.5" rx="1.25" transform="rotate(-45 20 5.75)"></rect>
</svg>
</span>
</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add state indication for screen readers.

The toggle button has an aria-label but doesn't communicate the current theme state to assistive technologies. Consider adding aria-pressed to indicate the toggle state.

♿ Proposed fix to add aria-pressed

Update the HTML:

      <button
        type="button"
        class="theme-toggle"
        id="theme-toggle"
        aria-label="Toggle light/dark mode"
+       aria-pressed="false"
      >

Update the JavaScript to sync the state:

  toggle.addEventListener("click", () => {
    const current = document.documentElement.getAttribute("data-theme");
    const next = current === "light" ? "dark" : "light";
    document.documentElement.setAttribute("data-theme", next);
    localStorage.setItem("theme", next);
+   toggle.setAttribute("aria-pressed", next === "light" ? "true" : "false");
    const meta = document.getElementById("meta-theme-color");
    if (meta) meta.setAttribute("content", next === "light" ? "#f7f8fa" : "#0e1014");
  });

Also initialize aria-pressed on page load based on the current theme.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/website/src/components/Nav.astro` around lines 45 - 68, The theme toggle
button (id="theme-toggle", class="theme-toggle") needs an accessible pressed
state: add aria-pressed="false" (or true) initial attribute and update it
whenever the theme changes; in the JS that handles the toggle (the click handler
that currently toggles theme and any init routine that reads saved theme) set
themeToggleElement.setAttribute('aria-pressed', isDark.toString()) and also
update the aria-label if you prefer dynamic labels; ensure the page-load
initialization code reads the current theme and synchronizes aria-pressed on the
element with id "theme-toggle".

Comment on lines +57 to +65
<script is:inline>
(function () {
var stored = localStorage.getItem("theme");
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
var theme = stored || (prefersDark ? "dark" : "light");
document.documentElement.setAttribute("data-theme", theme);
var meta = document.getElementById("meta-theme-color");
if (meta) meta.setAttribute("content", theme === "light" ? "#f7f8fa" : "#0e1014");
})();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "Layout.astro" | grep -E "apps/website"

Repository: fum4/openkit

Length of output: 95


🏁 Script executed:

cat -n apps/website/src/layouts/Layout.astro | sed -n '50,70p'

Repository: fum4/openkit

Length of output: 934


🌐 Web query:

localStorage.getItem throw exception restricted environment iframe cross-origin

💡 Result:

localStorage.getItem() normally returns a string or null, but it can throw a DOMException (often SecurityError) when the browser decides the current document is not allowed to use Web Storage.

Common causes in “restricted iframe / cross-origin” scenarios:

  1. Third‑party (cross‑site) iframe storage is blocked by privacy features

    • In browsers with a storage access policy / tracking prevention, read/write attempts to window.localStorage in a third‑party context can throw SecurityError. This is explicitly documented (not just cookies—Web Storage too). [1]
    • Fix/mitigation: in affected browsers, use the Storage Access API and request access from inside the iframe (typically requires a user gesture and correct embedding conditions). [2][3]
  2. The iframe is sandboxed without allow-same-origin

    • If the iframe uses sandbox and doesn’t include allow-same-origin, the frame gets an opaque origin and storage access can fail with messages like “document is sandboxed and lacks the allow-same-origin flag” (commonly surfaced as a SecurityError). (This is a frequent real-world cause of “restricted environment” storage failures.) [4]
  3. You’re trying to access storage across origins

    • You cannot access another origin’s localStorage (e.g., parent trying to read the iframe’s storage or vice‑versa). Attempts commonly surface as “Failed to read the ‘localStorage’ property…” / access denied. [5]
    • Fix/mitigation: communicate via postMessage and let each origin store its own data.

Practical defensive pattern:

function safeGet(key) {
  try {
    return window.localStorage?.getItem(key) ?? null;
  } catch (e) {
    // SecurityError / "operation is insecure" / blocked third-party storage / sandboxed frame
    return null;
  }
}

If you share:

  • the exact exception name/message, and
  • whether this runs in a third‑party iframe, and whether the iframe has a sandbox attribute,
    I can point to the most likely cause and the best fix for that browser/embedding setup.

Sources: MDN Storage access policy (Web Storage throws SecurityError in blocked third‑party contexts) [1]; MDN Storage Access API overview [2] and related API details [3]; examples of sandboxed-iframe storage failure [4]; cross-origin iframe access denial discussion [5].

[1] (developer.mozilla.org)
[2] (developer.mozilla.org)
[3] (developer.mozilla.org)
[4] (reddit.com)
[5] (stackoverflow.com)

Citations:


Guard theme initialization against storage access failures.

At line 59, localStorage.getItem("theme") is unguarded. In restricted storage contexts (sandboxed iframes, cross-origin privacy policies, third-party storage blocks), this call can throw SecurityError and prevent theme initialization. Add try/catch and validate the stored value:

Suggested fix
 <script is:inline>
   (function () {
-    var stored = localStorage.getItem("theme");
-    var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
-    var theme = stored || (prefersDark ? "dark" : "light");
+    var stored = null;
+    try {
+      stored = localStorage.getItem("theme");
+    } catch (_) {}
+    var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
+    var theme =
+      stored === "light" || stored === "dark"
+        ? stored
+        : (prefersDark ? "dark" : "light");
     document.documentElement.setAttribute("data-theme", theme);
     var meta = document.getElementById("meta-theme-color");
     if (meta) meta.setAttribute("content", theme === "light" ? "#f7f8fa" : "#0e1014");
   })();
 </script>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<script is:inline>
(function () {
var stored = localStorage.getItem("theme");
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
var theme = stored || (prefersDark ? "dark" : "light");
document.documentElement.setAttribute("data-theme", theme);
var meta = document.getElementById("meta-theme-color");
if (meta) meta.setAttribute("content", theme === "light" ? "#f7f8fa" : "#0e1014");
})();
<script is:inline>
(function () {
var stored = null;
try {
stored = localStorage.getItem("theme");
} catch (_) {}
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
var theme =
stored === "light" || stored === "dark"
? stored
: (prefersDark ? "dark" : "light");
document.documentElement.setAttribute("data-theme", theme);
var meta = document.getElementById("meta-theme-color");
if (meta) meta.setAttribute("content", theme === "light" ? "#f7f8fa" : "#0e1014");
})();
</script>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/website/src/layouts/Layout.astro` around lines 57 - 65, Wrap the
localStorage access in a try/catch inside the IIFE to guard against
SecurityError or other exceptions when calling localStorage.getItem("theme"); if
an error occurs or the retrieved value is not "light" or "dark", ignore it and
fall back to prefersDark for theme selection; then continue to call
document.documentElement.setAttribute("data-theme", theme) and update the meta
element (document.getElementById("meta-theme-color")) as before. Ensure the
variables stored, prefersDark, and theme remain in scope and that any caught
error is swallowed (no throw) so theme initialization always runs.

@fum4
fum4 merged commit 609a634 into master Mar 18, 2026
18 checks passed
@fum4
fum4 deleted the LOCAL-4/light_dark_mode_on_website branch March 18, 2026 23:36

This branch was successfully deployed

1 active deployment
Preview — 8f43b04c Deployed Mar 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant