@w6w/ui 0.1.0 → 0.1.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.
@@ -375,7 +375,8 @@ export interface W6WUIProviderProps {
375
375
  api: W6WApi;
376
376
  /**
377
377
  * Force the theme every `@w6w/ui` component resolves to — both the CSS
378
- * tokens (`styles.css`'s `:where([data-theme=...])` blocks) and the
378
+ * tokens (`styles.css`'s `:where([data-theme=...])` blocks; `color-scheme` is
379
+ * declared on component roots, never on the host `<html>`) and the
379
380
  * JS-side theme-aware components (`AppIcon`, `CodeEditor`, `JsonEditor`,
380
381
  * `WorkflowFlowEditor`, via `useEffectiveTheme`) — instead of each one
381
382
  * independently falling back to `data-theme` on `<html>` or the visitor's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w6w/ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React components for w6w — central API management. Build plugins, apps and integrations on them.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://w6w.io",
@@ -102,6 +102,7 @@
102
102
  "test:picker-layout": "bash test/picker-layout/run.sh",
103
103
  "test:expr-template": "bash test/expr-template/run.sh",
104
104
  "test:action-test-form": "bash test/action-test-form/run.sh",
105
+ "test:host-isolation": "bash test/host-isolation/run.sh",
105
106
  "test:copyable": "bash test/copyable/run.sh",
106
107
  "test:pack-smoke": "bash test/pack-smoke/run.sh",
107
108
  "storybook": "storybook dev -p 6006 --no-open",
package/src/code.css CHANGED
@@ -34,7 +34,6 @@
34
34
  */
35
35
  /* Light — the base defaults. */
36
36
  :where(:root) {
37
- color-scheme: light;
38
37
  --w6w-bg: #f7f8fa;
39
38
  --w6w-panel: #ffffff;
40
39
  --w6w-panel-2: #f0f2f6;
@@ -57,13 +56,13 @@
57
56
  --w6w-code-punctuation: #5f6875;
58
57
  --w6w-code-variable: #953800;
59
58
  --w6w-radius: 10px;
59
+ --w6w-scheme: light;
60
60
  }
61
61
 
62
62
  /* Dark — followed automatically from the OS preference (unless a host has
63
63
  forced a mode via data-theme, which is handled by the blocks below). */
64
64
  @media (prefers-color-scheme: dark) {
65
65
  :where(:root) {
66
- color-scheme: dark;
67
66
  --w6w-bg: #0f1115;
68
67
  --w6w-panel: #181b22;
69
68
  --w6w-panel-2: #1f232c;
@@ -78,6 +77,7 @@
78
77
  --w6w-health-down: var(--w6w-danger);
79
78
  --w6w-health-unknown: #9aa3b2;
80
79
  --w6w-icon-swatch: #1f232c;
80
+ --w6w-scheme: dark;
81
81
  --w6w-code-comment: #7d8797;
82
82
  --w6w-code-keyword: #d2a8ff;
83
83
  --w6w-code-string: #7ee787;
@@ -90,7 +90,7 @@
90
90
  /* Explicit mode. Declared AFTER the media query at equal (zero) specificity, so
91
91
  a forced data-theme always beats the OS preference. */
92
92
  :where([data-theme=light]) {
93
- color-scheme: light;
93
+ --w6w-scheme: light;
94
94
  --w6w-bg: #f7f8fa;
95
95
  --w6w-panel: #ffffff;
96
96
  --w6w-panel-2: #f0f2f6;
@@ -115,7 +115,7 @@
115
115
  }
116
116
 
117
117
  :where([data-theme=dark]) {
118
- color-scheme: dark;
118
+ --w6w-scheme: dark;
119
119
  --w6w-bg: #0f1115;
120
120
  --w6w-panel: #181b22;
121
121
  --w6w-panel-2: #1f232c;
@@ -147,6 +147,25 @@
147
147
  font-size: 0.85em;
148
148
  }
149
149
 
150
+ /* color-scheme — declared on ui COMPONENT ROOTS, never on the host's <html>.
151
+ `color-scheme` inherits and also themes the page canvas, scrollbars and form
152
+ controls, so setting it on :root / [data-theme] let importing this file flip a
153
+ host's whole document. Instead each token block above also sets the
154
+ `--w6w-scheme` custom property (light / dark), which INHERITS, so the nearest
155
+ themed ancestor wins however themes nest (a light panel inside a dark page and
156
+ the reverse). Elements ui renders (any `w6w-` class, which covers the native
157
+ <dialog> modals) and the native controls inside them read it with
158
+ `color-scheme: var(--w6w-scheme)`. Not a hand-picked root list: every ui
159
+ component carries a `w6w-` class. Only an element whose class LIST has a token
160
+ starting `w6w-` matches (`class^=` / `class*=" w6w-"`), so host elements are never
161
+ touched: not a host `data-theme` wrapper, not a host class that merely contains
162
+ `w6w-` (`my-w6w-card`), and not a host element's own color-scheme on inputs nested
163
+ in a ui root (color-scheme inherits, so no descendant rule is needed). Nothing here
164
+ ever matches <html>/:root. All zero specificity. */
165
+ :where([class^=w6w-]:not(:root), [class*=" w6w-"]:not(:root)) {
166
+ color-scheme: var(--w6w-scheme);
167
+ }
168
+
150
169
  /*
151
170
  * @w6w/ui — the spacing / typography scale.
152
171
  *
@@ -9,10 +9,10 @@
9
9
  added to that stack later inherits it with no styling of its own.
10
10
 
11
11
  Custom properties, deliberately, rather than a `.react-flow__controls-button`
12
- override: `@xyflow/react/dist/style.css` is imported as a side effect from
13
- WorkflowFlowEditor.tsx, so it rides in the LAZY chunk and is injected *after*
14
- this stylesheet. A bare class override (0,1,0) would tie with the library's
15
- own rule and lose on source order. Custom properties inherit and are
12
+ override: React Flow's own stylesheet is compiled into the same
13
+ styles.css (`@use` in the build-only styles.build.scss), but cascade
14
+ order is not something to lean on: a bare class override (0,1,0) would tie
15
+ with the library's own rule and lose if the order ever changed. Custom properties inherit and are
16
16
  order-independent, and scoping them on `.w6w-flow` keeps them off the rest of
17
17
  the page.
18
18
 
@@ -28,7 +28,6 @@
28
28
 
29
29
  /* Light — the base defaults. */
30
30
  :where(:root) {
31
- color-scheme: light;
32
31
  --w6w-bg: #f7f8fa;
33
32
  --w6w-panel: #ffffff;
34
33
  --w6w-panel-2: #f0f2f6;
@@ -51,13 +50,13 @@
51
50
  --w6w-code-punctuation: #5f6875;
52
51
  --w6w-code-variable: #953800;
53
52
  --w6w-radius: 10px;
53
+ --w6w-scheme: light;
54
54
  }
55
55
 
56
56
  /* Dark — followed automatically from the OS preference (unless a host has
57
57
  forced a mode via data-theme, which is handled by the blocks below). */
58
58
  @media (prefers-color-scheme: dark) {
59
59
  :where(:root) {
60
- color-scheme: dark;
61
60
  --w6w-bg: #0f1115;
62
61
  --w6w-panel: #181b22;
63
62
  --w6w-panel-2: #1f232c;
@@ -72,6 +71,7 @@
72
71
  --w6w-health-down: var(--w6w-danger);
73
72
  --w6w-health-unknown: #9aa3b2;
74
73
  --w6w-icon-swatch: #1f232c;
74
+ --w6w-scheme: dark;
75
75
  --w6w-code-comment: #7d8797;
76
76
  --w6w-code-keyword: #d2a8ff;
77
77
  --w6w-code-string: #7ee787;
@@ -85,7 +85,7 @@
85
85
  /* Explicit mode. Declared AFTER the media query at equal (zero) specificity, so
86
86
  a forced data-theme always beats the OS preference. */
87
87
  :where([data-theme="light"]) {
88
- color-scheme: light;
88
+ --w6w-scheme: light;
89
89
  --w6w-bg: #f7f8fa;
90
90
  --w6w-panel: #ffffff;
91
91
  --w6w-panel-2: #f0f2f6;
@@ -109,7 +109,7 @@
109
109
  --w6w-code-variable: #953800;
110
110
  }
111
111
  :where([data-theme="dark"]) {
112
- color-scheme: dark;
112
+ --w6w-scheme: dark;
113
113
  --w6w-bg: #0f1115;
114
114
  --w6w-panel: #181b22;
115
115
  --w6w-panel-2: #1f232c;
@@ -139,3 +139,22 @@
139
139
  .w6w-small {
140
140
  font-size: 0.85em;
141
141
  }
142
+
143
+ /* color-scheme — declared on ui COMPONENT ROOTS, never on the host's <html>.
144
+ `color-scheme` inherits and also themes the page canvas, scrollbars and form
145
+ controls, so setting it on :root / [data-theme] let importing this file flip a
146
+ host's whole document. Instead each token block above also sets the
147
+ `--w6w-scheme` custom property (light / dark), which INHERITS, so the nearest
148
+ themed ancestor wins however themes nest (a light panel inside a dark page and
149
+ the reverse). Elements ui renders (any `w6w-` class, which covers the native
150
+ <dialog> modals) and the native controls inside them read it with
151
+ `color-scheme: var(--w6w-scheme)`. Not a hand-picked root list: every ui
152
+ component carries a `w6w-` class. Only an element whose class LIST has a token
153
+ starting `w6w-` matches (`class^=` / `class*=" w6w-"`), so host elements are never
154
+ touched: not a host `data-theme` wrapper, not a host class that merely contains
155
+ `w6w-` (`my-w6w-card`), and not a host element's own color-scheme on inputs nested
156
+ in a ui root (color-scheme inherits, so no descendant rule is needed). Nothing here
157
+ ever matches <html>/:root. All zero specificity. */
158
+ :where([class^="w6w-"]:not(:root), [class*=" w6w-"]:not(:root)) {
159
+ color-scheme: var(--w6w-scheme);
160
+ }