@flairstudio/kit 0.0.0-stage → 0.2.0-beta.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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
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
+
5
+ ## 0.2.0-beta.0
6
+
7
+ A beta, published under npm's `next` tag. `latest` stays at 0.1.0 until 0.2.0.
8
+
9
+ - **Added:** `preview.js`, the listener that lets Flair Design show a site's page in its frame, wearing the theme being edited. Also `preview-host.js`, Flair's side, which a site's own tests can use too. Both ship with type declarations. See "Showing a site in Flair" in the README.
10
+ - **Added:** `layers` in `tokens.json`, and a "Cascade layers" section in `TOKENS.md`.
11
+ - **Breaking, for palettes:** the cascade layers are now `flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview`. Move the palette file's blocks inside `@layer flair-kit.palette { … }`, and open the file with the order line, so it works whatever order the CSS loads in. A palette left outside the layer still works on the site, but in Flair it beats the preview, so the page doesn't follow the theme being edited.
12
+
13
+ ## 0.1.0
14
+
15
+ First release: colour, spacing, type, radius, layer, motion, size and font tokens; light and dark modes; opt-in Inter.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FlairStudio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ The Inter font files in dist/fonts/ are not covered by this licence. They are
24
+ licensed under the SIL Open Font License 1.1; see dist/fonts/OFL.txt.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ # flair-kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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.
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
+ - Flair's `light-dark()` export can't be used that way, because it can't follow `data-theme`.
6
+
7
+ Every token is listed in `TOKENS.md`, which ships in the package.
8
+
9
+ ## Use it in a site with a build
10
+
11
+ ```sh
12
+ npm install @flairstudio/kit@0.2.0-beta.0 --save-exact
13
+ ```
14
+
15
+ Import in this order:
16
+
17
+ ```js
18
+ import '@flairstudio/kit/tokens.css'; // first
19
+ import '@flairstudio/kit/fonts.css'; // only if the site uses Inter
20
+ import './palette.css'; // the site's own palette (below)
21
+ import './site.css'; // the site's own CSS
22
+ ```
23
+
24
+ ## Use it without a build
25
+
26
+ Install it as a dev dependency, copy `node_modules/@flairstudio/kit/dist/` into the site (for example to `assets/flair-kit/`), and commit the copy. Then link it before the site's own styles:
27
+
28
+ ```html
29
+ <link rel="stylesheet" href="assets/flair-kit/tokens.css">
30
+ ```
31
+
32
+ Line 1 of each generated file names its version, `/* flair-kit <version> · … */`, so a test can check that the copy matches the installed version.
33
+
34
+ ## Light and dark
35
+
36
+ - `data-theme="light"` or `data-theme="dark"` works on any element, not only `<html>`. A region that always stays dark takes `data-theme="dark"`, and its form controls and scrollbars follow.
37
+ - With no attribute, the page follows the system setting.
38
+ - Only `light` and `dark` are values. Anything else acts like no attribute: on `<html>` the page follows the system, and on a nested element it keeps its parent's mode.
39
+
40
+ ## A site's palette and overrides
41
+
42
+ The package's colours are a default. A site's palette file replaces them, and it must:
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").
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
+
47
+ ```css
48
+ @layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;
49
+
50
+ @layer flair-kit.palette {
51
+ :root,
52
+ [data-theme="light"] { color-scheme: light; --color-background: #…; /* … */ --gradient-angle: 110deg; }
53
+
54
+ [data-theme="dark"] { color-scheme: dark; --color-background: #…; /* … */ }
55
+
56
+ @media (prefers-color-scheme: dark) {
57
+ :root:not([data-theme="light"]) { color-scheme: dark; --color-background: #…; /* … */ }
58
+ }
59
+ }
60
+ ```
61
+
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.
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.
66
+
67
+ Override a colour with those same three selectors. A colour set only on `:root` behaves differently:
68
+ - it applies to the page in every mode, so a value chosen for light mode also shows in dark mode;
69
+ - it misses every element with its own `data-theme`;
70
+ - alongside a palette file, `data-theme="dark"` on `<html>` picks it up, but the system's dark mode doesn't.
71
+
72
+ 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
+
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:
75
+
76
+ ```css
77
+ @layer flair-kit.tokens, flair-kit.palette, flair-kit.components, flair-kit.preview;
78
+ ```
79
+
80
+ A site that uses its own layers declares them after flair-kit's.
81
+
82
+ ## Breakpoints
83
+
84
+ `30rem`, `48rem` and `64rem` (480, 768 and 1024px at the default text size). Media queries can't read CSS variables, so these are values, not tokens. Write rules as `@media (width >= 48rem)`. They are also in `tokens.json` under `breakpoints`.
85
+
86
+ ## Motion
87
+
88
+ The package adds no transitions. `--dur-theme` is there for a site that fades between themes; under `prefers-reduced-motion: reduce` it becomes `0.01ms`, never `0s`, so code waiting on a transition's end event still hears it. A site that sets its own `--dur-theme` overrides that as well, so it should set it again inside its own `@media (prefers-reduced-motion: reduce)` block.
89
+
90
+ ## Showing a site in Flair
91
+
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.
93
+
94
+ ### Load the listener
95
+
96
+ A site with a build, in its entry file:
97
+
98
+ ```js
99
+ if (window.self !== window.top) import('@flairstudio/kit/preview.js').then((m) => m.listen());
100
+ ```
101
+
102
+ The bundler puts the import in a file of its own, which loads only when the page is framed.
103
+
104
+ A site without a build, with `dist/` copied to `assets/flair-kit/`, after its stylesheet links:
105
+
106
+ ```html
107
+ <script type="module">
108
+ if (window.self !== window.top) import('./assets/flair-kit/preview.js').then((m) => m.listen());
109
+ </script>
110
+ ```
111
+
112
+ Outside a frame, `listen()` does nothing. Calling it again while it runs changes nothing, and it returns a function that stops it.
113
+
114
+ ### Which Flair may theme the page
115
+
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:
117
+
118
+ ```js
119
+ import('@flairstudio/kit/preview.js').then(({ listen, DEFAULT_ALLOW }) =>
120
+ listen({ allow: [...DEFAULT_ALLOW, 'https://flair.example'] }));
121
+ ```
122
+
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.
124
+
125
+ ### What the listener changes
126
+
127
+ Only these, and only once Flair has sent a theme:
128
+ - 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;
130
+ - `data-flair-preview` on `<html>`, set with the first theme;
131
+ - an inline `--dur-theme` on `<html>`: `0.01ms` for the first theme and while a colour is being dragged, so nothing fades.
132
+
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.
134
+
135
+ ### Review tools step aside
136
+
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:
138
+
139
+ ```css
140
+ [data-flair-preview] .review-tools { display: none; }
141
+ ```
142
+
143
+ A script that needs to react listens for the event, fired on `document` each time a theme goes on:
144
+
145
+ ```js
146
+ document.addEventListener('flair-kit:preview', (event) => {
147
+ const { mode, first } = event.detail; // 'light' or 'dark'; true for the first theme
148
+ });
149
+ ```
150
+
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.
152
+
153
+ ### Two rules
154
+
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.
156
+ - **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
+
158
+ ### Flair's side: `preview-host.js`
159
+
160
+ Flair sends themes with `preview-host.js`, and a site's tests can too:
161
+
162
+ ```js
163
+ import { connect } from '@flairstudio/kit/preview-host.js';
164
+
165
+ const { send, close } = connect(iframe, {
166
+ origin: 'http://localhost:5173', // the site's address
167
+ onReady: ({ kit, names }) => {}, // the frame's package version and colour names
168
+ onApplied: () => {}, // the theme is on: the frame is ready to be seen
169
+ onRefused: (reason) => {}, // a short code, such as 'value'
170
+ onMismatch: ({ host, frame }) => {}, // the frame speaks another format version
171
+ });
172
+ send({ light, dark, mode: 'light', angle: 110, instant: false });
173
+ ```
174
+
175
+ `light` and `dark` map colour names, without the `--color-` prefix, to `#rrggbb` values. `send` throws a `TypeError` on a theme the frame would refuse. It keeps the latest theme and sends it whenever the frame says it's ready: at once, and again after a reload or a link inside the frame. It sends only the colour names the frame knows. `close()` stops listening.
176
+
177
+ ### Testing a site's pages with a Flair theme
178
+
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.
180
+
181
+ ```js
182
+ import { test, expect } from '@playwright/test';
183
+ import { createRequire } from 'node:module';
184
+ import { dirname, join } from 'node:path';
185
+
186
+ const FLAIR = 'http://localhost:4317'; // an allowed address; nothing needs to run there
187
+ const SITE = 'http://localhost:5173/'; // the page under test
188
+ const require = createRequire(import.meta.url);
189
+ const dist = dirname(require.resolve('@flairstudio/kit/preview-host.js'));
190
+ // The package's default palette; use a Flair export's values to test a real theme
191
+ const { light, dark } = require('@flairstudio/kit/tokens.json').colors;
192
+
193
+ const HOST_PAGE = `<!doctype html>
194
+ <iframe src="${SITE}" title="Site" style="width: 1480px; height: 900px; border: 0"></iframe>
195
+ <script type="module">
196
+ import { connect } from './preview-host.js';
197
+ const frame = document.querySelector('iframe');
198
+ window.flairKit = { applied: 0, refused: [] };
199
+ window.flairKit.host = connect(frame, {
200
+ origin: new URL(frame.src).origin,
201
+ onApplied: () => { window.flairKit.applied++; },
202
+ onRefused: (reason) => { window.flairKit.refused.push(reason); },
203
+ });
204
+ </script>`;
205
+
206
+ test('the home page wears a Flair theme', async ({ page }) => {
207
+ await page.route(`${FLAIR}/**`, (route) => {
208
+ const { pathname } = new URL(route.request().url());
209
+ if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: HOST_PAGE });
210
+ return route.fulfill({ path: join(dist, pathname.slice(1)) }); // preview-host.js, and the preview.js it imports
211
+ });
212
+ await page.goto(`${FLAIR}/`);
213
+ await page.evaluate((theme) => window.flairKit.host.send(theme), { light, dark, mode: 'dark', angle: 110 });
214
+ await expect.poll(() => page.evaluate(() => window.flairKit.applied)).toBeGreaterThan(0);
215
+ const site = page.frameLocator('iframe');
216
+ // check the site's page through `site`
217
+ });
218
+ ```
219
+
220
+ In a TypeScript test, `window.flairKit` needs a cast inside `page.evaluate`, such as `(window as any).flairKit`.
221
+
222
+ ## Versions
223
+
224
+ Pin an exact version, and read `CHANGELOG.md` (it ships in the package) before upgrading. Renaming or removing a token is a breaking change.
225
+
226
+ ## Licence
227
+
228
+ MIT, © FlairStudio. The Inter font files are under the SIL Open Font License 1.1 (`dist/fonts/OFL.txt`).
package/TOKENS.md ADDED
@@ -0,0 +1,195 @@
1
+ # flair-kit tokens
2
+
3
+ Version 0.2.0-beta.0. Colours change with the mode; everything else stays the same in light and dark.
4
+
5
+ ## Colours
6
+
7
+ Set per mode by `data-theme="light"` or `data-theme="dark"` on any element, or by the system when there is no attribute. The values shown are the default palette; a site's own palette file replaces them.
8
+
9
+ | Token | Light | Dark | What it's for |
10
+ |---|---|---|---|
11
+ | `--color-background` | `#f6faf9` | `#101413` | The page itself |
12
+ | `--color-card` | `#ffffff` | `#191f1e` | A raised surface on the page: cards, panels, dialogs |
13
+ | `--color-muted` | `#ecf2f1` | `#262d2c` | A quiet surface: wells, inputs, inactive tabs |
14
+ | `--color-secondary` | `#f0e5ed` | `#583050` | A tinted surface for bands and highlighted areas |
15
+ | `--color-foreground` | `#191f1e` | `#edf1f0` | Body text and icons on any of the four surfaces |
16
+ | `--color-card-foreground` | `#191f1e` | `#edf1f0` | Text on a card; the same as foreground today |
17
+ | `--color-muted-foreground` | `#5a6563` | `#b1bbb9` | Secondary text: captions, hints, metadata |
18
+ | `--color-on-secondary` | `#6f1362` | `#f7e2f2` | Text on the secondary surface |
19
+ | `--color-border` | `#ced6d5` | `#485250` | Hairlines and dividers; decorative, so not held to a contrast ratio |
20
+ | `--color-outline` | `#727e7c` | `#929e9c` | Borders a person needs to see, such as a field’s edge, on any surface |
21
+ | `--color-primary` | `#0d9488` | `#0d9488` | The main accent as a fill: buttons, selected states |
22
+ | `--color-on-primary` | `#000000` | `#000000` | Text and icons on a primary fill |
23
+ | `--color-primary-hover` | `#14a093` | `#14a093` | A primary fill while hovered |
24
+ | `--color-primary-pressed` | `#1eab9d` | `#1eab9d` | A primary fill while pressed |
25
+ | `--color-primary-text` | `#09746a` | `#30bdaf` | The main accent as text and links, on any surface |
26
+ | `--color-ring` | `#09746a` | `#30bdaf` | The focus ring; the same as primary-text |
27
+ | `--color-tertiary` | `#b93008` | `#f6a48f` | A third accent, as a fill |
28
+ | `--color-on-tertiary` | `#ffffff` | `#000000` | Text on a tertiary fill |
29
+ | `--color-accent-2` | `#ec14d2` | `#ed13d2` | A second accent, as a fill or a mark |
30
+ | `--color-glow` | `#f6b8a8` | `#f6b8a8` | A soft decorative colour for washes and art |
31
+ | `--color-destructive` | `#c6101a` | `#f7a39a` | Errors and destructive actions, as text or a fill |
32
+ | `--color-on-destructive` | `#ffffff` | `#000000` | Text on a destructive fill |
33
+ | `--color-chart-1` | `#0a8b80` | `#20aea0` | The first data series |
34
+ | `--color-chart-2` | `#b30f9f` | `#f799e3` | The second data series |
35
+ | `--color-chart-3` | `#95290c` | `#f5cbc0` | The third data series |
36
+ | `--color-chart-4` | `#36403e` | `#727f7d` | The fourth data series |
37
+ | `--color-brand` | `#0d9488` | `#0d9488` | The theme’s seed colour, exactly as chosen |
38
+ | `--color-gradient-1` | `#0d9488` | `#0d9488` | The first stop of the theme’s gradient |
39
+ | `--color-gradient-2` | `#ec14d2` | `#ed13d2` | The middle stop of the theme’s gradient |
40
+ | `--color-gradient-3` | `#f6b8a8` | `#f6b8a8` | The last stop of the theme’s gradient |
41
+ | `--gradient-angle` | `110deg` | `110deg` | The angle the gradient stops are drawn at |
42
+
43
+ ## Spacing
44
+
45
+ | Token | Value | What it's for |
46
+ |---|---|---|
47
+ | `--space-1` | `0.25rem` | 4px |
48
+ | `--space-2` | `0.5rem` | 8px |
49
+ | `--space-3` | `0.75rem` | 12px |
50
+ | `--space-4` | `1rem` | 16px |
51
+ | `--space-5` | `1.25rem` | 20px |
52
+ | `--space-6` | `1.5rem` | 24px |
53
+ | `--space-8` | `2rem` | 32px |
54
+ | `--space-10` | `2.5rem` | 40px |
55
+ | `--space-12` | `3rem` | 48px |
56
+ | `--space-16` | `4rem` | 64px |
57
+ | `--space-gutter` | `clamp(1.25rem, 5vw, 5rem)` | Page side padding; grows with the screen from 20px to 80px |
58
+ | `--space-section` | `clamp(3rem, 1.5rem + 5vw, 6rem)` | Space between page sections; grows from 48px to 96px |
59
+ | `--space-section-tight` | `clamp(2.25rem, 1.125rem + 3.75vw, 4.5rem)` | Space between closely related sections; about three-quarters of --space-section |
60
+
61
+ ## Type sizes
62
+
63
+ | Token | Value | What it's for |
64
+ |---|---|---|
65
+ | `--text-12` | `0.75rem` | Small print, labels |
66
+ | `--text-14` | `0.875rem` | Secondary text, dense UI |
67
+ | `--text-16` | `1rem` | Body text |
68
+ | `--text-18` | `1.125rem` | Lead paragraphs, small headings |
69
+ | `--text-20` | `1.25rem` | Headings between 18 and 24 |
70
+ | `--text-24` | `1.5rem` | Section headings |
71
+ | `--text-32` | `2rem` | Page headings; larger display sizes belong to each site |
72
+
73
+ ## Radius
74
+
75
+ | Token | Value | What it's for |
76
+ |---|---|---|
77
+ | `--radius-sm` | `4px` | Small controls, chips |
78
+ | `--radius-md` | `8px` | Buttons, fields |
79
+ | `--radius-lg` | `12px` | Cards, panels |
80
+ | `--radius-full` | `9999px` | Pills and circles |
81
+
82
+ ## Layers
83
+
84
+ | Token | Value | What it's for |
85
+ |---|---|---|
86
+ | `--z-raised` | `10` | Content lifted above its neighbours |
87
+ | `--z-sticky` | `20` | Sticky headers and bars |
88
+ | `--z-overlay` | `40` | Menus, dialogs and their scrims |
89
+ | `--z-toast` | `100` | Toasts and notices |
90
+ | `--z-tooltip` | `200` | Tooltips, above everything |
91
+
92
+ ## Durations
93
+
94
+ | Token | Value | What it's for |
95
+ |---|---|---|
96
+ | `--dur-press` | `120ms` | Press feedback |
97
+ | `--dur-exit` | `160ms` | Something leaving |
98
+ | `--dur-state` | `200ms` | Hover and other state changes |
99
+ | `--dur-enter` | `250ms` | Something arriving |
100
+ | `--dur-theme` | `200ms` | A fade between themes or modes, for sites that add one |
101
+
102
+ ## Easing
103
+
104
+ | Token | Value | What it's for |
105
+ |---|---|---|
106
+ | `--ease-out` | `cubic-bezier(0.2, 0, 0, 1)` | The standard easing: fast start, gentle stop |
107
+
108
+ ## Sizes
109
+
110
+ | Token | Value | What it's for |
111
+ |---|---|---|
112
+ | `--size-touch` | `2.75rem` | Main controls: 44px, comfortable to tap. The tested minimum is 24px |
113
+
114
+ ## Fonts
115
+
116
+ | Token | Value | What it's for |
117
+ |---|---|---|
118
+ | `--font-sans` | `Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif` | Body and UI text; Inter ships in the opt-in fonts.css |
119
+ | `--font-mono` | `ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace` | Code and figures; the system’s own mono, nothing to download |
120
+ | `--font-display` | `var(--font-sans)` | Headlines; follows --font-sans as set on :root, unless a site sets its own |
121
+
122
+ ## Pairings Flair guarantees
123
+
124
+ Flair's engine builds every palette so these pairs pass. Any other pairing a page paints is checked on the rendered page instead.
125
+
126
+ - `foreground` on `background`: at least 4.6:1
127
+ - `foreground` on `card`: at least 4.6:1
128
+ - `foreground` on `muted`: at least 4.6:1
129
+ - `foreground` on `secondary`: at least 4.6:1
130
+ - `muted-foreground` on `background`: at least 4.6:1
131
+ - `muted-foreground` on `card`: at least 4.6:1
132
+ - `muted-foreground` on `muted`: at least 4.6:1
133
+ - `muted-foreground` on `secondary`: at least 4.6:1
134
+ - `on-secondary` on `background`: at least 4.6:1
135
+ - `on-secondary` on `card`: at least 4.6:1
136
+ - `on-secondary` on `muted`: at least 4.6:1
137
+ - `on-secondary` on `secondary`: at least 4.6:1
138
+ - `primary-text` on `background`: at least 4.6:1
139
+ - `primary-text` on `card`: at least 4.6:1
140
+ - `primary-text` on `muted`: at least 4.6:1
141
+ - `primary-text` on `secondary`: at least 4.6:1
142
+ - `destructive` on `background`: at least 4.6:1
143
+ - `destructive` on `card`: at least 4.6:1
144
+ - `destructive` on `muted`: at least 4.6:1
145
+ - `destructive` on `secondary`: at least 4.6:1
146
+ - `outline` on `background`: at least 3.1:1
147
+ - `outline` on `card`: at least 3.1:1
148
+ - `outline` on `muted`: at least 3.1:1
149
+ - `outline` on `secondary`: at least 3.1:1
150
+ - `primary` on `background`: at least 3.1:1
151
+ - `primary` on `card`: at least 3.1:1
152
+ - `tertiary` on `background`: at least 3.1:1
153
+ - `tertiary` on `card`: at least 3.1:1
154
+ - `accent-2` on `background`: at least 3.1:1
155
+ - `accent-2` on `card`: at least 3.1:1
156
+ - `chart-1` on `background`: at least 3.1:1
157
+ - `chart-1` on `card`: at least 3.1:1
158
+ - `chart-2` on `background`: at least 3.1:1
159
+ - `chart-2` on `card`: at least 3.1:1
160
+ - `chart-3` on `background`: at least 3.1:1
161
+ - `chart-3` on `card`: at least 3.1:1
162
+ - `chart-4` on `background`: at least 3.1:1
163
+ - `chart-4` on `card`: at least 3.1:1
164
+ - `on-primary` on `primary`: at least 4.6:1
165
+ - `on-primary` on `primary-hover`: at least 4.6:1
166
+ - `on-primary` on `primary-pressed`: at least 4.6:1
167
+ - `on-tertiary` on `tertiary`: at least 4.6:1
168
+ - `on-destructive` on `destructive`: at least 4.6:1
169
+
170
+ ## Breakpoints
171
+
172
+ Values for media queries, which can't read CSS variables. Write rules as `(width >= 48rem)`.
173
+
174
+ | Name | Value |
175
+ |---|---|
176
+ | sm | `30rem` |
177
+ | md | `48rem` |
178
+ | lg | `64rem` |
179
+
180
+ ## Reduced motion
181
+
182
+ Under `prefers-reduced-motion: reduce`:
183
+
184
+ - `--dur-theme` becomes `0.01ms`
185
+
186
+ ## Cascade layers
187
+
188
+ From lowest to highest, then the site's own unlayered CSS, which beats them all:
189
+
190
+ - `flair-kit.tokens`: the package's defaults, which are every token in this file
191
+ - `flair-kit.palette`: the site's palette file
192
+ - `flair-kit.components`: components
193
+ - `flair-kit.preview`: the theme Flair sends while it shows the page in its frame
194
+
195
+ Generated from src/tokens.ts by npm run build.
@@ -0,0 +1,93 @@
1
+ Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
package/dist/fonts.css ADDED
@@ -0,0 +1,19 @@
1
+ /* flair-kit 0.2.0-beta.0 · generated from src/tokens.ts · do not edit */
2
+
3
+ @font-face {
4
+ font-family: Inter;
5
+ font-style: normal;
6
+ font-weight: 100 900;
7
+ font-display: swap;
8
+ src: url(fonts/inter-latin-wght-normal.woff2) format('woff2');
9
+ unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
10
+ }
11
+
12
+ @font-face {
13
+ font-family: Inter;
14
+ font-style: normal;
15
+ font-weight: 100 900;
16
+ font-display: swap;
17
+ src: url(fonts/inter-latin-ext-wght-normal.woff2) format('woff2');
18
+ unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
19
+ }
@@ -0,0 +1,39 @@
1
+ /* flair-kit 0.2.0-beta.0 · generated from src/tokens.ts · do not edit */
2
+
3
+ import type { Colors, Mode } from './preview.js';
4
+
5
+ export { COLOR_NAMES, FORMAT_VERSION, KIT_VERSION } from './preview.js';
6
+ export type { ColorName, Colors, Mode, Reason } from './preview.js';
7
+
8
+ /** A theme as Flair sends it: both modes' colours, the canvas mode, the gradient angle, and whether a drag is under way */
9
+ export interface Theme {
10
+ readonly light: Colors;
11
+ readonly dark: Colors;
12
+ readonly mode: Mode;
13
+ /** Degrees, from 0 to 360 */
14
+ readonly angle: number;
15
+ /** True while a drag or typing is under way, so the page doesn't fade */
16
+ readonly instant?: boolean;
17
+ }
18
+ /** What the frame said when it became ready */
19
+ export interface ReadyInfo { readonly kit: string; readonly names: readonly string[] }
20
+ export interface ConnectOptions {
21
+ /** The site's origin, or any address on it */
22
+ readonly origin: string;
23
+ /** The frame is listening: its package version and the colour names it accepts */
24
+ readonly onReady?: (info: ReadyInfo) => void;
25
+ /** The frame has put the theme on and is ready to be seen */
26
+ readonly onApplied?: () => void;
27
+ /** The frame refused the theme, or shares no colour names with it ("name") */
28
+ readonly onRefused?: (reason: string) => void;
29
+ /** The frame speaks another format version, so nothing is sent */
30
+ readonly onMismatch?: (versions: { readonly host: number; readonly frame: unknown }) => void;
31
+ }
32
+ export interface Connection {
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;
35
+ /** Stops listening to the frame */
36
+ close(): void;
37
+ }
38
+ /** Connects to the page in an <iframe> of a site */
39
+ export declare function connect(frame: HTMLIFrameElement, options: ConnectOptions): Connection;