@hadoku/themes 0.0.0-stage → 5.12.16

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-lucide +43 -0
  3. package/README.md +433 -2
  4. package/THEME_USAGE_GUIDE.md +308 -0
  5. package/dist/HadokuThemeRoot.d.ts +53 -0
  6. package/dist/HadokuThemeRoot.js +66 -0
  7. package/dist/ThemeIcons.d.ts +31 -0
  8. package/dist/ThemeIcons.js +91 -0
  9. package/dist/effects.d.ts +25 -0
  10. package/dist/effects.js +25 -0
  11. package/dist/icons/Icon.d.ts +36 -0
  12. package/dist/icons/Icon.js +89 -0
  13. package/dist/icons/index.d.ts +61 -0
  14. package/dist/icons/index.js +87 -0
  15. package/dist/icons/registry.generated.d.ts +158 -0
  16. package/dist/icons/registry.generated.js +446 -0
  17. package/dist/index.d.ts +82 -0
  18. package/dist/index.js +169 -0
  19. package/dist/metadata.d.ts +35 -0
  20. package/dist/metadata.js +108 -0
  21. package/dist/platform/index.d.ts +94 -0
  22. package/dist/platform/index.js +149 -0
  23. package/dist/platform/usePlatform.d.ts +29 -0
  24. package/dist/platform/usePlatform.js +65 -0
  25. package/dist/prefsApiBase.d.ts +37 -0
  26. package/dist/prefsApiBase.js +40 -0
  27. package/dist/theme-types.d.ts +34 -0
  28. package/dist/theme-types.js +1 -0
  29. package/dist/themeContext.d.ts +62 -0
  30. package/dist/themeContext.js +70 -0
  31. package/dist/themePrefs.d.ts +29 -0
  32. package/dist/themePrefs.js +48 -0
  33. package/dist/useRefElement.d.ts +19 -0
  34. package/dist/useRefElement.js +52 -0
  35. package/dist/useTheme.d.ts +46 -0
  36. package/dist/useTheme.js +216 -0
  37. package/package.json +83 -4
  38. package/scripts/audit-tokens.mjs +126 -0
  39. package/scripts/check-contrast.mjs +24 -0
  40. package/scripts/check-docs.mjs +53 -0
  41. package/scripts/check-icons.mjs +473 -0
  42. package/scripts/check-usage.mjs +297 -0
  43. package/scripts/codemod-icons.mjs +396 -0
  44. package/scripts/generate-icons.mjs +199 -0
  45. package/scripts/generate-preview.mjs +374 -0
  46. package/scripts/generate-tailwind-colors.mjs +109 -0
  47. package/scripts/lib/color.mjs +184 -0
  48. package/scripts/lib/contract.d.mts +58 -0
  49. package/scripts/lib/contract.mjs +348 -0
  50. package/scripts/lib/derive.mjs +324 -0
  51. package/scripts/lib/icon-registry.mjs +92 -0
  52. package/scripts/lib/parse-themes.mjs +19 -0
  53. package/scripts/lib/tokens.mjs +188 -0
  54. package/scripts/normalize-tokens.mjs +161 -0
  55. package/src/advanced.css +218 -0
  56. package/src/icons/Icon.tsx +151 -0
  57. package/src/icons/emoji-map.json +202 -0
  58. package/src/icons/index.ts +151 -0
  59. package/src/icons/registry.generated.ts +455 -0
  60. package/src/icons/sources.json +150 -0
  61. package/src/icons.css +145 -0
  62. package/src/style.css +1421 -0
  63. package/src/tailwind-colors.css +88 -0
  64. package/src/tailwind-integration.css +49 -0
package/src/icons.css ADDED
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Hadoku icon module — presentation layer.
3
+ *
4
+ * Import alongside style.css, UNLAYERED (see THEME_USAGE_GUIDE.md — putting it in a
5
+ * cascade layer makes every colour resolve to nothing):
6
+ *
7
+ * @import '@wolffm/themes/style.css';
8
+ * @import '@wolffm/themes/icons.css';
9
+ *
10
+ * ─────────────────────────────────────────────────────────────────────────────
11
+ * WHY THE GLYPH IS NOT TINTED WITH AN ACCENT BY DEFAULT
12
+ *
13
+ * The obvious design — paint the glyph `--color-warning` — is unshippable, and the
14
+ * numbers are unambiguous. Measured across all 18 themes on both `--color-bg-card`
15
+ * and `--color-bg`, a bare accent glyph misses the WCAG 1.4.11 non-text minimum of
16
+ * 3:1 in 8 of 36 combinations for `warning` alone (light 2.15, ocean-light 1.92,
17
+ * pink-light 1.67), and every other family fails somewhere too. `--color-<f>-dark`
18
+ * does not rescue it — that fails 3 more.
19
+ *
20
+ * This is precisely the accent-as-text anti-pattern `scripts/check-usage.mjs` rule 6
21
+ * already gates against, and it is NOT covered by `check:contrast`, which validates
22
+ * `on-<f>` over `<f>` and never looks at an accent over a surface.
23
+ *
24
+ * So the accent moves to the icon's CHROME, exactly as the planning doc's own escape
25
+ * hatch anticipated. Both tile treatments below pass 3:1 in 18/18 themes for all five
26
+ * families, because they reuse the token pairings the design system already
27
+ * guarantees: tint tile = `--color-<f>-bg` + `--color-on-<f>-bg`; filled tile =
28
+ * `--color-<f>` + `--color-on-<f>`.
29
+ *
30
+ * A bare icon inherits `currentColor`, so it is as legible as the text it sits with —
31
+ * safe by construction in every theme, with no contrast obligation of its own.
32
+ */
33
+
34
+ /* ── the glyph ─────────────────────────────────────────────────────────────── */
35
+
36
+ .hdk-icon {
37
+ width: 1em;
38
+ height: 1em;
39
+ flex: 0 0 auto;
40
+ /* Sit on the text baseline so `<Icon/> Label` lines up without extra layout. */
41
+ vertical-align: -0.14em;
42
+ }
43
+
44
+ /* `set:html` and dangerouslySetInnerHTML need a host element in the framework-free
45
+ path; it must not disturb inline layout. */
46
+ span.hdk-icon {
47
+ display: inline-flex;
48
+ }
49
+
50
+ span.hdk-icon > svg {
51
+ width: 100%;
52
+ height: 100%;
53
+ }
54
+
55
+ /* ── consumer-chosen glyph colour ──────────────────────────────────────────── */
56
+
57
+ /*
58
+ * The escape hatch, and the reason it is a class rather than a prop taking a
59
+ * colour: a consumer may paint the glyph itself with any FAMILY token, but only
60
+ * with a family token. No hex can travel through this API, which is the whole
61
+ * constraint — how you colour an icon is your call, where the colour comes from
62
+ * is not.
63
+ *
64
+ * Contrast then belongs to the consumer. A bare accent glyph clears 3:1 on a page
65
+ * or card surface in only 28 of 36 theme/surface combinations for `warning` (see
66
+ * the header note), so this is right when you know the surface — an accent glyph
67
+ * inside a tinted row, or beside a label you have already checked — and wrong as
68
+ * a blanket default. Hence `bare` stays the default and this is opt-in.
69
+ */
70
+ .hdk-icon--primary {
71
+ color: var(--color-primary);
72
+ }
73
+ .hdk-icon--success {
74
+ color: var(--color-success);
75
+ }
76
+ .hdk-icon--warning {
77
+ color: var(--color-warning);
78
+ }
79
+ .hdk-icon--danger {
80
+ color: var(--color-danger);
81
+ }
82
+ .hdk-icon--neutral {
83
+ color: var(--color-neutral);
84
+ }
85
+
86
+ /* ── the accent chrome ─────────────────────────────────────────────────────── */
87
+
88
+ .hdk-icon-tile {
89
+ display: inline-flex;
90
+ align-items: center;
91
+ justify-content: center;
92
+ /* Square, and sized from the glyph so one font-size drives the whole thing. */
93
+ width: 2em;
94
+ height: 2em;
95
+ border-radius: var(--hdk-radius);
96
+ flex: 0 0 auto;
97
+ }
98
+
99
+ .hdk-icon-tile--round {
100
+ border-radius: 50%;
101
+ }
102
+
103
+ /* Tint: --color-<f>-bg + --color-on-<f>-bg. The documented badge pairing. */
104
+ .hdk-icon-tile--tint.hdk-icon-tile--primary {
105
+ background: var(--color-primary-bg);
106
+ color: var(--color-on-primary-bg);
107
+ }
108
+ .hdk-icon-tile--tint.hdk-icon-tile--success {
109
+ background: var(--color-success-bg);
110
+ color: var(--color-on-success-bg);
111
+ }
112
+ .hdk-icon-tile--tint.hdk-icon-tile--warning {
113
+ background: var(--color-warning-bg);
114
+ color: var(--color-on-warning-bg);
115
+ }
116
+ .hdk-icon-tile--tint.hdk-icon-tile--danger {
117
+ background: var(--color-danger-bg);
118
+ color: var(--color-on-danger-bg);
119
+ }
120
+ .hdk-icon-tile--tint.hdk-icon-tile--neutral {
121
+ background: var(--color-neutral-bg);
122
+ color: var(--color-on-neutral-bg);
123
+ }
124
+
125
+ /* Filled: --color-<f> + --color-on-<f>. */
126
+ .hdk-icon-tile--filled.hdk-icon-tile--primary {
127
+ background: var(--color-primary);
128
+ color: var(--color-on-primary);
129
+ }
130
+ .hdk-icon-tile--filled.hdk-icon-tile--success {
131
+ background: var(--color-success);
132
+ color: var(--color-on-success);
133
+ }
134
+ .hdk-icon-tile--filled.hdk-icon-tile--warning {
135
+ background: var(--color-warning);
136
+ color: var(--color-on-warning);
137
+ }
138
+ .hdk-icon-tile--filled.hdk-icon-tile--danger {
139
+ background: var(--color-danger);
140
+ color: var(--color-on-danger);
141
+ }
142
+ .hdk-icon-tile--filled.hdk-icon-tile--neutral {
143
+ background: var(--color-neutral);
144
+ color: var(--color-on-neutral);
145
+ }