nvchad.github.io icon indicating copy to clipboard operation
nvchad.github.io copied to clipboard

Bugfix/theme initial state

Open imnaK opened this issue 10 months ago • 0 comments

Issue:

The website currently attempts to set the theme from localStorage without checking if a value is actually stored. This can lead to undefined being used as the theme, causing unexpected behavior e.g. having to double click the theme-toggler to get to dark mode.

Steps to Reproduce:

  1. Clear cookies on the official website (https://nvchad.com).
  2. Reload the page.

Expected Behavior:

The website should load with a valid theme applied, even if no theme preference is set in localStorage yet.

Proposed Fix:

This pull request introduces a check for localStorage.theme. If the value is not set (i.e., undefined), the system's preferred theme will be used as the default and saved to localStorage for future visits.

Manual testing has been conducted to ensure the fix works as intended.

imnaK avatar Mar 29 '24 17:03 imnaK