@webjsdev/cli 0.9.0 → 0.9.1

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/lib/create.js CHANGED
@@ -642,10 +642,21 @@ export default function RootLayout({ children }: { children: unknown }) {
642
642
  <script>
643
643
  (function(){
644
644
  try {
645
- var t = localStorage.getItem('webjs_theme');
646
- if (t === 'light' || t === 'dark') {
647
- document.documentElement.dataset.theme = t;
645
+ var mq = window.matchMedia('(prefers-color-scheme: light)');
646
+ function apply(){
647
+ var t = null;
648
+ try { t = localStorage.getItem('webjs_theme'); } catch (_) {}
649
+ var el = document.documentElement;
650
+ if (t === 'light' || t === 'dark') el.dataset.theme = t;
651
+ else delete el.dataset.theme;
652
+ // Keep shadcn's .dark class in sync with the effective theme so the
653
+ // copied ui-* components (button, card, etc.) follow light/dark too.
654
+ // Dark is the default unless the OS prefers light or 'light' is set.
655
+ var dark = t === 'dark' || (t !== 'light' && !mq.matches);
656
+ el.classList.toggle('dark', dark);
648
657
  }
658
+ apply();
659
+ mq.addEventListener('change', apply);
649
660
  } catch (_) {}
650
661
  })();
651
662
  </script>
@@ -874,8 +885,13 @@ export class ThemeToggle extends WebComponent {
874
885
  if (next === 'system') localStorage.removeItem('webjs_theme');
875
886
  else localStorage.setItem('webjs_theme', next);
876
887
  } catch {}
877
- if (next === 'system') delete document.documentElement.dataset.theme;
878
- else document.documentElement.dataset.theme = next;
888
+ const el = document.documentElement;
889
+ if (next === 'system') delete el.dataset.theme;
890
+ else el.dataset.theme = next;
891
+ // Keep shadcn's .dark class in sync so the ui-* components follow the theme.
892
+ const dark = next === 'dark'
893
+ || (next === 'system' && !window.matchMedia('(prefers-color-scheme: light)').matches);
894
+ el.classList.toggle('dark', dark);
879
895
  }
880
896
 
881
897
  render() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webjsdev/cli",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "description": "webjs CLI - dev, start, create, db",
6
6
  "bin": {
@@ -568,6 +568,17 @@ or a build-step pipeline. The framework has no hard dependency on Tailwind.
568
568
  If you mix custom CSS into a light-DOM component, apply the class-prefix
569
569
  rule (see Components section above).
570
570
 
571
+ **Dark mode uses two signals; a theme switch must set both.** The editorial
572
+ chrome tokens (`--fg`, `--bg`, `--accent`) follow a `data-theme` attribute on
573
+ `<html>`; the Webjs UI kit under `components/ui/` follows a `.dark` class
574
+ (`@custom-variant dark (&:is(.dark *))`). The scaffold's head init script and
575
+ `theme-toggle` set **both** (`data-theme` AND
576
+ `classList.toggle('dark', isDark)`). If you replace the toggle or build your
577
+ own theme switch, set both, or the `components/ui/*` render light tokens on a
578
+ dark page (white buttons and cards, invisible text) while the chrome looks
579
+ correct. Light mode hides this (both systems default to light), so **verify
580
+ dark mode in a browser, not just light.**
581
+
571
582
  ---
572
583
 
573
584
  ## Styling alternative: vanilla CSS end-to-end