saadeghi / theme-change

Change CSS theme with toggle, buttons or select using CSS custom properties and localStorage
https://codepen.io/saadeghi/pen/OJypbNM
MIT License
1.42k stars 46 forks source link

Calling themeChange doesn't change the theme #37

Open ghost opened 1 year ago

ghost commented 1 year ago

The toggle component works fine but after a user login, I can't set the theme because changing the value(what I update from a store) only changes the toggle's state:

          <input type="checkbox" class="toggle toggle-primary"
                 data-toggle-theme="light,dark" data-theme="dark"
                 bind:checked={isDarkMode} on:change={handleModeUpdate} />
        </label>

In this case, the site will be still dark when a different component changes isDarkMode to false when it was true by default.

ghost commented 1 year ago

The toggle doesn't even react to the update of isDarkMode at all. I was wondering if I should try a select but if there is no mechanism to update the theme then there is no point in it.

saadeghi commented 1 year ago

Can you please provide an example repo?