Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next themes #1061

Merged
merged 4 commits into from
Dec 14, 2023
Merged

Next themes #1061

merged 4 commits into from
Dec 14, 2023

Conversation

sspenst
Copy link
Owner

@sspenst sspenst commented Dec 13, 2023

Goal

  • Get the page to not flash any theme other than the one you selected
  • Ability to use Tailwind dark: classes based on the selected theme

Implementation

  • ThemeProvider sets class attribute on <html> to one of the custom Theme values
    • this class allows the correct CSS variables to be used from global.css
    • ThemeProvider stores this value in localStorage
    • this class is updated by calling setAppTheme in themeModal
  • data-theme-dark custom attribute
    • need this so we can use Tailwind dark: classes based on the current theme
    • color-scheme style variable is set in global.css based on data-theme-dark
    • manually set data-theme-dark attribute based on the current theme
  • loading the theme instantly with dangerouslySetInnerHTML script
    • ThemeProvider handles setting the class attribute to the correct theme
    • this script initializes data-theme-dark based on the localStorage value
    • invalid localStorage themes are handled here and reset back to the default theme-modern

* trying to get custom themes to work

* woww i think i got it working

* some cleanup

* still trying things, almost done

* touching up
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2ea43f1) 79.93% compared to head (a55783c) 80.52%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1061      +/-   ##
==========================================
+ Coverage   79.93%   80.52%   +0.59%     
==========================================
  Files         208      207       -1     
  Lines        6240     6194      -46     
  Branches     1380     1374       -6     
==========================================
  Hits         4988     4988              
+ Misses       1195     1151      -44     
+ Partials       57       55       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sspenst sspenst merged commit 631f36b into main Dec 14, 2023
24 checks passed
@sspenst sspenst deleted the next-themes branch December 14, 2023 01:22
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