@widgentic/designer 0.4.1 → 0.6.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/README.md CHANGED
@@ -91,4 +91,36 @@ one default palette and no second one to fall back to: a host that wants a
91
91
  different look passes its own values through `chrome`, and `chromeCss` renders
92
92
  them for the surrounding page just the same.
93
93
 
94
+ Three shapes of the same recipe:
95
+
96
+ 1. **Partial override** — pass only what differs; every unmapped token keeps
97
+ the product default: `chrome: { accent: "var(--brand)", font: "Inter, sans-serif" }`.
98
+ 2. **Full takeover** — the page owns the palette and the designers follow it
99
+ by construction. Paint the page with `chromeCss` and hand the designers
100
+ `chromeReferences()`, the full map of `var()` references under the same
101
+ prefix:
102
+
103
+ ```ts
104
+ import { CHROME_DEFAULTS, chromeCss, chromeReferences, createDesigner } from "@widgentic/designer";
105
+
106
+ // the page: light block, system dark block, and an explicit toggle block
107
+ style.textContent = chromeCss(CHROME_DEFAULTS, {
108
+ prefix: "--host",
109
+ selector: ":root",
110
+ darkMediaSelector: ':root:not([data-theme="light"])',
111
+ darkSelector: ':root[data-theme="dark"]'
112
+ });
113
+ // the designers: references resolve at the page, so flipping data-theme
114
+ // repaints MOUNTED designers through the cascade — no remount, no event
115
+ createDesigner(host, { chrome: { ...chromeReferences(), font: "Inter, sans-serif" } });
116
+ ```
117
+
118
+ 3. **A scheme toggle** is nothing extra — it is the full takeover's
119
+ `darkSelector` block plus one attribute your page writes.
120
+
121
+ One caveat, worth reading twice: a reference to a property the page never
122
+ defines is INVALID at computed-value time — it does not fall back to the
123
+ built-in defaults. Always pair `chromeReferences()` with `chromeCss` under the
124
+ same prefix; use a partial override when you only want to change a few tokens.
125
+
94
126
  MIT © Diego Hoyos