Skip to content

feat(theme): Implementing theme switch functionality#121

Merged
Ryan-Millard merged 16 commits into
Ryan-Millard:mainfrom
manu-059:theme-switch
Dec 28, 2025
Merged

feat(theme): Implementing theme switch functionality#121
Ryan-Millard merged 16 commits into
Ryan-Millard:mainfrom
manu-059:theme-switch

Conversation

@manu-059
Copy link
Copy Markdown
Contributor

@manu-059 manu-059 commented Dec 15, 2025

✨ Feature Pull Request

Adds light and dark theme support with a theme switcher

📌 Description

  • What:
    Implemented a theme switch functionality that allows users to toggle between Light and Dark modes across the application. The selected theme is applied consistently to UI components, colors, and background assets.

  • Why:
    To improve user experience and accessibility by providing better visual comfort in different lighting conditions. Dark mode also aligns with modern UI standards and user expectations.

🔗 Issue

📦 Type of Change

  • New feature
  • Enhancement

🧪 How Has This Been Tested?

  • Manually tested theme switching across all major pages
  • Verified UI consistency in both Light and Dark modes
  • Confirmed theme toggling works without page refresh
  • Checked responsiveness on desktop and smaller screen sizes

✔️ Checklist

  • I’ve read the contribution guidelines.
  • My code follows the project style (lint/format passes).
  • I’ve added or updated tests.
  • I’ve updated documentation if needed.
  • No breaking changes introduced.

💬 Additional Context

  • Implemented a custom useTheme hook that exposes the current theme value and a toggleTheme function.
  • User theme preference is persisted using localStorage.
  • Automatically detects and applies the user’s default browser/system theme on initial load.
  • Designed to be easily extendable for additional themes in the future.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added light and dark theme switching with a new toggle button in the navigation bar
    • Theme preference automatically persists across browser sessions
  • Documentation

    • Added comprehensive theming documentation with CSS variable reference
    • Added component and hook documentation pages
  • Tests

    • Added test coverage for theme switching and theme management

✏️ Tip: You can customize this high-level summary in your review settings.

@manu-059 manu-059 changed the title Implementing theme switch functionality feat(theme): Implementing theme switch functionality #101 Dec 15, 2025
@manu-059 manu-059 changed the title feat(theme): Implementing theme switch functionality #101 feat(theme): Implementing theme switch functionality Dec 15, 2025
Copy link
Copy Markdown
Owner

@Ryan-Millard Ryan-Millard left a comment

Choose a reason for hiding this comment

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

I'm reviewing this now.

Copy link
Copy Markdown
Owner

@Ryan-Millard Ryan-Millard left a comment

Choose a reason for hiding this comment

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

This is a really good feature. Thank you. I think it is cool.

Please add some:

  • Documentation
  • Tests

Comment thread src/assets/hedgehog-bg-dark.svg Outdated
Comment thread src/components/GlassCard.module.css
Comment thread src/components/ThemeSwitch.jsx
Comment thread src/global-styles/base.css Outdated
@Ryan-Millard
Copy link
Copy Markdown
Owner

@CodeRabbit full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 17, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 17, 2025

Warning

Rate limit exceeded

@Ryan-Millard has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d4ba5ab and cc41bc9.

📒 Files selected for processing (1)
  • docs/docs/reference/react/components/ThemeSwitch/tests.md
📝 Walkthrough

Walkthrough

This PR introduces a complete theme switching system featuring a new useTheme hook for managing light/dark theme state with localStorage persistence and system preference detection, a ThemeSwitch React component for toggling themes, comprehensive CSS variables for both light and dark color schemes, and extensive documentation with tests for all new functionality.

Changes

Cohort / File(s) Summary
Theme Management
src/hooks/useTheme.js, src/hooks/useTheme.test.jsx
New custom hook managing theme state with localStorage persistence and system preference detection via matchMedia. Returns { theme, toggleTheme }. Includes comprehensive test coverage for initialization, persistence, DOM updates, and edge cases.
Theme Toggle Component
src/components/ThemeSwitch.jsx, src/components/ThemeSwitch.module.css, src/components/ThemeSwitch.test.jsx
New React component providing theme toggle button with icon rendering (Sun/Moon), ARIA labels, and Tooltip integration. Applies glass styling and custom CSS. Includes full test suite covering rendering, icon display, theme toggling, and accessibility.
NavBar Integration
src/components/NavBar.jsx, src/components/NavBar.module.css
Integrated ThemeSwitch component alongside spacer div. Added .spacer class with flex-grow: 1, adjusted justify-content removal from .navbar, and padding-left to .navLinks.
CSS Variables & Theming
src/global-styles/variables.css, src/global-styles/base.css, src/global-styles/components.css, src/components/GlassCard.module.css
Introduced comprehensive CSS variable system with light/dark theme blocks containing color, spacing, radius, and glass effect tokens. Replaced hardcoded color values throughout component styles with corresponding CSS variables.
Component Documentation
docs/docs/reference/react/components/ThemeSwitch/*, docs/docs/reference/react/components/NavBar/*
Added markdown documentation and metadata for ThemeSwitch component (usage, implementation, testing) and NavBar component with category metadata.
Hook Documentation
docs/docs/reference/react/hooks/useTheme/*
Comprehensive documentation for useTheme hook covering initialization, persistence behavior, return values, usage patterns, and test guidance with category metadata.
CSS Variables Reference
docs/docs/reference/react/css/global/*
Multi-level documentation structure for global CSS variables including theme-independent tokens (typography, spacing, radius), light/dark theme specifications with color swatches, extending/usage patterns, theme switching flow, and best practices.
Utilities & Exports
docs/src/components/ColorSwatch.jsx
New documentation component rendering color swatches for theme variable visualization.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ThemeSwitch
    participant useTheme Hook
    participant DOM
    participant CSS Vars
    participant Components

    User->>ThemeSwitch: Click toggle button
    ThemeSwitch->>useTheme Hook: Call toggleTheme()
    activate useTheme Hook
    useTheme Hook->>useTheme Hook: Update theme state
    useTheme Hook->>DOM: Apply 'light'/'dark' class to root element
    useTheme Hook->>DOM: Persist theme to localStorage
    deactivate useTheme Hook
    DOM->>CSS Vars: CSS variable scope changes based on root class
    Note over CSS Vars: :root.light or :root.dark active
    CSS Vars->>Components: --color-primary, --glass-bg, etc. now resolve<br/>to new theme values
    Components->>Components: Re-render with updated CSS variable values
    Components->>User: Updated appearance (new colors/contrast)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐰 A toggle so bright, a rabbit delight!
Light and dark themes dancing in flight,
Variables twirl through CSS so neat,
Theme switching magic, forever so sweet! 🌙☀️

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(theme): Implementing theme switch functionality' accurately summarizes the main change: adding theme switching capability with light and dark modes, which aligns with the primary objective of issue #101.
Linked Issues check ✅ Passed All primary coding objectives from issue #101 are met: toggle button added to NavBar, dark/light theme styles defined using CSS variables, user preference persisted in localStorage, system preference auto-detected via useTheme hook, and styles applied across components.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing theme switching. CSS refactoring to use variables, NavBar integration, documentation, tests, and component additions all support the core theme feature without introducing unrelated modifications.

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
src/components/GlassCard.module.css (1)

53-64: Dark mode styles work but could use global variables.

This has been flagged in a previous review: consider defining these as global CSS variables in src/global-styles/components.css rather than using :global(:root.dark) overrides in the module. This would improve maintainability and align with the global .glass class mentioned by the reviewer.

src/global-styles/base.css (1)

7-30: Remove duplicate transitions from html and body.

As previously noted by Ryan-Millard, applying the same transition properties to both html and body is redundant and can negatively impact rendering performance. Choose one element (preferably body since it already has other styling) and remove the transitions from the other.

Apply this diff to remove the redundant transitions from html:

-/* Smooth theme transitions */
-html {
-  transition:
-    background-color 0.3s ease,
-    color 0.3s ease;
-}
-
 body {
   margin: 0;
   padding: var(--spacing-lg);
🧹 Nitpick comments (5)
src/global-styles/variables.css (1)

23-24: Consider differentiating --color-text-light from --color-text.

Both variables are set to #2c1a1a in the light theme, making --color-text-light redundant. If this is intentional (both should be dark for accessibility), consider adding a comment explaining why. Otherwise, --color-text-light should be a lighter shade for secondary text elements.

   --color-text: #2c1a1a; /* very dark brown for all text */
-  --color-text-light: #2c1a1a; /* also dark, for any "light" text elements */
+  --color-text-light: #5a4a4a; /* lighter brown for secondary text elements */
src/components/NavBar.jsx (1)

42-43: Theme switch integration looks good.

The ThemeSwitch is correctly positioned and remains visible on both desktop and mobile views, which is good for UX. Minor nit: the empty spacer div could use a self-closing tag.

-      <div className={styles.spacer}></div>
+      <div className={styles.spacer} />
src/hooks/useTheme.js (1)

4-12: Consider validating theme values from localStorage.

The hook accepts any value from localStorage.getItem('theme') without validation. If the stored value is corrupted or manually edited to an invalid theme (e.g., 'blue', 'invalid'), it will be applied as-is, potentially breaking the theming system.

Consider adding validation:

 const [theme, setTheme] = useState(() => {
+  // Guard for SSR
+  if (typeof window === 'undefined') {
+    return 'light';
+  }
+
   // Check localStorage first
   const savedTheme = localStorage.getItem('theme');
-  if (savedTheme) {
+  if (savedTheme === 'light' || savedTheme === 'dark') {
     return savedTheme;
   }
   // Fall back to system preference
   return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
 });
src/components/ThemeSwitch.module.css (2)

1-20: Consider accessibility: button contrast on varied backgrounds.

The button uses a transparent background with backdrop-filter: blur(8px) and only box shadows for definition. While this creates a modern aesthetic, ensure that the button meets WCAG contrast requirements across different background contexts, especially given the dynamic hedgehog background pattern.

Test the button visibility and contrast:

  • Against the light mode hedgehog background
  • Against the dark mode hedgehog background
  • In areas where the background pattern creates high or low contrast conditions

22-27: Use CSS variable instead of hardcoded color for consistency.

The icon color is hardcoded as #27272a, which requires a separate override for dark mode (line 30-31). For consistency with the theming system and to reduce the need for overrides, use a CSS variable that adapts automatically based on the active theme.

Apply this diff:

 .icon {
   height: 1.25rem;
   width: 1.25rem;
-  color: #27272a;
+  color: var(--color-text);
   transition: color 0.2s ease-in-out;
 }
-
-/* Dark mode styles */
-:global(:root.dark) .icon {
-  color: var(--color-text);
-}

If --color-text doesn't provide the desired contrast in light mode, define a more specific variable like --color-icon in your variables file.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5106cb and 18cfd5b.

⛔ Files ignored due to path filters (1)
  • src/assets/hedgehog-bg-dark.svg is excluded by !**/*.svg
📒 Files selected for processing (8)
  • src/components/GlassCard.module.css (1 hunks)
  • src/components/NavBar.jsx (2 hunks)
  • src/components/NavBar.module.css (2 hunks)
  • src/components/ThemeSwitch.jsx (1 hunks)
  • src/components/ThemeSwitch.module.css (1 hunks)
  • src/global-styles/base.css (2 hunks)
  • src/global-styles/variables.css (1 hunks)
  • src/hooks/useTheme.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/hooks/useTheme.js (1)
src/components/ThemeSwitch.jsx (1)
  • useTheme (16-16)
src/components/ThemeSwitch.jsx (1)
src/hooks/useTheme.js (3)
  • useTheme (3-32)
  • toggleTheme (27-29)
  • theme (4-12)
src/components/NavBar.jsx (1)
src/components/ThemeSwitch.jsx (1)
  • ThemeSwitch (14-24)
🔇 Additional comments (8)
src/global-styles/variables.css (2)

1-12: Well-structured design tokens.

Good separation of global tokens (font, spacing, radius) from theme-specific color variables. This makes the system extensible for additional themes.


32-47: Dark theme variables look good.

The dark theme provides appropriate contrast with lighter text on dark backgrounds. The --color-text-light is correctly differentiated here (#d0d0d0 vs #f0f0f0), which is the expected pattern.

src/components/NavBar.module.css (2)

5-7: Good use of flexbox spacer pattern.

The .spacer class effectively pushes the ThemeSwitch and hamburger to the right while keeping the logo on the left.


25-25: Minor padding addition looks appropriate.

The left padding provides visual separation between the navigation links and adjacent elements.

src/components/NavBar.jsx (1)

6-6: Import added correctly.

The ThemeSwitch import follows the existing pattern using path aliases.

src/components/ThemeSwitch.jsx (1)

1-24: Clean implementation with good accessibility.

The component is well-structured with:

  • Proper aria-label for screen readers
  • type="button" to prevent unintended form submissions
  • Clear JSDoc documentation
  • Intuitive icon swap (Sun shown in dark mode to indicate "switch to light")

The past review comment about replacing this with a reusable GlassSwitch component (issue #123) is noted and should be addressed when that component is available.

src/global-styles/base.css (1)

32-35: LGTM!

The dark theme background implementation correctly uses the :root.dark selector to switch the background image when dark mode is active, which aligns with the theme class toggling in the useTheme hook.

src/hooks/useTheme.js (1)

27-31: LGTM!

The toggleTheme function correctly uses functional setState to toggle between themes, and the return value provides a clean API for consumers.

Comment thread src/hooks/useTheme.js
Comment thread src/hooks/useTheme.js
@Ryan-Millard
Copy link
Copy Markdown
Owner

@manu-059, are you still working on this pull request? Please let me know. I don't want this feature to stagnate for too long - a simple comment to say yes or no is all I need.🦔🦔

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/hooks/useTheme.js (1)

19-42: SSR guards and toggle logic look good.

The effect properly guards against SSR environments, and the toggle logic is clean. The use of functional state update in toggleTheme ensures stability.

🧹 Nitpick comments (5)
src/hooks/useTheme.js (1)

10-14: Consider adding try/catch around localStorage access.

In some browsers (private/incognito mode, storage quota exceeded), localStorage.getItem can throw. While rare, wrapping this in a try/catch would make the hook more robust.

🔎 Proposed fix
     // Check localStorage first
-    const savedTheme = localStorage.getItem('theme');
-    if (savedTheme) {
-      return savedTheme;
+    try {
+      const savedTheme = localStorage.getItem('theme');
+      if (savedTheme === 'light' || savedTheme === 'dark') {
+        return savedTheme;
+      }
+    } catch {
+      // localStorage unavailable, fall through to system preference
     }
src/components/ThemeSwitch.module.css (1)

1-27: Clean theme button styling with good theming integration.

The button styling is well-structured with proper accessibility (cursor: pointer), good visual feedback on hover, and uses CSS variables for icon color to support theme switching.

Minor nits for consideration:

  • Line 8: transition: all can be less performant than specifying exact properties (e.g., transition: transform 0.2s ease-in-out)
  • Line 15: margin: 0pxmargin: 0 (unit unnecessary for zero values)
src/global-styles/variables.css (3)

45-46: Naming inconsistency: --color-primary-dark is brighter in dark theme.

In the dark theme, --color-primary-dark (#ff4081) is actually a more vibrant/brighter shade than --color-primary (#ff6b9d), which contradicts the "dark" suffix. In the light theme, the naming is correct (darker shade for hover). Consider renaming to --color-primary-hover or similar to avoid confusion across themes.


57-64: Consider consolidating duplicate glass variables to :root.

Several glass effect variables are identical between light and dark themes:

  • --glass-bg, --glass-border, --glass-shadow, --glass-table-stacked

These could be moved to the base :root block (lines 1-12) to reduce duplication, keeping only the differing variables in the theme-specific blocks.

🔎 Proposed refactor
 :root {
   --font-sans: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

   --spacing-xs: 4px;
   --spacing-sm: 8px;
   --spacing-md: 16px;
   --spacing-lg: 24px;
   --spacing-xl: 32px;

   --radius-sm: 4px;
   --radius-md: 8px;
+
+  /* Shared glass effect variables */
+  --glass-bg: rgba(255, 255, 255, 0.1);
+  --glass-border: rgba(255, 255, 255, 0.2);
+  --glass-shadow: rgba(0, 0, 0, 0.1);
+  --glass-table-stacked: rgba(255, 255, 255, 0.7);
 }

Then remove the duplicated declarations from both the light and dark theme blocks.


43-43: Consider using near-black instead of pure black for reduced eye strain.

Pure black (#000000) can create harsh contrast on OLED screens and may cause eye fatigue. A near-black like #0d0d0d or #121212 (Material Design dark theme recommendation) is often preferred.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18cfd5b and c7f596c.

⛔ Files ignored due to path filters (1)
  • src/assets/hedgehog-bg.svg is excluded by !**/*.svg
📒 Files selected for processing (7)
  • src/components/GlassCard.module.css
  • src/components/ThemeSwitch.module.css
  • src/data/contributor-credits.json
  • src/global-styles/base.css
  • src/global-styles/components.css
  • src/global-styles/variables.css
  • src/hooks/useTheme.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/global-styles/base.css
🧰 Additional context used
🧬 Code graph analysis (1)
src/hooks/useTheme.js (1)
src/components/ThemeSwitch.jsx (1)
  • useTheme (16-16)
🔇 Additional comments (5)
src/data/contributor-credits.json (1)

1-44: LGTM!

The contributor credits update is valid JSON and correctly adds new contributors while updating existing contribution counts.

src/global-styles/components.css (1)

39-57: Good refactor to CSS variables for themeable glass effects.

Replacing hardcoded rgba() values with CSS variables (--glass-bg, --glass-border, --glass-shadow, --glass-table-stacked) enables the glass styling to adapt consistently across light and dark themes. All variables are properly defined in both theme modes in variables.css.

src/components/GlassCard.module.css (1)

18-18: Good adoption of global CSS variables for theming.

The switch from hardcoded rgba values to CSS variables (--glass-table-border, --glass-table-row-odd, --glass-table-row-hover) enables consistent light/dark theming. These variables are properly defined in src/global-styles/variables.css with distinct values for both light and dark themes, supporting dynamic theme switching.

src/global-styles/variables.css (2)

2-11: LGTM! Well-structured global design tokens.

The addition of shared typography, spacing, and radius tokens at the root level is a good practice for maintainability and consistency across the application.


14-39: Light theme implementation looks solid.

The selector pattern :root, :root.light correctly establishes light as the default theme. The color palette and glass effect variables are well-organized.

@manu-059
Copy link
Copy Markdown
Contributor Author

@Ryan-Millard Have made the requested changes, Let me know if anything i have missed , will be happy to take them.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/components/NavBar.jsx (1)

6-6: Theme switch integration looks good.

The ThemeSwitch component is properly imported and positioned in the navigation bar. The placement (between the logo and hamburger menu) ensures it remains accessible across viewport sizes.

Optional: Consider CSS-based spacing instead of an empty div.

Line 57 uses an empty <div> with flex-grow: 1 for layout spacing. While functional, modern CSS offers more semantic alternatives:

  • Apply margin-inline-start: auto directly to the ThemeSwitch component
  • Use justify-content: space-between on the navbar container (if layout permits)
  • Leverage flexbox gap property for consistent spacing
🔎 Alternative approach without empty div

In NavBar.module.css, you could add a utility class for the ThemeSwitch wrapper or apply the margin directly:

-      <div className={styles.spacer}></div>
-      <ThemeSwitch />
+      <ThemeSwitch className={styles.themeSwitchPush} />

Then in the CSS:

.themeSwitchPush {
  margin-inline-start: auto;
}

Or if the layout allows, restore justify-content: space-between on .navbar and remove the spacer entirely.

Also applies to: 57-58

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7f596c and 746e952.

📒 Files selected for processing (1)
  • src/components/NavBar.jsx
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/NavBar.jsx (1)
src/components/ThemeSwitch.jsx (1)
  • ThemeSwitch (14-24)

Copy link
Copy Markdown
Owner

@Ryan-Millard Ryan-Millard left a comment

Choose a reason for hiding this comment

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

This is REALLY, REALLY GOOD!

I just have three quick requests:

  1. Please add some tests for the new components added in this pull request.
  2. Please write some Docusaurus documentation (goes in docs/docs/reference) for the changes you made such as the useTheme hook and ThemeSwitch component - please also document the usage of the CSS variables involved in this PR.
  3. Please improve the accessibility of the site by updating the CSS variables to work better together - and make logical contrast between the different themes. Joan (the hedgehog) is a girl, so it would make sense to use something like purple for the dark mode background (many users find #000000 too aggressively dark). In the image below, some of the text is difficult to read, and my suggested changes on the variables.css file should fix most of that.
Image

Thank you! This is almost ready to merge.🦔

Comment thread src/global-styles/variables.css
@Ryan-Millard
Copy link
Copy Markdown
Owner

Hey @manu-059. Are you still working on this PR?

I'd like to know whether I should keep this pull request open or help things move along. I really like what this PR is adding.
Please let me know if you're struggling with anything or would prefer it if someone else took over from you on this PR.🦔

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 (2)
docs/docs/reference/styling/theme-variables.md (1)

213-215: Add language identifier to code block.

The code block at line 213 is missing a language identifier. Adding one improves syntax highlighting and documentation clarity.

🔎 Proposed fix
-```
+```plaintext
 /src/global-styles/variables.css
</details>

</blockquote></details>
<details>
<summary>docs/docs/reference/react/components/ThemeSwitch/tests.md (1)</summary><blockquote>

`9-11`: **Add language identifier to code block.**

The code block at line 9 is missing a language identifier. Consider adding `plaintext` or `text` for consistency with documentation standards.



<details>
<summary>🔎 Proposed fix</summary>

```diff
-```
+```plaintext
 src/test/ThemeSwitch.test.jsx
</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 746e9524fcafa0620e518bedc33cd8efd59c13cd and 6bf173c6fc2cb570a3b2ba27e42d9cfcbb7b347c.

</details>

<details>
<summary>📒 Files selected for processing (9)</summary>

* `docs/docs/reference/react/components/ThemeSwitch/_category_.json`
* `docs/docs/reference/react/components/ThemeSwitch/index.md`
* `docs/docs/reference/react/components/ThemeSwitch/tests.md`
* `docs/docs/reference/react/hooks/_category_.json`
* `docs/docs/reference/react/hooks/useTheme.md`
* `docs/docs/reference/styling/_category_.json`
* `docs/docs/reference/styling/theme-variables.md`
* `src/global-styles/variables.css`
* `src/test/ThemeSwitch.test.jsx`

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (2)</summary>

* docs/docs/reference/react/hooks/_category_.json
* docs/docs/reference/styling/_category_.json

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* src/global-styles/variables.css

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code graph analysis (1)</summary>

<details>
<summary>src/test/ThemeSwitch.test.jsx (1)</summary><blockquote>

<details>
<summary>src/components/ThemeSwitch.jsx (1)</summary>

* `ThemeSwitch` (14-24)

</details>

</blockquote></details>

</details><details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>docs/docs/reference/styling/theme-variables.md</summary>

[style] ~30-~30: Consider using an extreme adjective for ‘small’.
Context: ...--------- | | `--spacing-xs` | `4px`  | Extra small spacing      | | `--spacing-sm` | `8px`...

(EXTREME_ADJECTIVES)

</details>
<details>
<summary>docs/docs/reference/react/hooks/useTheme.md</summary>

[style] ~72-~72: ‘in conjunction with’ might be wordy. Consider a shorter alternative.
Context: ...sage with CSS variables  The hook works in conjunction with CSS variables defined in `/src/global-s...

(EN_WORDINESS_PREMIUM_IN_CONJUNCTION_WITH)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.18.1)</summary>

<details>
<summary>docs/docs/reference/react/components/ThemeSwitch/tests.md</summary>

9-9: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>
<details>
<summary>docs/docs/reference/styling/theme-variables.md</summary>

213-213: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread src/test/ThemeSwitch.test.jsx Outdated
Comment thread src/test/ThemeSwitch.test.jsx Outdated
@manu-059
Copy link
Copy Markdown
Contributor Author

@Ryan-Millard , Have added Tests, Documentation & Updated the requested colours.
Let me know if any change in Tests or Documentation needed, Will fix them.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
docs/docs/reference/react/components/NavBar/tests.md (1)

9-11: Add language identifier to code block.

The code block is missing a language identifier, which affects syntax highlighting and accessibility.

🔎 Proposed fix
-```
+```plaintext
 src/test/ThemeSwitch.test.jsx
</details>

</blockquote></details>
<details>
<summary>docs/docs/reference/react/components/ThemeSwitch/tests.md (1)</summary><blockquote>

`9-11`: **Add language identifier to code block.**

The code block lacks a language identifier for proper syntax highlighting.



<details>
<summary>🔎 Proposed fix</summary>

```diff
-```
+```plaintext
 src/test/ThemeSwitch.test.jsx
</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 6bf173c6fc2cb570a3b2ba27e42d9cfcbb7b347c and b505e840767e5d0f0af42fbe0af3c0d4de1a6434.

</details>

<details>
<summary>📒 Files selected for processing (25)</summary>

* `docs/docs/reference/react/components/NavBar/_category_.json`
* `docs/docs/reference/react/components/NavBar/index.md`
* `docs/docs/reference/react/components/NavBar/tests.md`
* `docs/docs/reference/react/components/ThemeSwitch/index.md`
* `docs/docs/reference/react/components/ThemeSwitch/tests.md`
* `docs/docs/reference/react/components/_category_.json`
* `docs/docs/reference/react/css/_category_.json`
* `docs/docs/reference/react/css/global/_category_.json`
* `docs/docs/reference/react/css/global/variables/_category_.json`
* `docs/docs/reference/react/css/global/variables/theme-independent.md`
* `docs/docs/reference/react/css/global/variables/theme/_category_.json`
* `docs/docs/reference/react/css/global/variables/theme/best-practice.md`
* `docs/docs/reference/react/css/global/variables/theme/dark.md`
* `docs/docs/reference/react/css/global/variables/theme/extending.md`
* `docs/docs/reference/react/css/global/variables/theme/light.md`
* `docs/docs/reference/react/css/global/variables/theme/related-pages.md`
* `docs/docs/reference/react/css/global/variables/theme/theme-switching.md`
* `docs/docs/reference/react/css/global/variables/theme/usage.md`
* `docs/docs/reference/react/hooks/_category_.json`
* `docs/docs/reference/react/hooks/useTheme.md`
* `docs/src/components/ColorSwatch.jsx`
* `src/components/ThemeSwitch.jsx`
* `src/components/ThemeSwitch.module.css`
* `src/components/ThemeSwitch.test.jsx`
* `src/hooks/useTheme.test.jsx`

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (8)</summary>

* docs/docs/reference/react/css/global/variables/theme/_category_.json
* docs/docs/reference/react/css/global/_category_.json
* docs/docs/reference/react/css/global/variables/_category_.json
* docs/docs/reference/react/css/global/variables/theme/light.md
* docs/docs/reference/react/css/_category_.json
* docs/docs/reference/react/css/global/variables/theme/theme-switching.md
* docs/docs/reference/react/components/NavBar/_category_.json
* docs/docs/reference/react/components/NavBar/index.md

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>

* src/components/ThemeSwitch.jsx
* docs/docs/reference/react/hooks/_category_.json
* docs/docs/reference/react/components/ThemeSwitch/index.md

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code graph analysis (2)</summary>

<details>
<summary>src/components/ThemeSwitch.test.jsx (1)</summary><blockquote>

<details>
<summary>src/components/ThemeSwitch.jsx (1)</summary>

* `ThemeSwitch` (15-27)

</details>

</blockquote></details>
<details>
<summary>src/hooks/useTheme.test.jsx (1)</summary><blockquote>

<details>
<summary>src/hooks/useTheme.js (2)</summary>

* `theme` (4-17)
* `toggleTheme` (37-39)

</details>

</blockquote></details>

</details><details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>docs/docs/reference/react/css/global/variables/theme-independent.md</summary>

[style] ~26-~26: Consider using an extreme adjective for ‘small’.
Context: ...--------- | | `--spacing-xs` | `4px`  | Extra small spacing      | | `--spacing-sm` | `8px`...

(EXTREME_ADJECTIVES)

</details>
<details>
<summary>docs/docs/reference/react/hooks/useTheme.md</summary>

[style] ~66-~66: ‘in conjunction with’ might be wordy. Consider a shorter alternative.
Context: ...sage with CSS variables  The hook works in conjunction with CSS variables defined in `/src/global-s...

(EN_WORDINESS_PREMIUM_IN_CONJUNCTION_WITH)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.18.1)</summary>

<details>
<summary>docs/docs/reference/react/components/NavBar/tests.md</summary>

9-9: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>
<details>
<summary>docs/docs/reference/react/components/ThemeSwitch/tests.md</summary>

9-9: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (14)</summary><blockquote>

<details>
<summary>docs/docs/reference/react/components/_category_.json (1)</summary><blockquote>

`3-3`: **LGTM! Documentation category position updated.**

The position update correctly accommodates the new ThemeSwitch documentation structure mentioned in the PR objectives.

</blockquote></details>
<details>
<summary>src/components/ThemeSwitch.module.css (2)</summary><blockquote>

`17-22`: **LGTM! Icon styling follows theme variable best practices.**

The icon correctly uses CSS variables for color and includes appropriate transitions.

---

`10-15`: **Add PostCSS transpilation or confirm modern browser targets for CSS Nesting support.**

CSS Nesting is natively supported in Chrome 120+, Edge 120+, Firefox 117+, and Safari 17.2+. However, this project has no PostCSS or transpilation setup configured, meaning the nested `.icon` selector will not work in older browsers. Either add PostCSS with a nesting plugin (e.g., `postcss-nesting`) or confirm the project targets only modern browsers.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/css/global/variables/theme/extending.md (1)</summary><blockquote>

`1-26`: **LGTM! Clear and accurate theme extension documentation.**

The instructions and code examples correctly demonstrate how to add theme-aware CSS variables to both light and dark theme blocks.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/css/global/variables/theme/best-practice.md (1)</summary><blockquote>

`1-18`: **LGTM! Comprehensive and practical theming best practices.**

The guidance is clear, actionable, and aligns well with the implemented theme system. The recommendations will help maintain consistency across the application.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/css/global/variables/theme/dark.md (2)</summary><blockquote>

`25-35`: **LGTM! Clear documentation of glass effect variables.**

The glass effect variables are well-documented with clear descriptions and visual previews. The use of rgba values for transparency effects is appropriate.

---

`11-24`: All documented dark theme color values match the CSS implementation in `variables.css` exactly. No corrections needed.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/css/global/variables/theme-independent.md (3)</summary><blockquote>

`9-9`: **Verify the GitHub link uses the correct branch.**

Line 9 links to the `main` branch. Since this is an open PR targeting main, ensure the link will be valid once merged, or consider using a branch-agnostic approach if the documentation is deployed from the PR branch.

---

`16-30`: **LGTM! Typography and spacing scales are well-defined.**

The spacing scale follows a consistent progression (4px increments), and the use of "Extra small" for `xs` aligns with industry-standard design system conventions. The static analysis suggestion to use "Extremely small" can be safely ignored as a false positive.

---

`32-37`: **LGTM! Border radius tokens are appropriately defined.**

The border radius values provide good options for UI consistency. The documentation is clear and complete.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/css/global/variables/theme/related-pages.md (1)</summary><blockquote>

`8-9`: No action required. The relative link paths are correct and will properly resolve to the existing documentation files.

</blockquote></details>
<details>
<summary>src/hooks/useTheme.test.jsx (1)</summary><blockquote>

`1-122`: **Excellent test coverage for the useTheme hook.**

This test suite demonstrates best practices:
- Effective use of a TestComponent wrapper to exercise the custom hook
- Comprehensive mocking of browser APIs (matchMedia, localStorage, document.documentElement)
- Test coverage spans initialization logic (system preference vs. localStorage), toggle functionality, DOM class updates, and localStorage persistence
- Edge case handling for unexpected theme values
- Proper setup/teardown ensuring clean test state

The tests effectively validate the hook's core responsibilities: SSR guards, system preference detection, localStorage persistence, and theme class application to the document root.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/hooks/useTheme.md (1)</summary><blockquote>

`1-199`: **Comprehensive and well-structured documentation.**

This documentation effectively covers:
- Clear explanation of hook functionality and return values
- Detailed initialization flow (localStorage → system preference → fallback)
- CSS variable integration with concrete examples
- Multiple usage patterns for different scenarios
- Implementation details with actual code snippets
- Testing guidance with mocking examples

The documentation aligns well with the hook implementation (based on relevant code snippets) and provides valuable guidance for developers using this hook.

</blockquote></details>
<details>
<summary>docs/docs/reference/react/css/global/variables/theme/usage.md (1)</summary><blockquote>

`1-84`: **Clear and practical documentation for theme variable usage.**

This documentation provides valuable usage patterns across different contexts:
- CSS color, spacing, and glass effect variables with practical examples
- CSS Module integration showing theme-aware component styling
- React inline styles demonstrating CSS variable usage in JSX

The examples are well-structured and cover common use cases that developers will encounter when implementing theme-aware components.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread docs/docs/reference/react/components/NavBar/tests.md Outdated
Comment thread docs/docs/reference/react/components/ThemeSwitch/tests.md Outdated
Comment thread docs/src/components/ColorSwatch.jsx
Comment thread src/components/ThemeSwitch.module.css
Comment thread src/components/ThemeSwitch.test.jsx
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 (1)
docs/docs/reference/react/hooks/useTheme/index.md (1)

66-66: Simplify wordy phrase for better readability.

The phrase "works in conjunction with" can be more concise.

🔎 Proposed edit
- The hook works in conjunction with CSS variables defined in `/src/global-styles/variables.css`:
+ The hook applies CSS variables defined in `/src/global-styles/variables.css`:
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b505e84 and 0e752c8.

📒 Files selected for processing (3)
  • docs/docs/reference/react/hooks/useTheme/_category_.json
  • docs/docs/reference/react/hooks/useTheme/index.md
  • docs/docs/reference/react/hooks/useTheme/tests.md
✅ Files skipped from review due to trivial changes (1)
  • docs/docs/reference/react/hooks/useTheme/category.json
🧰 Additional context used
🪛 LanguageTool
docs/docs/reference/react/hooks/useTheme/index.md

[style] ~66-~66: ‘in conjunction with’ might be wordy. Consider a shorter alternative.
Context: ...sage with CSS variables The hook works in conjunction with CSS variables defined in `/src/global-s...

(EN_WORDINESS_PREMIUM_IN_CONJUNCTION_WITH)

🔇 Additional comments (3)
docs/docs/reference/react/hooks/useTheme/tests.md (1)

1-95: ✅ Documentation is well-structured and comprehensive.

The test documentation clearly explains the hook's test coverage, mocking strategy, and provides practical examples using Vitest and React Testing Library. The organization (Initialization, Persistence, DOM side-effects, Toggling, Edge cases) effectively maps to the test suite structure and would help developers understand and maintain the tests.

Confirm that the test command examples at lines 16–24 match the actual npm test configuration in the project, and verify that the reference to "ThemeSwitch Component" at line 94 points to an existing documentation page.

docs/docs/reference/react/hooks/useTheme/index.md (2)

1-199: Overall documentation is clear and comprehensive.

The documentation effectively communicates the hook's purpose, provides practical examples, explains initialization and theme application logic, and includes implementation details. The structure with info box, dependencies, basic usage, return value table, how-it-works, examples, and implementation sections follows a logical progression that helps developers understand both usage and internals.


131-177: The implementation code snippets in the documentation are accurate and match the current implementation in src/hooks/useTheme.js. All three code sections—state initialization, toggle function, and side effects—correctly reflect the actual hook implementation, including the SSR fallback, localStorage persistence logic, and DOM class management. No updates needed.

Comment thread docs/docs/reference/react/hooks/useTheme/index.md
Comment thread docs/docs/reference/react/hooks/useTheme/index.md Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e752c8 and 91a0649.

📒 Files selected for processing (1)
  • docs/docs/reference/react/components/ThemeSwitch/tests.md
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
docs/docs/reference/react/components/ThemeSwitch/tests.md

10-10: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Comment thread docs/docs/reference/react/components/ThemeSwitch/tests.md
Comment thread docs/docs/reference/react/components/ThemeSwitch/tests.md
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/docs/reference/react/hooks/useTheme/index.md (1)

64-66: Simplify wordy phrasing for conciseness.

Line 66 uses "in conjunction with" which is more verbose than necessary. Consider replacing with a shorter alternative like "with" or "alongside".

-The hook works in conjunction with CSS variables defined in `/src/global-styles/variables.css`:
+The hook works with CSS variables defined in `/src/global-styles/variables.css`:
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91a0649 and d4ba5ab.

📒 Files selected for processing (2)
  • docs/docs/reference/react/css/global/variables/theme/related-pages.md
  • docs/docs/reference/react/hooks/useTheme/index.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/docs/reference/react/css/global/variables/theme/related-pages.md
🧰 Additional context used
🪛 LanguageTool
docs/docs/reference/react/hooks/useTheme/index.md

[style] ~66-~66: ‘in conjunction with’ might be wordy. Consider a shorter alternative.
Context: ...sage with CSS variables The hook works in conjunction with CSS variables defined in `/src/global-s...

(EN_WORDINESS_PREMIUM_IN_CONJUNCTION_WITH)

🔇 Additional comments (1)
docs/docs/reference/react/hooks/useTheme/index.md (1)

86-86: All referenced documentation pages exist in the repository. Verification confirms:

  • docs/docs/reference/react/css/global/variables/theme/ contains multiple theme documentation files
  • docs/docs/reference/react/components/ThemeSwitch/tests.md exists
  • docs/docs/reference/react/components/ThemeSwitch/index.md exists

The documentation cross-references are valid.

Copy link
Copy Markdown
Owner

@Ryan-Millard Ryan-Millard left a comment

Choose a reason for hiding this comment

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

This feature is heavenly. Thank you so much, @manu-059!

The UI is clean, the docs are clean, the tests are great and the functionality is wonderful. I look forward to your next contribution on this repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add theme toggle that auto-detects preferred theme

2 participants