Repository navigation
feat(website): add light/dark mode with polished theme switching - #84
Conversation
- 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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
apps/website/src/components/Hero.astro (1)
502-509: Remove or relocate unused.steptheme 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
83pxspacer, 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
📒 Files selected for processing (9)
apps/website/src/components/Download.astroapps/website/src/components/Features.astroapps/website/src/components/Footer.astroapps/website/src/components/Hero.astroapps/website/src/components/HowItWorks.astroapps/website/src/components/Nav.astroapps/website/src/layouts/Layout.astroapps/website/src/pages/getting-started.astroapps/website/src/styles/global.css
| <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> |
There was a problem hiding this comment.
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".
| <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"); | ||
| })(); |
There was a problem hiding this comment.
🧩 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:
-
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.localStoragein a third‑party context can throwSecurityError. 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]
- In browsers with a storage access policy / tracking prevention, read/write attempts to
-
The iframe is sandboxed without
allow-same-origin- If the iframe uses
sandboxand doesn’t includeallow-same-origin, the frame gets an opaque origin and storage access can fail with messages like “document is sandboxed and lacks theallow-same-originflag” (commonly surfaced as aSecurityError). (This is a frequent real-world cause of “restricted environment” storage failures.) [4]
- If the iframe uses
-
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
postMessageand let each origin store its own data.
- You cannot access another origin’s
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:
- 1: https://developer.mozilla.org/en-US/docs/Web/Privacy/Storage_Access_Policy?utm_source=openai
- 2: https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API?utm_source=openai
- 3: https://developer.mozilla.org/en-US/docs/Web/API/Document/requestStorageAccessFor?utm_source=openai
- 4: https://www.reddit.com/r/PowerBI/comments/1i24nk7?utm_source=openai
- 5: https://stackoverflow.com/questions/30481516/iframe-in-chrome-error-failed-to-read-localstorage-from-window-access-deni?utm_source=openai
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.
| <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.
Summary by CodeRabbit