Closed bjesuiter closed 1 year ago
Idea 3: Use _App.tsx to control the whole document: https://fresh.deno.dev/docs/concepts/app-wrapper
_app.tsx also requires info being available on server render (i guess?, since its a route and not an island)
i think this will not be fixable unless we save it serverside, or find a way to run an island before rendering html.
Yes, we need to store the users design preference on server side for this.
Maybe we need to add a UserPreferences Table to the UserSession one to have a place for these settings.
=> ofc toghether with your cache :)
Better Idea: Let the ThemeSwitcher write a non-secure cookie on client side and evaluate it in server render! If not available, set default.
Detect the default via client hint headers: https://dev.to/bryce/detecting-dark-mode-on-every-request-21b2
More info on web.dev: https://web.dev/user-preference-media-features-headers/
Implemented Cookie based theming:
Problem probably: Preact theme Switcher JS must be hydrated before theme is finally set, bc. current user theme comes from localstorage.
=> Idea: Store current user theme in userSession and pass it down on server render. => Idea 2: Add a new Wrapper in Layout component around header, main and footer components to attach the theme attribute to.