riptano / docs-ui

The UI and theme for DataStax Docs.
https://riptano.github.io/docs-ui/
Mozilla Public License 2.0
2 stars 0 forks source link

Prevent screen flash on page load #3

Closed colegoldsmith closed 1 year ago

colegoldsmith commented 1 year ago

This attempts to fix the "flash" that happens when you first load the site with the dark theme. Initially the light theme is default so the screen shows light colors for a split second before switching to dark.

This change solves the flash problem for most of the states on page load, but potentially not when the system preference and local storage setting differ.

How to test

  1. Run the UI in preview or as the bundle for a docs project
  2. Refresh the page after setting one or both of the settings: prefers-color-scheme and local storage

I found this helpful in chrome to manually change the prefers-color-scheme

Screenshot 2023-09-13 at 10 48 29 AM

To change local storage you can press the theme switch button, do delete you can remove from here

Screenshot 2023-09-13 at 10 53 26 AM