@vale-dinap/lucidly 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/theme.js ADDED
@@ -0,0 +1,9 @@
1
+ // Sets the colour theme before the page is first painted, so it never flashes the wrong one:
2
+ // the saved choice (see the theme button in app.js), else the system's. Loaded in <head>.
3
+ try {
4
+ const t = localStorage.getItem('lucidly.theme');
5
+ const dark = t === 'dark' || (t !== 'light' && matchMedia('(prefers-color-scheme: dark)').matches);
6
+ document.documentElement.dataset.theme = dark ? 'dark' : 'light';
7
+ } catch {
8
+ /* storage blocked: app.js applies the system theme */
9
+ }