@flairstudio/kit 0.2.0-beta.0 → 0.2.0-beta.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  Renaming or removing a token is a breaking change. Adding a token, or changing a value, is a minor release. Before 1.0, a breaking change bumps the minor version.
4
4
 
5
+ ## 0.2.0-beta.2
6
+
7
+ A beta, published under npm's `next` tag. `latest` stays at 0.1.0 until 0.2.0.
8
+
9
+ - **Changed, can break tests:** `tokens.css` writes every `--color-*` value, and each `@property` `initial-value`, as `color(srgb R G B)` instead of hex, and the preview writes a host's colours the same way. Hosts still send `#rrggbb`. Browsers fade a hex or `rgb()` colour in gamma-encoded sRGB, and between distant hues that passes through dark grey: the package's own fade between themes dipped. Chrome and Safari fade a `color(srgb …)` value in Oklab, which keeps its lightness. Firefox, checked in 159, fades it through sRGB as it does hex, so there the dip stays. `color()` needs Chrome 111, Firefox 113 or Safari 15, and an older browser drops the colours; hex worked in every browser. A script that reads a token with `getComputedStyle` and passes it to a colour parser now gets `color(srgb …)`, which some parsers don't read. The package's default colours, and the colours a host sends, now read back as `color(srgb …)` instead of `rgb(…)`, so a site test that matches them as `rgb()` strings needs updating. A site palette written in hex still reads back as `rgb(…)`. `tokens.json` and `TOKENS.md` stay hex.
10
+ - **Changed:** `listen()` checks its `allow` list before anything else, so a mistake throws a `TypeError` whether or not the page is in a frame. Before, outside a frame it was never checked.
11
+ - A string, such as `allow: 'https://flair.example'`, now throws, saying `allow` is a list. Before, it was split into characters, and the error named the first one.
12
+ - An empty list now throws, since no host could theme the page.
13
+ - A second `listen()` while one runs still changes nothing. If its `allow` holds other origins than the running one's, it now logs a console warning that the first list stands.
14
+ - **Changed:** in `preview-host.d.ts`, `Connection`'s `send` and `close` are typed as properties, `send: (theme: Theme) => void`, instead of methods. That matches the script, which returns them as plain functions, keeps `send`'s parameter strictly checked, and satisfies lint rules such as `unbound-method`.
15
+ - **Docs:** the README's opening names the layer order line, `@layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;`, that `tokens.css` opens with.
16
+ - **Docs:** the published beta.1's README, changelog and a comment in `preview.js` said only Chrome and Safari name the parent's origin through `location.ancestorOrigins`, and that Firefox doesn't. Current Firefox does too. It names it `"null"` when the frame has `referrerpolicy="no-referrer"`, and there the listener sends `ready` to each allowed address, as it does where no origin is named. Nothing in the listener changed.
17
+ - **Docs:** the README's Playwright recipe, "Testing a site's pages with a Flair theme", now runs in Chromium. It failed there: Chromium's Local Network Access check blocked the framed site, because the host page comes from `page.route`. The test now grants `local-network-access` in Chromium only, since WebKit throws on that permission. The recipe also says `SITE` is the site's own address, ends with a sample check that the theme's mode reached the page, and says which lines need a cast in TypeScript.
18
+ - **Docs:** `onApplied` and the README's Playwright recipe no longer say `applied` means the frame is ready to be seen. It can come before the frame has drawn the theme: the listener sends it after two animation frames or after 500ms, whichever comes first. The recipe now waits two animation frames inside the frame after `applied`, before it checks the page. Found by a site's framed tests: 7 of 140 framed runs read the site's own palette without the wait, 0 of 280 with it.
19
+ - **Docs:** "A site's palette and overrides" warns that labels on primary can be dark in a Flair theme. The default theme's `on-primary` is black (5.61:1 on `#0d9488`, where white is 3.74:1), so a site that forces white labels or shades its primary fills toward black fails contrast under it.
20
+ - **Internal:** `preview.js` takes its theme selectors, event and attribute names, `--dur-theme` and its hold, `--gradient-angle` and the `--color-` prefix from the build, from the same places as `tokens.css` and the type declarations. This change alone changes no output.
21
+ - **Tests:** fixes to the package's own tests. None changes what the package does.
22
+
23
+ ## 0.2.0-beta.1
24
+
25
+ A beta, published under npm's `next` tag. `latest` stays at 0.1.0 until 0.2.0.
26
+
27
+ - **Added:** FlairDesigner's local addresses, `http://localhost:3300` (its dev server) and `http://localhost:4330` (its tests), to `DEFAULT_ALLOW`. A page that FlairDesigner frames now needs no `allow` list of its own. Flair Design's two addresses stay.
28
+ - **Changed:** a message from the host that isn't flair-kit's, one whose `type` doesn't start with `flair-kit:`, such as a browser extension's, is now ignored without a word. In beta.0 it got a console warning and a `refused` answer with the reason `type`, so the host showed a refusal while the theme was on. An unknown `flair-kit:` type is still refused.
29
+ - **Changed:** where the browser names the parent's origin, as current Chrome, Safari and Firefox do, the listener now sends `ready` only to that origin, or to none if it isn't allowed. A framed page no longer logs a console warning for each other allowed address. Where the browser doesn't name the parent, or names it `"null"`, `ready` still goes to each allowed address.
30
+ - **Docs:** "Showing a site in Flair" in the README names FlairDesigner as the app that frames the page, and calls it the host.
31
+ - Two of its subheadings are renamed: "Which Flair may theme the page" is now "Which hosts may theme the page", and "Flair's side: `preview-host.js`" is now "The host's side: `preview-host.js`".
32
+ - The Playwright recipe's host address is now `HOST`, on `http://localhost:4330`, instead of `FLAIR`, on `http://localhost:4317`. Both are allowed, so a test copied from beta.0's recipe still runs.
33
+
5
34
  ## 0.2.0-beta.0
6
35
 
7
36
  A beta, published under npm's `next` tag. `latest` stays at 0.1.0 until 0.2.0.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # flair-kit
2
2
 
3
- Published on npm as `@flairstudio/kit`. Design tokens as plain CSS: colours with light and dark modes, spacing, type sizes, radius, layers, motion and fonts. No build step is needed to use them. The colour names are the ones the Flair Design theme tool uses.
3
+ Published on npm as `@flairstudio/kit`. Design tokens as plain CSS: colours with light and dark modes, spacing, type sizes, radius, layers, motion and fonts. No build step is needed to use them. The colour names are the ones the Flair Design theme tool uses. `tokens.css` opens with the order of its cascade layers, `@layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;`, and puts every token in the first (see "A site's palette and overrides").
4
4
  - A Flair theme exported in the `data-theme` style becomes a site's palette file once it sits inside the palette layer (see below). Until Flair's Export writes that wrapper, add it by hand.
5
5
  - Flair's `light-dark()` export can't be used that way, because it can't follow `data-theme`.
6
6
 
@@ -9,7 +9,7 @@ Every token is listed in `TOKENS.md`, which ships in the package.
9
9
  ## Use it in a site with a build
10
10
 
11
11
  ```sh
12
- npm install @flairstudio/kit@0.2.0-beta.0 --save-exact
12
+ npm install @flairstudio/kit@0.2.0-beta.2 --save-exact
13
13
  ```
14
14
 
15
15
  Import in this order:
@@ -41,7 +41,7 @@ Line 1 of each generated file names its version, `/* flair-kit <version> · …
41
41
 
42
42
  The package's colours are a default. A site's palette file replaces them, and it must:
43
43
 
44
- - **open with the layer order line, then put everything inside `@layer flair-kit.palette { … }`.** The line fixes the order of the layers whichever CSS file the browser reads first, so the palette beats the package's defaults even if it loads before `tokens.css`. The layer lets Flair's preview beat the palette while it shows the page (see "Showing a site in Flair").
44
+ - **open with the layer order line, then put everything inside `@layer flair-kit.palette { … }`.** The line fixes the order of the layers whichever CSS file the browser reads first, so the palette beats the package's defaults even if it loads before `tokens.css`. The layer lets the preview beat the palette while a host shows the page (see "Showing a site in Flair").
45
45
  - **use the same three selectors as `tokens.css`, in this order.** The dark block must come after the light one, or `data-theme="dark"` on `<html>` stops working:
46
46
 
47
47
  ```css
@@ -60,18 +60,22 @@ The package's colours are a default. A site's palette file replaces them, and it
60
60
  ```
61
61
 
62
62
  - **set every colour in both modes.** A colour the file leaves out falls back to the package's default. `tokens.json` lists them all under `colors.names`, so a site test can check its palette covers them.
63
- - **set colours only on `:root` and on elements with `data-theme`.** A palette may use stronger selectors, such as `#page[data-palette][data-theme]`, as long as the element carries `data-theme`. A colour set on any other element, such as `body` or `.page`, isn't reached by Flair's preview: the element keeps the palette's value instead of inheriting Flair's.
63
+ - **set colours only on `:root` and on elements with `data-theme`.** A palette may use stronger selectors, such as `#page[data-palette][data-theme]`, as long as the element carries `data-theme`. A colour set on any other element, such as `body` or `.page`, isn't reached by the preview: the element keeps the palette's value instead of inheriting the preview's.
64
64
 
65
- A palette left outside the layer still works on the site, but in Flair it beats the preview, so the page doesn't change as the theme is edited.
65
+ A palette left outside the layer still works on the site, but in the host's frame it beats the preview, so the page doesn't change as the theme is edited.
66
66
 
67
67
  Override a colour with those same three selectors. A colour set only on `:root` behaves differently:
68
68
  - it applies to the page in every mode, so a value chosen for light mode also shows in dark mode;
69
69
  - it misses every element with its own `data-theme`;
70
70
  - alongside a palette file, `data-theme="dark"` on `<html>` picks it up, but the system's dark mode doesn't.
71
71
 
72
+ `tokens.css` writes every colour as `color(srgb R G B)`, each channel from 0 to 1, and the preview writes a host's colours the same way. Browsers fade a hex or `rgb()` colour through gamma-encoded sRGB, so a fade between distant hues dips through dark grey. Chrome and Safari fade a `color(srgb …)` value in Oklab, which keeps its lightness. Firefox, checked in 159, fades it through sRGB as it does hex, so there the dip stays. A palette file may still write hex, but write `color(srgb …)` for a fade between themes that keeps its lightness in Chrome and Safari. `color()` needs Chrome 111, Firefox 113 or Safari 15; an older browser drops the colours. The package's default colours, and the colours a host sends, read back as `color(srgb …)` when computed, not `rgb(…)`, so a test that compares them should use that form. So should a script that reads a token with `getComputedStyle` and passes it to a colour parser: some parsers read `rgb(…)` but not `color(…)`. A palette written in hex still reads back as `rgb(…)`.
73
+
74
+ Labels on a primary fill take `--color-on-primary`, and in a Flair theme that can be dark: the package's default theme has a primary of `#0d9488` with a black `on-primary` (5.61:1), where white would be 3.74:1. A site that forces white labels on primary, or shades a primary fill toward black, fails contrast under such a theme. Use `--color-on-primary` for the label and `--color-primary` for the fill, and test the site under the default theme.
75
+
72
76
  Check colour values carefully. The colours are registered as `<color>`, so a misspelt value (`#1f2a3`, `banana`) doesn't fail loudly. The element quietly takes its parent's colour instead, which inside a `data-theme` region can mean a light colour in a dark region.
73
77
 
74
- Every token declaration in the package sits in the `flair-kit.tokens` cascade layer. The `@property` registrations in `tokens.css` and the `@font-face` rules in `fonts.css` sit outside it by design, because neither needs overriding. A site's own CSS outside a layer always wins, whatever its selectors, so no override needs `!important`, and overrides stay outside a layer. From lowest to highest, the order is the package's defaults, the site's palette, components, Flair's preview, then the site's unlayered CSS:
78
+ Every token declaration in the package sits in the `flair-kit.tokens` cascade layer. The `@property` registrations in `tokens.css` and the `@font-face` rules in `fonts.css` sit outside it by design, because neither needs overriding. A site's own CSS outside a layer always wins, whatever its selectors, so no override needs `!important`, and overrides stay outside a layer. From lowest to highest, the order is the package's defaults, the site's palette, components, the preview, then the site's unlayered CSS:
75
79
 
76
80
  ```css
77
81
  @layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;
@@ -89,7 +93,7 @@ The package adds no transitions. `--dur-theme` is there for a site that fades be
89
93
 
90
94
  ## Showing a site in Flair
91
95
 
92
- Flair Design can show a site's real page in a frame, wearing the theme being edited, and follow every change live. The page needs the listener, `preview.js`, from this package. It loads only inside a frame, so visitors never download it.
96
+ FlairDesigner can show a site's real page in a frame, wearing the theme being edited, and follow every change live. This section calls it the host: any app that frames the page and sends it themes with `preview-host.js`. The page needs the listener, `preview.js`, from this package. It loads only inside a frame, so visitors never download it.
93
97
 
94
98
  ### Load the listener
95
99
 
@@ -109,32 +113,40 @@ A site without a build, with `dist/` copied to `assets/flair-kit/`, after its st
109
113
  </script>
110
114
  ```
111
115
 
112
- Outside a frame, `listen()` does nothing. Calling it again while it runs changes nothing, and it returns a function that stops it.
116
+ Outside a frame, `listen()` adds no listener and sends nothing, though it still checks its `allow` list (see below). Calling it again while it runs changes nothing, and it returns a function that stops it.
113
117
 
114
- ### Which Flair may theme the page
118
+ ### Which hosts may theme the page
115
119
 
116
- `listen()` takes themes only from Flair's own local addresses, `http://localhost:3000` (its dev server) and `http://localhost:4317` (its tests), which it exports as `DEFAULT_ALLOW`. Pass `allow` to replace the list, or spread the default to add to it:
120
+ `listen()` takes themes only from the hosts' own local addresses, which it exports as `DEFAULT_ALLOW`:
121
+ - `http://localhost:3000` and `http://localhost:4317`: Flair Design's dev server and its tests;
122
+ - `http://localhost:3300` and `http://localhost:4330`: the same for FlairDesigner.
123
+
124
+ Pass `allow` to replace the list, or spread the default to add to it:
117
125
 
118
126
  ```js
119
127
  import('@flairstudio/kit/preview.js').then(({ listen, DEFAULT_ALLOW }) =>
120
128
  listen({ allow: [...DEFAULT_ALLOW, 'https://flair.example'] }));
121
129
  ```
122
130
 
123
- Addresses must match exactly: `http://127.0.0.1:3000` isn't `http://localhost:3000`. A message from any other address, or from a window that isn't the page's parent, is ignored without a word. Only colour names the package knows and `#rrggbb` values get through, so a message can't add any other CSS.
131
+ `allow` is a list, even of one address. `listen()` checks it first, framed or not, and throws a `TypeError` on a string, an empty list, or an address that isn't `http` or `https`. A second `listen()` while one runs keeps the first list: if its own `allow` holds other origins, it logs a console warning that the first list stands.
132
+
133
+ Addresses must match exactly: `http://127.0.0.1:3300` isn't `http://localhost:3300`. A message from any other address, or from a window that isn't the page's parent, is ignored without a word. So is a message from the host that isn't flair-kit's, one whose `type` doesn't start with `flair-kit:`, such as a browser extension's. Only colour names the package knows and `#rrggbb` values get through, so a message can't add any other CSS.
134
+
135
+ When it starts, the listener tells the page's parent it's ready. Current Chrome, Safari and Firefox name the parent's origin (`location.ancestorOrigins`), so there it sends to that origin alone, or to none if the origin isn't allowed. Where the browser doesn't name the parent, or names it `"null"` (Firefox does when the frame has `referrerpolicy="no-referrer"`), the listener sends to each allowed address, and the browser drops the ones that don't match. A browser may log a console warning for each one it drops.
124
136
 
125
137
  ### What the listener changes
126
138
 
127
- Only these, and only once Flair has sent a theme:
139
+ Only these, and only once the host has sent a theme:
128
140
  - its own `<style>`, in the `flair-kit.preview` layer, which beats the site's palette but not its unlayered overrides;
129
- - `data-theme` on `<html>`, set to the mode chosen in Flair;
141
+ - `data-theme` on `<html>`, set to the mode chosen in the host;
130
142
  - `data-flair-preview` on `<html>`, set with the first theme;
131
143
  - an inline `--dur-theme` on `<html>`: `0.01ms` for the first theme and while a colour is being dragged, so nothing fades.
132
144
 
133
- The preview beats the palette only when the palette sits in its layer (see "A site's palette and overrides"). If a router or hydration rebuilds `<head>`, the listener puts its `<style>` back with the next theme. A Content Security Policy whose `style-src` doesn't allow inline styles blocks that `<style>`, so the page keeps its own colours in Flair. Allow inline styles on the pages Flair frames.
145
+ The preview beats the palette only when the palette sits in its layer (see "A site's palette and overrides"). If a router or hydration rebuilds `<head>`, the listener puts its `<style>` back with the next theme. A Content Security Policy whose `style-src` doesn't allow inline styles blocks that `<style>`, so the page keeps its own colours in the host's frame. Allow inline styles on the pages a host frames.
134
146
 
135
147
  ### Review tools step aside
136
148
 
137
- A site's own review tools, such as a theme switcher, notes or a palette menu, would fight Flair's. Hide them under the attribute:
149
+ A site's own review tools, such as a theme switcher, notes or a palette menu, would fight the host's. Hide them under the attribute:
138
150
 
139
151
  ```css
140
152
  [data-flair-preview] .review-tools { display: none; }
@@ -148,16 +160,16 @@ document.addEventListener('flair-kit:preview', (event) => {
148
160
  });
149
161
  ```
150
162
 
151
- Flair shows the page once the listeners have run and two frames have been drawn, so a change made in the handler is in place by then.
163
+ The event fires once the theme is written, and the listeners run before the listener starts waiting to send `applied`. The host shows the page on `applied`, which comes after two animation frames, or after 500ms if the browser holds frames back, so a change made in the handler is in place by then, though the frame may not have drawn it yet (see "Testing a site's pages with a Flair theme").
152
164
 
153
165
  ### Two rules
154
166
 
155
- - **Flair sets the mode on `<html>`, and an element with its own `data-theme` keeps it.** So a page root that sets its own `data-theme`, such as `#page`, copies `event.detail.mode` into it on every event. Regions that always stay one mode keep theirs.
167
+ - **The host sets the mode on `<html>`, and an element with its own `data-theme` keeps it.** So a page root that sets its own `data-theme`, such as `#page`, copies `event.detail.mode` into it on every event. Regions that always stay one mode keep theirs.
156
168
  - **Set `--dur-theme` on `:root` only.** The listener's inline value on `<html>` beats it there. A value set on another element would bring the fade back during a drag.
157
169
 
158
- ### Flair's side: `preview-host.js`
170
+ ### The host's side: `preview-host.js`
159
171
 
160
- Flair sends themes with `preview-host.js`, and a site's tests can too:
172
+ The host sends themes with `preview-host.js`, and a site's tests can too:
161
173
 
162
174
  ```js
163
175
  import { connect } from '@flairstudio/kit/preview-host.js';
@@ -165,7 +177,7 @@ import { connect } from '@flairstudio/kit/preview-host.js';
165
177
  const { send, close } = connect(iframe, {
166
178
  origin: 'http://localhost:5173', // the site's address
167
179
  onReady: ({ kit, names }) => {}, // the frame's package version and colour names
168
- onApplied: () => {}, // the theme is on: the frame is ready to be seen
180
+ onApplied: () => {}, // the theme is written; the frame may not have drawn it yet
169
181
  onRefused: (reason) => {}, // a short code, such as 'value'
170
182
  onMismatch: ({ host, frame }) => {}, // the frame speaks another format version
171
183
  });
@@ -176,15 +188,15 @@ send({ light, dark, mode: 'light', angle: 110, instant: false });
176
188
 
177
189
  ### Testing a site's pages with a Flair theme
178
190
 
179
- A site's Playwright tests can put a theme on its pages without Flair running. The test answers an allowed address itself with `page.route`, serving a small host page and the two scripts. The site's own server serves the page under test.
191
+ A site's Playwright tests can put a theme on its pages without the host running. The test answers an allowed address itself with `page.route`, serving a small host page and the two scripts. The site's own server serves the page under test.
180
192
 
181
193
  ```js
182
194
  import { test, expect } from '@playwright/test';
183
195
  import { createRequire } from 'node:module';
184
196
  import { dirname, join } from 'node:path';
185
197
 
186
- const FLAIR = 'http://localhost:4317'; // an allowed address; nothing needs to run there
187
- const SITE = 'http://localhost:5173/'; // the page under test
198
+ const HOST = 'http://localhost:4330'; // an allowed address; nothing needs to run there
199
+ const SITE = 'http://localhost:5173/'; // the page under test: change it to your site's own address
188
200
  const require = createRequire(import.meta.url);
189
201
  const dist = dirname(require.resolve('@flairstudio/kit/preview-host.js'));
190
202
  // The package's default palette; use a Flair export's values to test a real theme
@@ -203,21 +215,32 @@ const HOST_PAGE = `<!doctype html>
203
215
  });
204
216
  </script>`;
205
217
 
206
- test('the home page wears a Flair theme', async ({ page }) => {
207
- await page.route(`${FLAIR}/**`, (route) => {
218
+ test('the home page wears a Flair theme', async ({ page, browserName }) => {
219
+ // Chromium's Local Network Access check blocks the framed site without this; WebKit doesn't know the permission
220
+ if (browserName === 'chromium') await page.context().grantPermissions(['local-network-access']);
221
+ await page.route(`${HOST}/**`, (route) => {
208
222
  const { pathname } = new URL(route.request().url());
209
223
  if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: HOST_PAGE });
210
224
  return route.fulfill({ path: join(dist, pathname.slice(1)) }); // preview-host.js, and the preview.js it imports
211
225
  });
212
- await page.goto(`${FLAIR}/`);
226
+ await page.goto(`${HOST}/`);
213
227
  await page.evaluate((theme) => window.flairKit.host.send(theme), { light, dark, mode: 'dark', angle: 110 });
214
228
  await expect.poll(() => page.evaluate(() => window.flairKit.applied)).toBeGreaterThan(0);
215
229
  const site = page.frameLocator('iframe');
216
- // check the site's page through `site`
230
+ // `applied` can come before the frame has drawn the theme (see below), so let it draw two frames first
231
+ await site.locator('html').evaluate(
232
+ () => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))),
233
+ );
234
+ await expect(site.locator('html')).toHaveAttribute('data-theme', 'dark');
235
+ // check the rest of the site's page through `site`
217
236
  });
218
237
  ```
219
238
 
220
- In a TypeScript test, `window.flairKit` needs a cast inside `page.evaluate`, such as `(window as any).flairKit`.
239
+ The `grantPermissions` line is there because the host page comes from `page.route`, so Chromium treats it as a page from outside the local network, and blocks its frame on `localhost`. Without it, the frame shows Chromium's error page and the test fails waiting for `applied`. To grant it for every test instead, add `permissions: ['local-network-access']` to the `use` of the Chromium project in `playwright.config`. Don't add it to the other projects: WebKit throws on a permission it doesn't know.
240
+
241
+ The two-frame wait is there because `applied` means the theme is written, not that the frame has drawn it. The listener sends `applied` after two animation frames, or after 500ms if the browser holds frames back, and a young frame under load can draw nothing for longer than that. Then the theme's colour transitions are still pending, and a page read straight after `applied` shows the site's own palette. Wait two animation frames inside the frame, as above, before checking colours.
242
+
243
+ In a TypeScript test, `window.flairKit` needs a cast in the two `page.evaluate` lines, such as `(window as any).flairKit`. The `window.flairKit` in `HOST_PAGE` is browser code in a string, so it needs none. Lint rules such as Biome's `noExplicitAny` warn on `as any`.
221
244
 
222
245
  ## Versions
223
246
 
package/TOKENS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # flair-kit tokens
2
2
 
3
- Version 0.2.0-beta.0. Colours change with the mode; everything else stays the same in light and dark.
3
+ Version 0.2.0-beta.2. Colours change with the mode; everything else stays the same in light and dark.
4
4
 
5
5
  ## Colours
6
6
 
package/dist/fonts.css CHANGED
@@ -1,4 +1,4 @@
1
- /* flair-kit 0.2.0-beta.0 · generated from src/tokens.ts · do not edit */
1
+ /* flair-kit 0.2.0-beta.2 · generated from src/tokens.ts · do not edit */
2
2
 
3
3
  @font-face {
4
4
  font-family: Inter;
@@ -1,11 +1,11 @@
1
- /* flair-kit 0.2.0-beta.0 · generated from src/tokens.ts · do not edit */
1
+ /* flair-kit 0.2.0-beta.2 · generated from src/tokens.ts · do not edit */
2
2
 
3
3
  import type { Colors, Mode } from './preview.js';
4
4
 
5
5
  export { COLOR_NAMES, FORMAT_VERSION, KIT_VERSION } from './preview.js';
6
6
  export type { ColorName, Colors, Mode, Reason } from './preview.js';
7
7
 
8
- /** A theme as Flair sends it: both modes' colours, the canvas mode, the gradient angle, and whether a drag is under way */
8
+ /** A theme as the host sends it: both modes' colours, the canvas mode, the gradient angle, and whether a drag is under way */
9
9
  export interface Theme {
10
10
  readonly light: Colors;
11
11
  readonly dark: Colors;
@@ -22,7 +22,7 @@ export interface ConnectOptions {
22
22
  readonly origin: string;
23
23
  /** The frame is listening: its package version and the colour names it accepts */
24
24
  readonly onReady?: (info: ReadyInfo) => void;
25
- /** The frame has put the theme on and is ready to be seen */
25
+ /** The theme is written; the frame may not have drawn it yet (after two frames, or 500ms) */
26
26
  readonly onApplied?: () => void;
27
27
  /** The frame refused the theme, or shares no colour names with it ("name") */
28
28
  readonly onRefused?: (reason: string) => void;
@@ -31,9 +31,9 @@ export interface ConnectOptions {
31
31
  }
32
32
  export interface Connection {
33
33
  /** Checks the theme, keeps it, and sends it now and whenever the frame says ready again. Throws a TypeError on a theme the frame would refuse */
34
- send(theme: Theme): void;
34
+ send: (theme: Theme) => void;
35
35
  /** Stops listening to the frame */
36
- close(): void;
36
+ close: () => void;
37
37
  }
38
38
  /** Connects to the page in an <iframe> of a site */
39
39
  export declare function connect(frame: HTMLIFrameElement, options: ConnectOptions): Connection;
@@ -1,7 +1,7 @@
1
- /* flair-kit 0.2.0-beta.0 · generated from src/preview-host.js · do not edit */
1
+ /* flair-kit 0.2.0-beta.2 · generated from src/preview-host.js · do not edit */
2
2
 
3
- // Flair's side of the preview: frames a site's page and sends it the theme being edited. A site's own tests use
4
- // it too, to put a Flair theme on their pages without Flair running. The names and the checks come from
3
+ // The host's side of the preview: frames a site's page and sends it the theme being edited. A site's own tests use
4
+ // it too, to put a Flair theme on their pages without the host running. The names and the checks come from
5
5
  // ./preview.js, so both sides of the format are written once.
6
6
  import { COLOR_NAMES, FORMAT_VERSION, KIT_VERSION, MESSAGE_TYPES, checkTheme } from './preview.js';
7
7
 
package/dist/preview.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* flair-kit 0.2.0-beta.0 · generated from src/tokens.ts · do not edit */
1
+ /* flair-kit 0.2.0-beta.2 · generated from src/tokens.ts · do not edit */
2
2
 
3
3
  /** The package version this listener came from */
4
4
  export declare const KIT_VERSION: string;
@@ -10,8 +10,8 @@ export declare const COLOR_NAMES: readonly ["background","card","muted","seconda
10
10
  export type ColorName = (typeof COLOR_NAMES)[number];
11
11
  /** A colour mode */
12
12
  export type Mode = 'light' | 'dark';
13
- /** The Flair addresses listen() allows when it's given no list: Flair's dev server and its tests */
14
- export declare const DEFAULT_ALLOW: readonly ["http://localhost:3000","http://localhost:4317"];
13
+ /** The host addresses listen() allows when it's given no list: Flair Design's dev server and tests, then FlairDesigner's */
14
+ export declare const DEFAULT_ALLOW: readonly ["http://localhost:3000","http://localhost:4317","http://localhost:3300","http://localhost:4330"];
15
15
  /** The type of each message in the format */
16
16
  export declare const MESSAGE_TYPES: { readonly ready: "flair-kit:ready"; readonly hello: "flair-kit:hello"; readonly theme: "flair-kit:theme"; readonly applied: "flair-kit:applied"; readonly refused: "flair-kit:refused"; };
17
17
  /** Why a theme was refused. A refusal never echoes the values it was sent */
@@ -22,10 +22,10 @@ export type Colors = { readonly [N in ColorName]?: string };
22
22
  export interface PreviewEventDetail { readonly mode: Mode; readonly first: boolean }
23
23
  /** Options for listen() */
24
24
  export interface ListenOptions {
25
- /** The Flair addresses that may theme the page, as origins or page addresses. It replaces DEFAULT_ALLOW */
25
+ /** The host addresses that may theme the page, as origins or page addresses. It replaces DEFAULT_ALLOW. A string, an empty list or an address that isn't http or https throws a TypeError, framed or not */
26
26
  readonly allow?: readonly string[];
27
27
  }
28
- /** Starts listening for Flair if the page is in a frame, and returns a function that stops it. A second call while it runs returns the same function */
28
+ /** Starts listening for the host if the page is in a frame, and returns a function that stops it. A second call while it runs returns the same function and changes nothing; if its allow list differs, it logs a warning that the first stands */
29
29
  export declare function listen(options?: ListenOptions): () => void;
30
30
  /** Checks a theme's mode, angle and colours against `names`: the first reason it fails, or null. Never throws */
31
31
  export declare function checkTheme(theme: unknown, names: readonly string[]): Reason | null;
package/dist/preview.js CHANGED
@@ -1,24 +1,31 @@
1
- /* flair-kit 0.2.0-beta.0 · generated from src/preview.js and src/tokens.ts · do not edit */
1
+ /* flair-kit 0.2.0-beta.2 · generated from src/preview.js and src/tokens.ts · do not edit */
2
2
 
3
3
  // Written by the build from src/tokens.ts and src/preview-format.ts
4
- export const KIT_VERSION = "0.2.0-beta.0";
4
+ export const KIT_VERSION = "0.2.0-beta.2";
5
5
  export const FORMAT_VERSION = 1;
6
6
  export const COLOR_NAMES = Object.freeze(["background","card","muted","secondary","foreground","card-foreground","muted-foreground","on-secondary","border","outline","primary","on-primary","primary-hover","primary-pressed","primary-text","ring","tertiary","on-tertiary","accent-2","glow","destructive","on-destructive","chart-1","chart-2","chart-3","chart-4","brand","gradient-1","gradient-2","gradient-3"]);
7
- export const DEFAULT_ALLOW = Object.freeze(["http://localhost:3000","http://localhost:4317"]);
7
+ export const DEFAULT_ALLOW = Object.freeze(["http://localhost:3000","http://localhost:4317","http://localhost:3300","http://localhost:4330"]);
8
8
  export const MESSAGE_TYPES = Object.freeze({"ready":"flair-kit:ready","hello":"flair-kit:hello","theme":"flair-kit:theme","applied":"flair-kit:applied","refused":"flair-kit:refused"});
9
+ const MESSAGE_PREFIX = "flair-kit:";
9
10
  const LAYER_ORDER = "@layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;";
10
11
  const PREVIEW_LAYER = "flair-kit.preview";
12
+ const THEME_SELECTORS = Object.freeze({"light":[":root","[data-theme=\"light\"]"],"dark":["[data-theme=\"dark\"]"],"systemMedia":"(prefers-color-scheme: dark)","systemDark":[":root:not([data-theme=\"light\"])"]});
13
+ const COLOR_PREFIX = "--color-";
14
+ const GRADIENT_ANGLE = "--gradient-angle";
15
+ const THEME_FADE = "--dur-theme";
16
+ const HOLD = "0.01ms";
17
+ const PREVIEW_EVENT = "flair-kit:preview";
18
+ const PREVIEW_ATTRIBUTE = "data-flair-preview";
11
19
 
12
- // The listener that lets Flair show this page in its frame, wearing the theme being edited.
13
- // KIT_VERSION, FORMAT_VERSION, COLOR_NAMES, DEFAULT_ALLOW, MESSAGE_TYPES, LAYER_ORDER and PREVIEW_LAYER are
14
- // written above this file by the build (scripts/lib/preview.ts). Nothing here runs until listen() is called.
20
+ // The listener that lets a host, such as FlairDesigner, show this page in its frame, wearing the theme being edited.
21
+ // KIT_VERSION, FORMAT_VERSION, COLOR_NAMES, DEFAULT_ALLOW, MESSAGE_TYPES, MESSAGE_PREFIX, LAYER_ORDER, PREVIEW_LAYER,
22
+ // THEME_SELECTORS, COLOR_PREFIX, GRADIENT_ANGLE, THEME_FADE, HOLD, PREVIEW_EVENT and PREVIEW_ATTRIBUTE are written
23
+ // above this file by the build (scripts/lib/preview.ts), from the same places tokens.css and the types use.
24
+ // HOLD is reduced motion's fade: never 0s, so code waiting on a transition's end event still hears it.
25
+ // Nothing here runs until listen() is called.
15
26
 
16
27
  const HEX = /^#[0-9a-f]{6}$/i;
17
28
  const MODES = ['light', 'dark'];
18
- const EVENT = 'flair-kit:preview';
19
- const ATTRIBUTE = 'data-flair-preview';
20
- /** Never 0s, so code waiting on a transition's end event still hears it */
21
- const HOLD = '0.01ms';
22
29
  /** applied waits for two animation frames; this stands behind them in case the browser holds frames back */
23
30
  const APPLIED_FALLBACK_MS = 500;
24
31
 
@@ -27,28 +34,36 @@ const running = new WeakMap();
27
34
  /** The listener's one <style> in each document, kept across a stop() and a fresh listen() */
28
35
  const sheets = new WeakMap();
29
36
 
37
+ /**
38
+ * A checked #rrggbb, in either case, as color(srgb R G B), written as tokens.css writes its colours. Browsers fade
39
+ * hex in gamma-encoded sRGB, through dark grey between distant hues; Chrome and Safari fade color() in Oklab, which holds it.
40
+ */
41
+ function srgb(hex) {
42
+ const channel = (at) => {
43
+ const byte = Number.parseInt(hex.slice(at, at + 2), 16);
44
+ return byte === 0 ? '0' : byte === 255 ? '1' : (byte / 255).toFixed(6);
45
+ };
46
+ return `color(srgb ${channel(1)} ${channel(3)} ${channel(5)})`;
47
+ }
48
+
30
49
  /** The preview stylesheet, built only from checked names and values, in the frame's colour order */
31
50
  function stylesheet({ light, dark, angle }) {
32
51
  const names = COLOR_NAMES.filter((name) => Object.hasOwn(light, name));
33
- const colours = (values, pad) => names.map((name) => `${pad}--color-${name}: ${values[name]};`);
52
+ /** A rule: its selectors, one per line, then color-scheme, the colours and any more lines, one level in */
53
+ const block = (selectors, scheme, values, more, pad) => [
54
+ ...selectors.map((selector, i) => `${pad}${selector}${i < selectors.length - 1 ? ',' : ' {'}`),
55
+ `${pad} color-scheme: ${scheme};`,
56
+ ...names.map((name) => `${pad} ${COLOR_PREFIX}${name}: ${srgb(values[name])};`),
57
+ ...more.map((line) => `${pad} ${line}`),
58
+ `${pad}}`,
59
+ ];
34
60
  return [
35
61
  LAYER_ORDER,
36
62
  `@layer ${PREVIEW_LAYER} {`,
37
- ' :root,',
38
- ' [data-theme="light"] {',
39
- ' color-scheme: light;',
40
- ...colours(light, ' '),
41
- ` --gradient-angle: ${angle}deg;`,
42
- ' }',
43
- ' [data-theme="dark"] {',
44
- ' color-scheme: dark;',
45
- ...colours(dark, ' '),
46
- ' }',
47
- ' @media (prefers-color-scheme: dark) {',
48
- ' :root:not([data-theme="light"]) {',
49
- ' color-scheme: dark;',
50
- ...colours(dark, ' '),
51
- ' }',
63
+ ...block(THEME_SELECTORS.light, 'light', light, [`${GRADIENT_ANGLE}: ${angle}deg;`], ' '),
64
+ ...block(THEME_SELECTORS.dark, 'dark', dark, [], ' '),
65
+ ` @media ${THEME_SELECTORS.systemMedia} {`,
66
+ ...block(THEME_SELECTORS.systemDark, 'dark', dark, [], ' '),
52
67
  ' }',
53
68
  '}',
54
69
  '',
@@ -69,11 +84,28 @@ function toOrigin(address) {
69
84
  return url.origin;
70
85
  }
71
86
 
87
+ /** The allow list as origins. A string or an empty list throws, as does any address that isn't http or https */
88
+ function allowedOrigins(allow) {
89
+ if (typeof allow === 'string') {
90
+ throw new TypeError(`flair-kit: listen()'s allow is a list of addresses, not a string: write allow: [${JSON.stringify(allow)}]`);
91
+ }
92
+ const origins = [...allow].map(toOrigin);
93
+ if (origins.length === 0) throw new TypeError("flair-kit: listen()'s allow lists no addresses, so no host could theme the page");
94
+ return origins;
95
+ }
96
+
97
+ /** True when two lists of origins hold the same origins, in any order */
98
+ function sameOrigins(a, b) {
99
+ const first = new Set(a);
100
+ const second = new Set(b);
101
+ return first.size === second.size && [...first].every((origin) => second.has(origin));
102
+ }
103
+
72
104
  const isColors = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
73
105
 
74
106
  /**
75
107
  * Checks a theme's mode, angle and colours: the first reason it fails, or null. Never throws.
76
- * `names` are the colour names that may appear, without the --color- prefix.
108
+ * `names` are the colour names that may appear, without the colour prefix.
77
109
  */
78
110
  export function checkTheme(theme, names) {
79
111
  if (theme === null || typeof theme !== 'object' || !MODES.includes(theme.mode)) return 'mode';
@@ -89,9 +121,11 @@ export function checkTheme(theme, names) {
89
121
  return null;
90
122
  }
91
123
 
92
- /** Why a message from the allowed parent can't be used, or null */
124
+ /** True for an object whose type starts flair-kit:. Anything else, such as an extension's chatter, isn't ours to answer */
125
+ const isOurs = (data) => data !== null && typeof data === 'object' && typeof data.type === 'string' && data.type.startsWith(MESSAGE_PREFIX);
126
+
127
+ /** Why a flair-kit message from the allowed parent can't be used, or null */
93
128
  function messageReason(data) {
94
- if (data === null || typeof data !== 'object') return 'type';
95
129
  if (data.type !== MESSAGE_TYPES.theme && data.type !== MESSAGE_TYPES.hello) return 'type';
96
130
  if (data.v !== FORMAT_VERSION) return 'version';
97
131
  return data.type === MESSAGE_TYPES.theme ? checkTheme(data, COLOR_NAMES) : null;
@@ -100,18 +134,32 @@ function messageReason(data) {
100
134
  const readyMessage = () => ({ type: MESSAGE_TYPES.ready, v: FORMAT_VERSION, kit: KIT_VERSION, names: [...COLOR_NAMES] });
101
135
 
102
136
  /**
103
- * Starts listening for Flair, if this page is inside a frame. Returns a function that stops it.
104
- * `allow` lists the Flair addresses that may theme the page; without it, Flair's own local addresses.
105
- * Calling it again while it runs returns the same stop function and changes nothing.
137
+ * Starts listening for the host, if this page is inside a frame. Returns a function that stops it.
138
+ * `allow` lists the host addresses that may theme the page; without it, DEFAULT_ALLOW, the hosts' own local addresses.
139
+ * It's checked first, so a string, an empty list or an address that isn't http or https throws a TypeError, framed or not.
140
+ * Calling it again while it runs returns the same stop function and changes nothing. If that call's `allow` holds
141
+ * other origins than the running one's, it logs a console warning that the first list stands.
106
142
  */
107
143
  export function listen(options = {}) {
144
+ const given = options?.allow ?? null;
145
+ const allow = allowedOrigins(given ?? DEFAULT_ALLOW);
108
146
  const win = globalThis.window;
109
147
  if (!win || win.self === win.top) return () => {};
110
148
  const current = running.get(win);
111
- if (current) return current.stop;
149
+ if (current) {
150
+ if (given !== null && !sameOrigins(allow, current.allow)) {
151
+ console.warn('flair-kit: listen() is already running, so its first allow list stands and this call changed nothing');
152
+ }
153
+ return current.stop;
154
+ }
112
155
 
113
- const allow = [...(options.allow ?? DEFAULT_ALLOW)].map(toOrigin);
114
156
  const post = (message, origin) => win.parent.postMessage(message, origin);
157
+ // Current Chrome, Safari and Firefox name the parent's origin, so ready goes there alone, or nowhere if it isn't
158
+ // allowed, and no post fails with a console warning. Where it's missing, or hidden as "null" (Firefox, under
159
+ // referrerpolicy="no-referrer"), ready goes to each allowed origin.
160
+ const parentOrigin = win.location?.ancestorOrigins?.[0];
161
+ const named = typeof parentOrigin === 'string' && parentOrigin !== 'null';
162
+ const readyTo = named ? allow.filter((origin) => origin === parentOrigin).slice(0, 1) : allow;
115
163
 
116
164
  let first = true;
117
165
  /** True once the first theme has been drawn and its applied has gone. Until then every theme keeps the hold */
@@ -151,10 +199,10 @@ export function listen(options = {}) {
151
199
  sheet.textContent = stylesheet(theme);
152
200
  root.setAttribute('data-theme', theme.mode);
153
201
  // A theme that lands before the first has been drawn keeps the hold too, or the first would fade after all
154
- if (!firstDrawn || theme.instant === true) root.style.setProperty('--dur-theme', HOLD);
155
- else root.style.removeProperty('--dur-theme');
156
- if (isFirst) root.setAttribute(ATTRIBUTE, '');
157
- doc.dispatchEvent(new win.CustomEvent(EVENT, { detail: { mode: theme.mode, first: isFirst } }));
202
+ if (!firstDrawn || theme.instant === true) root.style.setProperty(THEME_FADE, HOLD);
203
+ else root.style.removeProperty(THEME_FADE);
204
+ if (isFirst) root.setAttribute(PREVIEW_ATTRIBUTE, '');
205
+ doc.dispatchEvent(new win.CustomEvent(PREVIEW_EVENT, { detail: { mode: theme.mode, first: isFirst } }));
158
206
  afterTwoFrames(() => {
159
207
  if (isFirst) firstDrawn = true;
160
208
  post({ type: MESSAGE_TYPES.applied, v: FORMAT_VERSION }, origin);
@@ -181,9 +229,10 @@ export function listen(options = {}) {
181
229
  if (!allow.includes(event.origin)) return;
182
230
  if (event.source !== win.parent) return;
183
231
  const { data } = event;
232
+ if (!isOurs(data)) return;
184
233
  const reason = messageReason(data);
185
234
  if (reason) {
186
- console.warn(`flair-kit: a preview message from Flair was refused (${reason})`);
235
+ console.warn(`flair-kit: a preview message from the host was refused (${reason})`);
187
236
  post({ type: MESSAGE_TYPES.refused, v: FORMAT_VERSION, reason }, event.origin);
188
237
  return;
189
238
  }
@@ -204,8 +253,8 @@ export function listen(options = {}) {
204
253
  if (running.get(win)?.stop === stop) running.delete(win);
205
254
  };
206
255
 
207
- running.set(win, { stop });
256
+ running.set(win, { stop, allow });
208
257
  win.addEventListener('message', onMessage);
209
- for (const origin of allow) post(readyMessage(), origin);
258
+ for (const origin of readyTo) post(readyMessage(), origin);
210
259
  return stop;
211
260
  }
package/dist/tokens.css CHANGED
@@ -1,38 +1,38 @@
1
- /* flair-kit 0.2.0-beta.0 · generated from src/tokens.ts · do not edit */
1
+ /* flair-kit 0.2.0-beta.2 · generated from src/tokens.ts · do not edit */
2
2
 
3
3
  @layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;
4
4
 
5
5
  /* Registered so colours can fade between themes; inherits: true so a data-theme region gets its own values */
6
- @property --color-background { syntax: '<color>'; inherits: true; initial-value: #f6faf9; }
7
- @property --color-card { syntax: '<color>'; inherits: true; initial-value: #ffffff; }
8
- @property --color-muted { syntax: '<color>'; inherits: true; initial-value: #ecf2f1; }
9
- @property --color-secondary { syntax: '<color>'; inherits: true; initial-value: #f0e5ed; }
10
- @property --color-foreground { syntax: '<color>'; inherits: true; initial-value: #191f1e; }
11
- @property --color-card-foreground { syntax: '<color>'; inherits: true; initial-value: #191f1e; }
12
- @property --color-muted-foreground { syntax: '<color>'; inherits: true; initial-value: #5a6563; }
13
- @property --color-on-secondary { syntax: '<color>'; inherits: true; initial-value: #6f1362; }
14
- @property --color-border { syntax: '<color>'; inherits: true; initial-value: #ced6d5; }
15
- @property --color-outline { syntax: '<color>'; inherits: true; initial-value: #727e7c; }
16
- @property --color-primary { syntax: '<color>'; inherits: true; initial-value: #0d9488; }
17
- @property --color-on-primary { syntax: '<color>'; inherits: true; initial-value: #000000; }
18
- @property --color-primary-hover { syntax: '<color>'; inherits: true; initial-value: #14a093; }
19
- @property --color-primary-pressed { syntax: '<color>'; inherits: true; initial-value: #1eab9d; }
20
- @property --color-primary-text { syntax: '<color>'; inherits: true; initial-value: #09746a; }
21
- @property --color-ring { syntax: '<color>'; inherits: true; initial-value: #09746a; }
22
- @property --color-tertiary { syntax: '<color>'; inherits: true; initial-value: #b93008; }
23
- @property --color-on-tertiary { syntax: '<color>'; inherits: true; initial-value: #ffffff; }
24
- @property --color-accent-2 { syntax: '<color>'; inherits: true; initial-value: #ec14d2; }
25
- @property --color-glow { syntax: '<color>'; inherits: true; initial-value: #f6b8a8; }
26
- @property --color-destructive { syntax: '<color>'; inherits: true; initial-value: #c6101a; }
27
- @property --color-on-destructive { syntax: '<color>'; inherits: true; initial-value: #ffffff; }
28
- @property --color-chart-1 { syntax: '<color>'; inherits: true; initial-value: #0a8b80; }
29
- @property --color-chart-2 { syntax: '<color>'; inherits: true; initial-value: #b30f9f; }
30
- @property --color-chart-3 { syntax: '<color>'; inherits: true; initial-value: #95290c; }
31
- @property --color-chart-4 { syntax: '<color>'; inherits: true; initial-value: #36403e; }
32
- @property --color-brand { syntax: '<color>'; inherits: true; initial-value: #0d9488; }
33
- @property --color-gradient-1 { syntax: '<color>'; inherits: true; initial-value: #0d9488; }
34
- @property --color-gradient-2 { syntax: '<color>'; inherits: true; initial-value: #ec14d2; }
35
- @property --color-gradient-3 { syntax: '<color>'; inherits: true; initial-value: #f6b8a8; }
6
+ @property --color-background { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.964706 0.980392 0.976471); }
7
+ @property --color-card { syntax: '<color>'; inherits: true; initial-value: color(srgb 1 1 1); }
8
+ @property --color-muted { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.925490 0.949020 0.945098); }
9
+ @property --color-secondary { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.941176 0.898039 0.929412); }
10
+ @property --color-foreground { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.098039 0.121569 0.117647); }
11
+ @property --color-card-foreground { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.098039 0.121569 0.117647); }
12
+ @property --color-muted-foreground { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.352941 0.396078 0.388235); }
13
+ @property --color-on-secondary { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.435294 0.074510 0.384314); }
14
+ @property --color-border { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.807843 0.839216 0.835294); }
15
+ @property --color-outline { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.447059 0.494118 0.486275); }
16
+ @property --color-primary { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.050980 0.580392 0.533333); }
17
+ @property --color-on-primary { syntax: '<color>'; inherits: true; initial-value: color(srgb 0 0 0); }
18
+ @property --color-primary-hover { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.078431 0.627451 0.576471); }
19
+ @property --color-primary-pressed { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.117647 0.670588 0.615686); }
20
+ @property --color-primary-text { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.035294 0.454902 0.415686); }
21
+ @property --color-ring { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.035294 0.454902 0.415686); }
22
+ @property --color-tertiary { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.725490 0.188235 0.031373); }
23
+ @property --color-on-tertiary { syntax: '<color>'; inherits: true; initial-value: color(srgb 1 1 1); }
24
+ @property --color-accent-2 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.925490 0.078431 0.823529); }
25
+ @property --color-glow { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.964706 0.721569 0.658824); }
26
+ @property --color-destructive { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.776471 0.062745 0.101961); }
27
+ @property --color-on-destructive { syntax: '<color>'; inherits: true; initial-value: color(srgb 1 1 1); }
28
+ @property --color-chart-1 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.039216 0.545098 0.501961); }
29
+ @property --color-chart-2 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.701961 0.058824 0.623529); }
30
+ @property --color-chart-3 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.584314 0.160784 0.047059); }
31
+ @property --color-chart-4 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.211765 0.250980 0.243137); }
32
+ @property --color-brand { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.050980 0.580392 0.533333); }
33
+ @property --color-gradient-1 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.050980 0.580392 0.533333); }
34
+ @property --color-gradient-2 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.925490 0.078431 0.823529); }
35
+ @property --color-gradient-3 { syntax: '<color>'; inherits: true; initial-value: color(srgb 0.964706 0.721569 0.658824); }
36
36
 
37
37
  @layer flair-kit.tokens {
38
38
  :root {
@@ -81,107 +81,107 @@
81
81
  :root,
82
82
  [data-theme="light"] {
83
83
  color-scheme: light;
84
- --color-background: #f6faf9;
85
- --color-card: #ffffff;
86
- --color-muted: #ecf2f1;
87
- --color-secondary: #f0e5ed;
88
- --color-foreground: #191f1e;
89
- --color-card-foreground: #191f1e;
90
- --color-muted-foreground: #5a6563;
91
- --color-on-secondary: #6f1362;
92
- --color-border: #ced6d5;
93
- --color-outline: #727e7c;
94
- --color-primary: #0d9488;
95
- --color-on-primary: #000000;
96
- --color-primary-hover: #14a093;
97
- --color-primary-pressed: #1eab9d;
98
- --color-primary-text: #09746a;
99
- --color-ring: #09746a;
100
- --color-tertiary: #b93008;
101
- --color-on-tertiary: #ffffff;
102
- --color-accent-2: #ec14d2;
103
- --color-glow: #f6b8a8;
104
- --color-destructive: #c6101a;
105
- --color-on-destructive: #ffffff;
106
- --color-chart-1: #0a8b80;
107
- --color-chart-2: #b30f9f;
108
- --color-chart-3: #95290c;
109
- --color-chart-4: #36403e;
110
- --color-brand: #0d9488;
111
- --color-gradient-1: #0d9488;
112
- --color-gradient-2: #ec14d2;
113
- --color-gradient-3: #f6b8a8;
84
+ --color-background: color(srgb 0.964706 0.980392 0.976471);
85
+ --color-card: color(srgb 1 1 1);
86
+ --color-muted: color(srgb 0.925490 0.949020 0.945098);
87
+ --color-secondary: color(srgb 0.941176 0.898039 0.929412);
88
+ --color-foreground: color(srgb 0.098039 0.121569 0.117647);
89
+ --color-card-foreground: color(srgb 0.098039 0.121569 0.117647);
90
+ --color-muted-foreground: color(srgb 0.352941 0.396078 0.388235);
91
+ --color-on-secondary: color(srgb 0.435294 0.074510 0.384314);
92
+ --color-border: color(srgb 0.807843 0.839216 0.835294);
93
+ --color-outline: color(srgb 0.447059 0.494118 0.486275);
94
+ --color-primary: color(srgb 0.050980 0.580392 0.533333);
95
+ --color-on-primary: color(srgb 0 0 0);
96
+ --color-primary-hover: color(srgb 0.078431 0.627451 0.576471);
97
+ --color-primary-pressed: color(srgb 0.117647 0.670588 0.615686);
98
+ --color-primary-text: color(srgb 0.035294 0.454902 0.415686);
99
+ --color-ring: color(srgb 0.035294 0.454902 0.415686);
100
+ --color-tertiary: color(srgb 0.725490 0.188235 0.031373);
101
+ --color-on-tertiary: color(srgb 1 1 1);
102
+ --color-accent-2: color(srgb 0.925490 0.078431 0.823529);
103
+ --color-glow: color(srgb 0.964706 0.721569 0.658824);
104
+ --color-destructive: color(srgb 0.776471 0.062745 0.101961);
105
+ --color-on-destructive: color(srgb 1 1 1);
106
+ --color-chart-1: color(srgb 0.039216 0.545098 0.501961);
107
+ --color-chart-2: color(srgb 0.701961 0.058824 0.623529);
108
+ --color-chart-3: color(srgb 0.584314 0.160784 0.047059);
109
+ --color-chart-4: color(srgb 0.211765 0.250980 0.243137);
110
+ --color-brand: color(srgb 0.050980 0.580392 0.533333);
111
+ --color-gradient-1: color(srgb 0.050980 0.580392 0.533333);
112
+ --color-gradient-2: color(srgb 0.925490 0.078431 0.823529);
113
+ --color-gradient-3: color(srgb 0.964706 0.721569 0.658824);
114
114
  --gradient-angle: 110deg;
115
115
  }
116
116
 
117
117
  [data-theme="dark"] {
118
118
  color-scheme: dark;
119
- --color-background: #101413;
120
- --color-card: #191f1e;
121
- --color-muted: #262d2c;
122
- --color-secondary: #583050;
123
- --color-foreground: #edf1f0;
124
- --color-card-foreground: #edf1f0;
125
- --color-muted-foreground: #b1bbb9;
126
- --color-on-secondary: #f7e2f2;
127
- --color-border: #485250;
128
- --color-outline: #929e9c;
129
- --color-primary: #0d9488;
130
- --color-on-primary: #000000;
131
- --color-primary-hover: #14a093;
132
- --color-primary-pressed: #1eab9d;
133
- --color-primary-text: #30bdaf;
134
- --color-ring: #30bdaf;
135
- --color-tertiary: #f6a48f;
136
- --color-on-tertiary: #000000;
137
- --color-accent-2: #ed13d2;
138
- --color-glow: #f6b8a8;
139
- --color-destructive: #f7a39a;
140
- --color-on-destructive: #000000;
141
- --color-chart-1: #20aea0;
142
- --color-chart-2: #f799e3;
143
- --color-chart-3: #f5cbc0;
144
- --color-chart-4: #727f7d;
145
- --color-brand: #0d9488;
146
- --color-gradient-1: #0d9488;
147
- --color-gradient-2: #ed13d2;
148
- --color-gradient-3: #f6b8a8;
119
+ --color-background: color(srgb 0.062745 0.078431 0.074510);
120
+ --color-card: color(srgb 0.098039 0.121569 0.117647);
121
+ --color-muted: color(srgb 0.149020 0.176471 0.172549);
122
+ --color-secondary: color(srgb 0.345098 0.188235 0.313725);
123
+ --color-foreground: color(srgb 0.929412 0.945098 0.941176);
124
+ --color-card-foreground: color(srgb 0.929412 0.945098 0.941176);
125
+ --color-muted-foreground: color(srgb 0.694118 0.733333 0.725490);
126
+ --color-on-secondary: color(srgb 0.968627 0.886275 0.949020);
127
+ --color-border: color(srgb 0.282353 0.321569 0.313725);
128
+ --color-outline: color(srgb 0.572549 0.619608 0.611765);
129
+ --color-primary: color(srgb 0.050980 0.580392 0.533333);
130
+ --color-on-primary: color(srgb 0 0 0);
131
+ --color-primary-hover: color(srgb 0.078431 0.627451 0.576471);
132
+ --color-primary-pressed: color(srgb 0.117647 0.670588 0.615686);
133
+ --color-primary-text: color(srgb 0.188235 0.741176 0.686275);
134
+ --color-ring: color(srgb 0.188235 0.741176 0.686275);
135
+ --color-tertiary: color(srgb 0.964706 0.643137 0.560784);
136
+ --color-on-tertiary: color(srgb 0 0 0);
137
+ --color-accent-2: color(srgb 0.929412 0.074510 0.823529);
138
+ --color-glow: color(srgb 0.964706 0.721569 0.658824);
139
+ --color-destructive: color(srgb 0.968627 0.639216 0.603922);
140
+ --color-on-destructive: color(srgb 0 0 0);
141
+ --color-chart-1: color(srgb 0.125490 0.682353 0.627451);
142
+ --color-chart-2: color(srgb 0.968627 0.600000 0.890196);
143
+ --color-chart-3: color(srgb 0.960784 0.796078 0.752941);
144
+ --color-chart-4: color(srgb 0.447059 0.498039 0.490196);
145
+ --color-brand: color(srgb 0.050980 0.580392 0.533333);
146
+ --color-gradient-1: color(srgb 0.050980 0.580392 0.533333);
147
+ --color-gradient-2: color(srgb 0.929412 0.074510 0.823529);
148
+ --color-gradient-3: color(srgb 0.964706 0.721569 0.658824);
149
149
  }
150
150
 
151
151
  /* No data-theme attribute: follow the system */
152
152
  @media (prefers-color-scheme: dark) {
153
153
  :root:not([data-theme="light"]) {
154
154
  color-scheme: dark;
155
- --color-background: #101413;
156
- --color-card: #191f1e;
157
- --color-muted: #262d2c;
158
- --color-secondary: #583050;
159
- --color-foreground: #edf1f0;
160
- --color-card-foreground: #edf1f0;
161
- --color-muted-foreground: #b1bbb9;
162
- --color-on-secondary: #f7e2f2;
163
- --color-border: #485250;
164
- --color-outline: #929e9c;
165
- --color-primary: #0d9488;
166
- --color-on-primary: #000000;
167
- --color-primary-hover: #14a093;
168
- --color-primary-pressed: #1eab9d;
169
- --color-primary-text: #30bdaf;
170
- --color-ring: #30bdaf;
171
- --color-tertiary: #f6a48f;
172
- --color-on-tertiary: #000000;
173
- --color-accent-2: #ed13d2;
174
- --color-glow: #f6b8a8;
175
- --color-destructive: #f7a39a;
176
- --color-on-destructive: #000000;
177
- --color-chart-1: #20aea0;
178
- --color-chart-2: #f799e3;
179
- --color-chart-3: #f5cbc0;
180
- --color-chart-4: #727f7d;
181
- --color-brand: #0d9488;
182
- --color-gradient-1: #0d9488;
183
- --color-gradient-2: #ed13d2;
184
- --color-gradient-3: #f6b8a8;
155
+ --color-background: color(srgb 0.062745 0.078431 0.074510);
156
+ --color-card: color(srgb 0.098039 0.121569 0.117647);
157
+ --color-muted: color(srgb 0.149020 0.176471 0.172549);
158
+ --color-secondary: color(srgb 0.345098 0.188235 0.313725);
159
+ --color-foreground: color(srgb 0.929412 0.945098 0.941176);
160
+ --color-card-foreground: color(srgb 0.929412 0.945098 0.941176);
161
+ --color-muted-foreground: color(srgb 0.694118 0.733333 0.725490);
162
+ --color-on-secondary: color(srgb 0.968627 0.886275 0.949020);
163
+ --color-border: color(srgb 0.282353 0.321569 0.313725);
164
+ --color-outline: color(srgb 0.572549 0.619608 0.611765);
165
+ --color-primary: color(srgb 0.050980 0.580392 0.533333);
166
+ --color-on-primary: color(srgb 0 0 0);
167
+ --color-primary-hover: color(srgb 0.078431 0.627451 0.576471);
168
+ --color-primary-pressed: color(srgb 0.117647 0.670588 0.615686);
169
+ --color-primary-text: color(srgb 0.188235 0.741176 0.686275);
170
+ --color-ring: color(srgb 0.188235 0.741176 0.686275);
171
+ --color-tertiary: color(srgb 0.964706 0.643137 0.560784);
172
+ --color-on-tertiary: color(srgb 0 0 0);
173
+ --color-accent-2: color(srgb 0.929412 0.074510 0.823529);
174
+ --color-glow: color(srgb 0.964706 0.721569 0.658824);
175
+ --color-destructive: color(srgb 0.968627 0.639216 0.603922);
176
+ --color-on-destructive: color(srgb 0 0 0);
177
+ --color-chart-1: color(srgb 0.125490 0.682353 0.627451);
178
+ --color-chart-2: color(srgb 0.968627 0.600000 0.890196);
179
+ --color-chart-3: color(srgb 0.960784 0.796078 0.752941);
180
+ --color-chart-4: color(srgb 0.447059 0.498039 0.490196);
181
+ --color-brand: color(srgb 0.050980 0.580392 0.533333);
182
+ --color-gradient-1: color(srgb 0.050980 0.580392 0.533333);
183
+ --color-gradient-2: color(srgb 0.929412 0.074510 0.823529);
184
+ --color-gradient-3: color(srgb 0.964706 0.721569 0.658824);
185
185
  }
186
186
  }
187
187
 
package/dist/tokens.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.0-beta.0",
2
+ "version": "0.2.0-beta.2",
3
3
  "colors": {
4
4
  "names": [
5
5
  "background",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flairstudio/kit",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.0-beta.2",
4
4
  "description": "Design tokens as plain CSS: colours with light and dark modes, spacing, type, layers and motion.",
5
5
  "license": "MIT",
6
6
  "author": "FlairStudio",