@webority/theme 0.7.7 → 0.7.9

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/README.md CHANGED
@@ -37,6 +37,56 @@ colour — intentional shared semantics (see `_variables.scss`).
37
37
  `dist/webority-theme.css` is a precompiled default-brand **portal** build (no
38
38
  marketing partial). Prefer the SCSS chain above for brand-exact output.
39
39
 
40
+ ## Dark mode
41
+
42
+ The theme ships with two built-in dark-mode support patterns:
43
+
44
+ ### Manual toggle (production)
45
+
46
+ Set `data-theme="dark"` and `data-bs-theme="dark"` on `<html>` to flip both WUI and Bootstrap
47
+ native components together. The dark token remap maps all `--color-*` aliases onto dark hexes,
48
+ and Bootstrap's utility classes (`.text-body`, `.bg-secondary`) and components respond via
49
+ the `[data-bs-theme="dark"]` selector that Bootstrap provides. **Pair the attributes**—setting
50
+ one without the other leaves part of the system on the wrong palette.
51
+
52
+ Persist the choice in localStorage and restore it on next visit:
53
+
54
+ ```js
55
+ // On mount:
56
+ const theme = localStorage.getItem('theme') || 'light';
57
+ document.documentElement.setAttribute('data-theme', theme);
58
+ document.documentElement.setAttribute('data-bs-theme', theme);
59
+
60
+ // On toggle:
61
+ const newTheme = theme === 'light' ? 'dark' : 'light';
62
+ document.documentElement.setAttribute('data-theme', newTheme);
63
+ document.documentElement.setAttribute('data-bs-theme', newTheme);
64
+ localStorage.setItem('theme', newTheme);
65
+ ```
66
+
67
+ ### Automatic detection (opt-in)
68
+
69
+ Set `data-theme="auto"` on `<html>` to detect the system preference via `@media (prefers-color-scheme: dark)`
70
+ and apply the dark remap automatically. Works with user-level system settings (OS dark mode);
71
+ **does not persist a user's manual toggle** (every reload reads the OS setting). Use for opt-in
72
+ portals where the portal doesn't control color preference; omit for apps that give users a
73
+ theme picker.
74
+
75
+ ### Implementation
76
+
77
+ Both patterns use the same 60-line dark-token SCSS mixin (defined in `_wui-aliases.scss`),
78
+ so the compiled dark CSS is byte-identical whether toggled manually or via system preference.
79
+
80
+ Token remap includes:
81
+ - **Surfaces & text** — `--color-bg`, `--color-border`, `--color-text*`
82
+ - **Bootstrap RGB triplets** — `--bs-body-bg-rgb`, `--bs-body-color-rgb`, etc., so `.bg-body` / `.text-body` utilities flip
83
+ - **Brand & status colors** — primary, success, danger, warning, info (mapped to readable values on dark surfaces)
84
+ - **Scrim** — overlay dimming adjusted for dark backgrounds
85
+ - **Component shadows** — slider thumbs, badge accents, etc. re-mapped for visibility
86
+
87
+ Marketing sites ship light-only (the `scss/_marketing.scss` partial is opt-in on portals
88
+ and omitted on marketing); dark mode is a **portal feature**, not a marketing requirement.
89
+
40
90
  ## Library vs product ownership
41
91
 
42
92
  Three layers. Do not collapse product art direction into the shared package.