@travelallfly/ui 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +163 -2
- package/dist/chunk-C6EI7GYY.js +112 -0
- package/dist/chunk-HX7N52DB.cjs +228 -0
- package/dist/chunk-JH4ANRE2.cjs +112 -0
- package/dist/chunk-NSDKLLVT.js +228 -0
- package/dist/index.cjs +207 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +171 -0
- package/dist/tailwind-preset.cjs +62 -0
- package/dist/tailwind-preset.d.cts +23 -0
- package/dist/tailwind-preset.d.ts +23 -0
- package/dist/tailwind-preset.js +60 -0
- package/dist/tokens.cjs +54 -0
- package/dist/tokens.css +178 -0
- package/dist/tokens.d.cts +420 -0
- package/dist/tokens.d.ts +420 -0
- package/dist/tokens.js +54 -0
- package/dist/utils.cjs +74 -0
- package/dist/utils.d.cts +13 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +74 -0
- package/package.json +116 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AllFly
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,164 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AllFly UI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The shared design system for AllFly apps: design tokens, a Tailwind preset and React components, with a Storybook to browse them. It implements the Figma file [AllFly Design System](https://www.figma.com/design/IctaOawIt0vNkTWvMfcEk7/AllFly-Design-System) (v1.0, light and dark themes).
|
|
4
|
+
|
|
5
|
+
Status: first scaffold. It contains the foundations and one draft component (Button), which exists to prove the pipeline end to end. Further components are on hold until the theme is locked with design. The first published version is 0.1.0.
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
| Command | What it does |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `npm run storybook` | Storybook at http://localhost:6006 |
|
|
12
|
+
| `npm run build-storybook` | Static Storybook in `storybook-static/` |
|
|
13
|
+
| `npm run tokens` | Regenerate `src/tokens/tokens.css` from `src/tokens/tokens.ts` |
|
|
14
|
+
| `npm run changeset` | Describe a change for the next release |
|
|
15
|
+
| `npm run lint` | ESLint |
|
|
16
|
+
| `npm run typecheck` | TypeScript check |
|
|
17
|
+
| `npm run test-unit` | Unit tests |
|
|
18
|
+
| `npm run build` | Package build in `dist/` |
|
|
19
|
+
| `npm run test-consumers` | Build, pack and install the package into the Next and Vite fixtures, then build and check them |
|
|
20
|
+
|
|
21
|
+
## Tokens
|
|
22
|
+
|
|
23
|
+
`src/tokens/tokens.ts` is the single source. Everything else is derived from it:
|
|
24
|
+
|
|
25
|
+
- `src/tokens/tokens.css`: CSS variables, generated by `npm run tokens`. A test fails if it is out of date.
|
|
26
|
+
- `src/tokens/tailwind-preset.ts`: Tailwind theme that points at those variables.
|
|
27
|
+
- The Foundations pages in Storybook.
|
|
28
|
+
|
|
29
|
+
Colours have two tiers, as in Figma. Primitives (`blue/500`) are the raw palette. Roles (`bg/action`) point at primitives. Components use roles only; primitives have CSS variables but no Tailwind classes.
|
|
30
|
+
|
|
31
|
+
### Naming rule
|
|
32
|
+
|
|
33
|
+
A Tailwind class is the utility plus the Figma variable name, with `/` replaced by `-`.
|
|
34
|
+
|
|
35
|
+
| Figma | CSS variable | Tailwind class |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `bg/action` | `--af-bg-action` | `bg-bg-action` |
|
|
38
|
+
| `text/primary` | `--af-text-primary` | `text-text-primary` |
|
|
39
|
+
| `border/default` | `--af-border-default` | `border-border-default` |
|
|
40
|
+
| `status/error/fill` | `--af-status-error-fill` | `bg-status-error-fill` |
|
|
41
|
+
| `travel/hotels/accent` | `--af-travel-hotels-accent` | `text-travel-hotels-accent` |
|
|
42
|
+
| `spacing/lg` | `--af-spacing-lg` | `p-spacing-lg` |
|
|
43
|
+
| `radius/xl` | `--af-radius-xl` | `rounded-radius-xl` |
|
|
44
|
+
| Raised | `--af-elevation-raised` | `shadow-elevation-raised` |
|
|
45
|
+
| Body strong | (none) | `type-body-strong` |
|
|
46
|
+
|
|
47
|
+
The group stays in the class name (`text-text-primary`, not `text-primary`) because Quest and Backoffice already define `text-primary`, `border`, `rounded-md` and similar with different values. Keeping the group means the preset can be added to either app without changing how any existing screen looks.
|
|
48
|
+
|
|
49
|
+
### Dark theme
|
|
50
|
+
|
|
51
|
+
Every colour role has a light and a dark value. `tokens.css` sets the light values on `:root` and overrides the roles under a `dark` class, so an app switches theme by adding or removing `dark` on `<html>`. Components need no `dark:` classes. Primitives are the same in both themes.
|
|
52
|
+
|
|
53
|
+
Dark values live in `colorRolesDark` in `src/tokens/tokens.ts`. A value is either a primitive (`warm/900`), a primitive or hex with an opacity (`#0A0908@72`, the dark scrim) or a hex where Figma's dark mode uses a colour that has no swatch on the Foundations page.
|
|
54
|
+
|
|
55
|
+
"System" is not a third theme: the app resolves it to light or dark and applies that.
|
|
56
|
+
|
|
57
|
+
### Where the values came from
|
|
58
|
+
|
|
59
|
+
- **Light roles, primitives, type, spacing, radius**: read from the layer names on the Figma Foundations page, which carry each token's name and value. `bg/image-dim` is transparent in light, written as its dark colour at 0%.
|
|
60
|
+
- **Dark roles**: the "Foundations / Dark colours" page in Figma, which lists each role with its dark and light value (spec v2.1).
|
|
61
|
+
- **Focus ring**: measured on the "Dark mode / Library check" page (4px, action blue at 30%).
|
|
62
|
+
- **Shadows, button sizing and the Eyebrow style**: given by design in writing. Raised has no shadow in dark, because the lighter surface does the lifting; `tokens.css` overrides the shadow variables under `dark` for this.
|
|
63
|
+
|
|
64
|
+
### Values to confirm with design
|
|
65
|
+
|
|
66
|
+
- The dark value of `border/selected`. It is not on the dark colours page and currently reuses `border/focus`. It is listed in `darkRolesUnverified` and marked in Storybook. `border/ink` is not on that page either; its dark value was read from the library check page.
|
|
67
|
+
- The light values of `bg/raised`, `bg/image-dim`, `bg/art-cream` and `border/feature`. They are not on the light Foundations page; the values used are the Light column of the dark colours page, which marks them as having no light token in the spec.
|
|
68
|
+
- The `type/events/*` colours, marked PROPOSED in Figma. They are not in this package.
|
|
69
|
+
|
|
70
|
+
Replace all of the above with an export of the Figma variables when one is available.
|
|
71
|
+
|
|
72
|
+
## Using it in an app
|
|
73
|
+
|
|
74
|
+
The package is published publicly to npmjs.com as `@travelallfly/ui`, so installing it needs no token or `.npmrc`. The package used to be on GitHub Packages; remove any `@travelallfly:registry=https://npm.pkg.github.com` line from the app's `.npmrc`.
|
|
75
|
+
|
|
76
|
+
Install it and wire it up:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install @travelallfly/ui
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import allflyPreset from '@travelallfly/ui/tailwind-preset';
|
|
84
|
+
|
|
85
|
+
export default {
|
|
86
|
+
presets: [allflyPreset],
|
|
87
|
+
content: ['./app/**/*.{ts,tsx}', './node_modules/@travelallfly/ui/dist/**/*.js'],
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
@import '@travelallfly/ui/tokens.css';
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { Button } from '@travelallfly/ui';
|
|
97
|
+
import { buttonVariants, cn } from '@travelallfly/ui/utils';
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Components come from the package root, which is a client module (`"use client"`). `cn` and the variant helpers come from `/utils`, which has no directive, so Server Components can call them, for example `<Link className={buttonVariants({ variant: 'link' })}>`.
|
|
101
|
+
|
|
102
|
+
Always merge classes with the library's `cn`. It knows the token scales, so a caller's `px-4` replaces a component's `px-spacing-xl`; a stock `tailwind-merge` would keep both.
|
|
103
|
+
|
|
104
|
+
App configs can override Tailwind's core colours (Quest and Backoffice both replace `transparent` with an object, which removes `border-transparent`). Components must not depend on core colour classes; the Button test compiles its classes against such a config to catch this.
|
|
105
|
+
|
|
106
|
+
The app loads the fonts itself (Figtree, Instrument Serif, Geist Mono) and may override `--af-font-ui`, `--af-font-voice` and `--af-font-code` to match how it loads them, for example with `next/font`.
|
|
107
|
+
|
|
108
|
+
## Releasing
|
|
109
|
+
|
|
110
|
+
Versions and the changelog are managed with [Changesets](https://changesets.dev).
|
|
111
|
+
|
|
112
|
+
1. **In every pull request that changes what consumers get**, run `npm run changeset`, pick patch, minor or major, and describe the change. This adds a small file under `.changeset/`. A visual change that alters size or layout counts as breaking.
|
|
113
|
+
2. **To cut a release**, run `npm run version-packages` on a branch. It turns the pending changesets into a version bump and a `CHANGELOG.md` entry. Open that as a pull request into `develop`.
|
|
114
|
+
3. **When that pull request merges**, the Release workflow sees a version that is not in the registry, builds the package, publishes it to npmjs.com, pushes a `v<version>` tag and moves `master` to the released commit.
|
|
115
|
+
|
|
116
|
+
Publishing uses npm trusted publishing: the workflow proves its identity to npm with a GitHub OIDC token, and the package's npm settings trust only `travelallfly/allfly-ui` running `release.yml`. There is no npm token in the repository secrets.
|
|
117
|
+
|
|
118
|
+
Pushes to `develop` that do not change the version publish nothing. `master` therefore always points at the latest published release.
|
|
119
|
+
|
|
120
|
+
## Adding a component
|
|
121
|
+
|
|
122
|
+
What Figma defines, and the order to build it in, is in [docs/component-inventory.md](docs/component-inventory.md).
|
|
123
|
+
|
|
124
|
+
1. Find the component set in Figma and note its variants and states.
|
|
125
|
+
2. Create `src/components/<name>/<name>.tsx`, using role classes only.
|
|
126
|
+
3. Add `<name>.stories.tsx` with one story per Figma variant group, and the Figma guidance line as the description.
|
|
127
|
+
4. Add `<name>.test.tsx` covering behaviour and that the element is locatable by role and name.
|
|
128
|
+
5. Export it from `src/index.ts`.
|
|
129
|
+
|
|
130
|
+
## CI
|
|
131
|
+
|
|
132
|
+
The workflows follow the same conventions as Quest and Backoffice.
|
|
133
|
+
|
|
134
|
+
- `pr-checks.yml` runs on every pull request: lint, typecheck, unit tests, package build and Storybook build, plus the consumer smoke test as a second job.
|
|
135
|
+
- `vulnerability-scan.yml` runs the shared weekly scan from `tools-cicd`, configured by `.github/vscan.toml`.
|
|
136
|
+
- `auto_assign.yml` assigns reviewers.
|
|
137
|
+
- `release.yml` publishes to npmjs.com when a new version lands on `develop` (see Releasing).
|
|
138
|
+
|
|
139
|
+
There are no deploy, hotfix or promote workflows, because this package is not deployed to an environment. The Release workflow takes their place: `develop` is the working branch and `master` is the latest release.
|
|
140
|
+
|
|
141
|
+
## Consumer smoke test
|
|
142
|
+
|
|
143
|
+
`fixtures/next-app` (Next 16, React 19, Turbopack) and `fixtures/vite-app` (Vite 6, React 18) stand in for Quest and Backoffice. Their Tailwind configs copy the parts of the real apps' configs that can clash with this library: `transparent` replaced by an object, and their own `primary`, `border`, `rounded-md` and `font-sans`.
|
|
144
|
+
|
|
145
|
+
`npm run test-consumers` builds the package, packs it as npm would publish it, installs the tarball into each fixture and builds the fixture. It then checks that:
|
|
146
|
+
|
|
147
|
+
- the library's classes and token variables are in the built CSS, and the app's own classes still resolve to the app's values;
|
|
148
|
+
- every class on the prerendered Next page has a CSS rule;
|
|
149
|
+
- a Server Component can call `buttonVariants` and render `Button`;
|
|
150
|
+
- the Vite fixture typechecks against React 18 types, and the CommonJS entry points load and render under React 18.
|
|
151
|
+
|
|
152
|
+
When a new component is added, render it in both fixture pages so it is covered.
|
|
153
|
+
|
|
154
|
+
## Icons
|
|
155
|
+
|
|
156
|
+
The icons are Lucide: 24 grid, 2px stroke, round ends, never filled, at sizes 16, 20 and 24. Design is checking the 46 icons in Figma against Lucide names and will export any that have no match.
|
|
157
|
+
|
|
158
|
+
## Licence
|
|
159
|
+
|
|
160
|
+
MIT, see [LICENSE](LICENSE). The package contains code and token values only. The Figma file and its assets are not part of it and stay private.
|
|
161
|
+
|
|
162
|
+
## Open decisions
|
|
163
|
+
|
|
164
|
+
- Where Storybook is hosted, and whether pull requests get preview builds. It is not hosted yet.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
colorRoles,
|
|
3
|
+
colorRolesDark,
|
|
4
|
+
elevation,
|
|
5
|
+
fonts,
|
|
6
|
+
primitives,
|
|
7
|
+
radius,
|
|
8
|
+
spacing
|
|
9
|
+
} from "./chunk-NSDKLLVT.js";
|
|
10
|
+
|
|
11
|
+
// src/tokens/css.ts
|
|
12
|
+
var prefix = "af";
|
|
13
|
+
function flattenRoles(tree, path = []) {
|
|
14
|
+
return Object.entries(tree).flatMap(([key, value]) => {
|
|
15
|
+
const next = [...path, key];
|
|
16
|
+
if (typeof value !== "string") return flattenRoles(value, next);
|
|
17
|
+
return [{ name: next.join("-"), figmaName: next.join("/"), group: next[0], ref: value }];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
var roles = flattenRoles(colorRoles);
|
|
21
|
+
var darkRoles = flattenRoles(colorRolesDark);
|
|
22
|
+
var darkClass = "dark";
|
|
23
|
+
function darkRoleFor(name) {
|
|
24
|
+
const role = darkRoles.find((item) => item.name === name);
|
|
25
|
+
if (!role) throw new Error(`Role "${name}" has no dark value`);
|
|
26
|
+
return role;
|
|
27
|
+
}
|
|
28
|
+
function isHex(ref) {
|
|
29
|
+
return /^#[0-9A-F]{6}$/.test(ref);
|
|
30
|
+
}
|
|
31
|
+
function splitAlpha(ref) {
|
|
32
|
+
const [base, alpha] = ref.split("@");
|
|
33
|
+
if (alpha === void 0) return { base, alpha: null };
|
|
34
|
+
const percent = Number(alpha);
|
|
35
|
+
if (!Number.isInteger(percent) || percent < 0 || percent > 99) throw new Error(`Bad opacity in "${ref}"`);
|
|
36
|
+
return { base, alpha: percent };
|
|
37
|
+
}
|
|
38
|
+
function resolveColor(ref) {
|
|
39
|
+
const { base } = splitAlpha(ref);
|
|
40
|
+
return isHex(base) ? base : resolvePrimitive(base);
|
|
41
|
+
}
|
|
42
|
+
function colorValue(ref) {
|
|
43
|
+
const { base, alpha } = splitAlpha(ref);
|
|
44
|
+
resolveColor(ref);
|
|
45
|
+
const solid = isHex(base) ? base : cssVar(primitiveName(base));
|
|
46
|
+
return alpha === null ? solid : `color-mix(in srgb, ${solid} ${alpha}%, transparent)`;
|
|
47
|
+
}
|
|
48
|
+
function cssVarName(name) {
|
|
49
|
+
return `--${prefix}-${name}`;
|
|
50
|
+
}
|
|
51
|
+
function cssVar(name) {
|
|
52
|
+
return `var(${cssVarName(name)})`;
|
|
53
|
+
}
|
|
54
|
+
function primitiveName(ref) {
|
|
55
|
+
return ref.replace("/", "-");
|
|
56
|
+
}
|
|
57
|
+
function resolvePrimitive(ref) {
|
|
58
|
+
const [scale, step] = ref.split("/");
|
|
59
|
+
const steps = primitives[scale];
|
|
60
|
+
const value = steps?.[step];
|
|
61
|
+
if (!value) throw new Error(`Unknown primitive "${ref}"`);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function rem(px) {
|
|
65
|
+
return `${px / 16}rem`;
|
|
66
|
+
}
|
|
67
|
+
function renderTokensCss() {
|
|
68
|
+
const groups = [];
|
|
69
|
+
groups.push(
|
|
70
|
+
Object.entries(primitives).flatMap(
|
|
71
|
+
([scale, steps]) => Object.entries(steps).map(([step, value]) => `${cssVarName(`${scale}-${step}`)}: ${value};`)
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
groups.push(roles.map((role) => `${cssVarName(role.name)}: ${colorValue(role.ref)};`));
|
|
75
|
+
groups.push(Object.entries(spacing).map(([key, px]) => `${cssVarName(`spacing-${key}`)}: ${rem(px)};`));
|
|
76
|
+
groups.push(Object.entries(radius).map(([key, item]) => `${cssVarName(`radius-${key}`)}: ${item.value}px;`));
|
|
77
|
+
groups.push(Object.entries(elevation).map(([key, item]) => `${cssVarName(`elevation-${key}`)}: ${item.value};`));
|
|
78
|
+
groups.push(Object.entries(fonts).map(([key, stack]) => `${cssVarName(`font-${key}`)}: ${stack.join(", ")};`));
|
|
79
|
+
const indent = (lines) => lines.map((line) => ` ${line}`).join("\n");
|
|
80
|
+
const body = [["color-scheme: light;"], ...groups].map(indent).join("\n\n");
|
|
81
|
+
const darkLines = roles.map((role) => ({ light: role, dark: darkRoleFor(role.name) })).filter(({ light, dark }) => light.ref !== dark.ref).map(({ dark }) => `${cssVarName(dark.name)}: ${colorValue(dark.ref)};`);
|
|
82
|
+
const darkElevation = Object.entries(elevation).flatMap(
|
|
83
|
+
([key, item]) => item.dark === void 0 ? [] : [`${cssVarName(`elevation-${key}`)}: ${item.dark};`]
|
|
84
|
+
);
|
|
85
|
+
const darkBody = [["color-scheme: dark;"], darkLines, darkElevation].map(indent).join("\n\n");
|
|
86
|
+
return `:root {
|
|
87
|
+
${body}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.${darkClass} {
|
|
91
|
+
${darkBody}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
prefix,
|
|
98
|
+
flattenRoles,
|
|
99
|
+
roles,
|
|
100
|
+
darkRoles,
|
|
101
|
+
darkClass,
|
|
102
|
+
darkRoleFor,
|
|
103
|
+
isHex,
|
|
104
|
+
splitAlpha,
|
|
105
|
+
resolveColor,
|
|
106
|
+
cssVarName,
|
|
107
|
+
cssVar,
|
|
108
|
+
primitiveName,
|
|
109
|
+
resolvePrimitive,
|
|
110
|
+
rem,
|
|
111
|
+
renderTokensCss
|
|
112
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/tokens/tokens.ts
|
|
2
|
+
var primitives = {
|
|
3
|
+
base: {
|
|
4
|
+
white: "#FFFFFF"
|
|
5
|
+
},
|
|
6
|
+
blue: {
|
|
7
|
+
50: "#EAF3FF",
|
|
8
|
+
100: "#C9D6EE",
|
|
9
|
+
200: "#9CC4F8",
|
|
10
|
+
300: "#7DB4F5",
|
|
11
|
+
500: "#0770E3",
|
|
12
|
+
600: "#055BBD",
|
|
13
|
+
700: "#0A4794",
|
|
14
|
+
900: "#0B1F4B"
|
|
15
|
+
},
|
|
16
|
+
warm: {
|
|
17
|
+
0: "#FFFEFC",
|
|
18
|
+
50: "#FBF8F3",
|
|
19
|
+
75: "#F7F3EC",
|
|
20
|
+
100: "#F3EEE6",
|
|
21
|
+
200: "#E7E0D5",
|
|
22
|
+
300: "#CFC6B8",
|
|
23
|
+
400: "#A39A8C",
|
|
24
|
+
600: "#6B655C",
|
|
25
|
+
800: "#4A453E",
|
|
26
|
+
900: "#1F1D1A"
|
|
27
|
+
},
|
|
28
|
+
sunrise: {
|
|
29
|
+
50: "#FDEBE4",
|
|
30
|
+
500: "#E8603C",
|
|
31
|
+
700: "#B5411F"
|
|
32
|
+
},
|
|
33
|
+
marigold: {
|
|
34
|
+
50: "#FDF3DC",
|
|
35
|
+
100: "#FCEBB6",
|
|
36
|
+
500: "#F2B035",
|
|
37
|
+
800: "#7A4E00",
|
|
38
|
+
900: "#4A3000"
|
|
39
|
+
},
|
|
40
|
+
palm: {
|
|
41
|
+
50: "#E3F4EE",
|
|
42
|
+
500: "#1A7A5E",
|
|
43
|
+
700: "#14664F"
|
|
44
|
+
},
|
|
45
|
+
red: {
|
|
46
|
+
50: "#FBE9E7",
|
|
47
|
+
500: "#C93A3A",
|
|
48
|
+
700: "#A12B2B",
|
|
49
|
+
900: "#7A1F1F"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var colorRoles = {
|
|
53
|
+
bg: {
|
|
54
|
+
page: "warm/50",
|
|
55
|
+
surface: "warm/0",
|
|
56
|
+
sunken: "warm/100",
|
|
57
|
+
hover: "warm/75",
|
|
58
|
+
selected: "blue/50",
|
|
59
|
+
feature: "blue/900",
|
|
60
|
+
action: "blue/500",
|
|
61
|
+
"action-hover": "blue/600",
|
|
62
|
+
"action-pressed": "blue/700",
|
|
63
|
+
inverse: "warm/900",
|
|
64
|
+
scrim: "warm/900@60",
|
|
65
|
+
raised: "warm/0",
|
|
66
|
+
"image-dim": "#151310@0",
|
|
67
|
+
"art-cream": "#FDEBD5"
|
|
68
|
+
},
|
|
69
|
+
text: {
|
|
70
|
+
primary: "warm/900",
|
|
71
|
+
secondary: "warm/800",
|
|
72
|
+
muted: "warm/600",
|
|
73
|
+
link: "blue/600",
|
|
74
|
+
"on-action": "base/white",
|
|
75
|
+
"on-feature": "base/white",
|
|
76
|
+
"on-feature-muted": "blue/100",
|
|
77
|
+
"on-selected": "blue/700",
|
|
78
|
+
inverse: "warm/0"
|
|
79
|
+
},
|
|
80
|
+
border: {
|
|
81
|
+
default: "warm/200",
|
|
82
|
+
strong: "warm/300",
|
|
83
|
+
control: "warm/400",
|
|
84
|
+
focus: "blue/500",
|
|
85
|
+
selected: "blue/500",
|
|
86
|
+
ink: "warm/900",
|
|
87
|
+
feature: "blue/900"
|
|
88
|
+
},
|
|
89
|
+
status: {
|
|
90
|
+
success: { fill: "palm/50", text: "palm/700", border: "palm/500" },
|
|
91
|
+
info: { fill: "blue/50", text: "blue/700", border: "blue/200" },
|
|
92
|
+
caution: { fill: "marigold/100", text: "marigold/900", icon: "marigold/800", border: "marigold/500" },
|
|
93
|
+
error: { fill: "red/50", text: "red/900", strong: "red/700", border: "red/500" },
|
|
94
|
+
neutral: { fill: "warm/100", text: "warm/800", border: "warm/300" }
|
|
95
|
+
},
|
|
96
|
+
travel: {
|
|
97
|
+
flights: { tint: "blue/50", ink: "blue/700", accent: "blue/500" },
|
|
98
|
+
hotels: { tint: "sunrise/50", ink: "sunrise/700", accent: "sunrise/500" },
|
|
99
|
+
cars: { tint: "marigold/50", ink: "marigold/800", accent: "marigold/500" },
|
|
100
|
+
rail: { tint: "palm/50", ink: "palm/700", accent: "palm/500" }
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var colorRolesDark = {
|
|
104
|
+
bg: {
|
|
105
|
+
page: "#151310",
|
|
106
|
+
surface: "warm/900",
|
|
107
|
+
sunken: "#2A2723",
|
|
108
|
+
hover: "#26231F",
|
|
109
|
+
selected: "#172A45",
|
|
110
|
+
feature: "blue/900",
|
|
111
|
+
action: "blue/500",
|
|
112
|
+
"action-hover": "blue/600",
|
|
113
|
+
"action-pressed": "blue/700",
|
|
114
|
+
inverse: "warm/100",
|
|
115
|
+
scrim: "#0A0908@72",
|
|
116
|
+
raised: "#2E2A26",
|
|
117
|
+
"image-dim": "#151310@10",
|
|
118
|
+
"art-cream": "#FDEBD5"
|
|
119
|
+
},
|
|
120
|
+
text: {
|
|
121
|
+
primary: "warm/100",
|
|
122
|
+
secondary: "#D4CBBE",
|
|
123
|
+
muted: "#ABA294",
|
|
124
|
+
link: "blue/300",
|
|
125
|
+
"on-action": "base/white",
|
|
126
|
+
"on-feature": "base/white",
|
|
127
|
+
"on-feature-muted": "blue/100",
|
|
128
|
+
"on-selected": "blue/200",
|
|
129
|
+
inverse: "warm/900"
|
|
130
|
+
},
|
|
131
|
+
border: {
|
|
132
|
+
default: "#38342E",
|
|
133
|
+
strong: "#4F4941",
|
|
134
|
+
control: "#857C70",
|
|
135
|
+
focus: "blue/300",
|
|
136
|
+
selected: "blue/300",
|
|
137
|
+
ink: "warm/100",
|
|
138
|
+
feature: "#1E3A70"
|
|
139
|
+
},
|
|
140
|
+
status: {
|
|
141
|
+
success: { fill: "#13291F", text: "#86D3B2", border: "#3DB489" },
|
|
142
|
+
info: { fill: "#15243A", text: "#A9CBF7", border: "#2E4F7C" },
|
|
143
|
+
caution: { fill: "#2D2412", text: "#F5CB78", icon: "marigold/500", border: "#7A5A17" },
|
|
144
|
+
error: { fill: "#341A18", text: "#F6A8A0", strong: "#EE7A70", border: "#8A3530" },
|
|
145
|
+
neutral: { fill: "#2A2723", text: "#D4CBBE", border: "#4F4941" }
|
|
146
|
+
},
|
|
147
|
+
travel: {
|
|
148
|
+
flights: { tint: "#172A45", ink: "blue/200", accent: "blue/500" },
|
|
149
|
+
hotels: { tint: "#33201A", ink: "#F59A7C", accent: "sunrise/500" },
|
|
150
|
+
cars: { tint: "#2D2412", ink: "#F5C46A", accent: "marigold/500" },
|
|
151
|
+
rail: { tint: "#13291F", ink: "#7CCCAD", accent: "palm/500" }
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var darkRolesUnverified = ["border/selected"];
|
|
155
|
+
var spacing = {
|
|
156
|
+
xs: 4,
|
|
157
|
+
sm: 8,
|
|
158
|
+
md: 12,
|
|
159
|
+
lg: 16,
|
|
160
|
+
xl: 24,
|
|
161
|
+
"2xl": 32,
|
|
162
|
+
"3xl": 48,
|
|
163
|
+
"4xl": 64
|
|
164
|
+
};
|
|
165
|
+
var radius = {
|
|
166
|
+
xs: { value: 4, usage: "Checkboxes" },
|
|
167
|
+
sm: { value: 8, usage: "Tooltips, seats" },
|
|
168
|
+
md: { value: 12, usage: "Inputs, nav items" },
|
|
169
|
+
lg: { value: 16, usage: "Banners, toasts" },
|
|
170
|
+
xl: { value: 24, usage: "Cards" },
|
|
171
|
+
"2xl": { value: 32, usage: "Modals" },
|
|
172
|
+
full: { value: 9999, usage: "Buttons, chips" }
|
|
173
|
+
};
|
|
174
|
+
var elevation = {
|
|
175
|
+
raised: {
|
|
176
|
+
value: "0 6px 16px rgba(31, 29, 26, 0.06)",
|
|
177
|
+
dark: "none",
|
|
178
|
+
usage: "The booking card, popovers, the selected fare. No shadow in dark: the lighter surface does the lifting."
|
|
179
|
+
},
|
|
180
|
+
floating: {
|
|
181
|
+
value: "0 12px 32px rgba(31, 29, 26, 0.12)",
|
|
182
|
+
dark: "0 12px 32px rgba(10, 9, 8, 0.5)",
|
|
183
|
+
usage: "Modals, menus and toasts, over the scrim."
|
|
184
|
+
},
|
|
185
|
+
focus: {
|
|
186
|
+
value: "0 0 0 4px color-mix(in srgb, var(--af-bg-action) 30%, transparent)",
|
|
187
|
+
usage: "Every interactive element on keyboard focus."
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var fonts = {
|
|
191
|
+
ui: ['"Figtree Variable"', "Figtree", "ui-sans-serif", "system-ui", "sans-serif"],
|
|
192
|
+
voice: ['"Instrument Serif"', "ui-serif", "Georgia", "serif"],
|
|
193
|
+
code: ['"Geist Mono Variable"', '"Geist Mono"', "ui-monospace", "SFMono-Regular", "monospace"]
|
|
194
|
+
};
|
|
195
|
+
var typeStyles = {
|
|
196
|
+
display: { font: "ui", size: 40, lineHeight: 44, weight: 600, sample: "Book the 7:05 to LaGuardia" },
|
|
197
|
+
title: { font: "ui", size: 28, lineHeight: 34, weight: 600, sample: "Choose a fare for your round trip" },
|
|
198
|
+
heading: { font: "ui", size: 20, lineHeight: 28, weight: 600, sample: "Returning flights" },
|
|
199
|
+
body: { font: "ui", size: 15, lineHeight: 22, weight: 400, sample: "Arrival airport and dates come from the event." },
|
|
200
|
+
"body-strong": { font: "ui", size: 15, lineHeight: 22, weight: 600, sample: "7:20 AM \u2013 10:01 AM" },
|
|
201
|
+
label: { font: "ui", size: 13, lineHeight: 18, weight: 500, sample: "Delta \xB7 DL 2122" },
|
|
202
|
+
"label-strong": { font: "ui", size: 13, lineHeight: 18, weight: 600, sample: "Booked" },
|
|
203
|
+
eyebrow: {
|
|
204
|
+
font: "ui",
|
|
205
|
+
size: 13,
|
|
206
|
+
lineHeight: 18,
|
|
207
|
+
weight: 600,
|
|
208
|
+
uppercase: true,
|
|
209
|
+
letterSpacing: "0.08em",
|
|
210
|
+
sample: "Flights \xB7 Shopping list"
|
|
211
|
+
},
|
|
212
|
+
voice: { font: "voice", size: 40, lineHeight: 44, weight: 400, italic: true, sample: "Good evening, Kenneth." },
|
|
213
|
+
"voice-sm": { font: "voice", size: 28, lineHeight: 32, weight: 400, italic: true, sample: "You\u2019re all set, Maya." },
|
|
214
|
+
mono: { font: "code", size: 15, lineHeight: 22, weight: 400, sample: "DL 1482 \xB7 GXK4QP \xB7 $1,440.76" },
|
|
215
|
+
"mono-lg": { font: "code", size: 40, lineHeight: 44, weight: 500, sample: "$495,052.00" }
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
exports.primitives = primitives; exports.colorRoles = colorRoles; exports.colorRolesDark = colorRolesDark; exports.darkRolesUnverified = darkRolesUnverified; exports.spacing = spacing; exports.radius = radius; exports.elevation = elevation; exports.fonts = fonts; exports.typeStyles = typeStyles;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkHX7N52DBcjs = require('./chunk-HX7N52DB.cjs');
|
|
10
|
+
|
|
11
|
+
// src/tokens/css.ts
|
|
12
|
+
var prefix = "af";
|
|
13
|
+
function flattenRoles(tree, path = []) {
|
|
14
|
+
return Object.entries(tree).flatMap(([key, value]) => {
|
|
15
|
+
const next = [...path, key];
|
|
16
|
+
if (typeof value !== "string") return flattenRoles(value, next);
|
|
17
|
+
return [{ name: next.join("-"), figmaName: next.join("/"), group: next[0], ref: value }];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
var roles = flattenRoles(_chunkHX7N52DBcjs.colorRoles);
|
|
21
|
+
var darkRoles = flattenRoles(_chunkHX7N52DBcjs.colorRolesDark);
|
|
22
|
+
var darkClass = "dark";
|
|
23
|
+
function darkRoleFor(name) {
|
|
24
|
+
const role = darkRoles.find((item) => item.name === name);
|
|
25
|
+
if (!role) throw new Error(`Role "${name}" has no dark value`);
|
|
26
|
+
return role;
|
|
27
|
+
}
|
|
28
|
+
function isHex(ref) {
|
|
29
|
+
return /^#[0-9A-F]{6}$/.test(ref);
|
|
30
|
+
}
|
|
31
|
+
function splitAlpha(ref) {
|
|
32
|
+
const [base, alpha] = ref.split("@");
|
|
33
|
+
if (alpha === void 0) return { base, alpha: null };
|
|
34
|
+
const percent = Number(alpha);
|
|
35
|
+
if (!Number.isInteger(percent) || percent < 0 || percent > 99) throw new Error(`Bad opacity in "${ref}"`);
|
|
36
|
+
return { base, alpha: percent };
|
|
37
|
+
}
|
|
38
|
+
function resolveColor(ref) {
|
|
39
|
+
const { base } = splitAlpha(ref);
|
|
40
|
+
return isHex(base) ? base : resolvePrimitive(base);
|
|
41
|
+
}
|
|
42
|
+
function colorValue(ref) {
|
|
43
|
+
const { base, alpha } = splitAlpha(ref);
|
|
44
|
+
resolveColor(ref);
|
|
45
|
+
const solid = isHex(base) ? base : cssVar(primitiveName(base));
|
|
46
|
+
return alpha === null ? solid : `color-mix(in srgb, ${solid} ${alpha}%, transparent)`;
|
|
47
|
+
}
|
|
48
|
+
function cssVarName(name) {
|
|
49
|
+
return `--${prefix}-${name}`;
|
|
50
|
+
}
|
|
51
|
+
function cssVar(name) {
|
|
52
|
+
return `var(${cssVarName(name)})`;
|
|
53
|
+
}
|
|
54
|
+
function primitiveName(ref) {
|
|
55
|
+
return ref.replace("/", "-");
|
|
56
|
+
}
|
|
57
|
+
function resolvePrimitive(ref) {
|
|
58
|
+
const [scale, step] = ref.split("/");
|
|
59
|
+
const steps = _chunkHX7N52DBcjs.primitives[scale];
|
|
60
|
+
const value = _optionalChain([steps, 'optionalAccess', _ => _[step]]);
|
|
61
|
+
if (!value) throw new Error(`Unknown primitive "${ref}"`);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function rem(px) {
|
|
65
|
+
return `${px / 16}rem`;
|
|
66
|
+
}
|
|
67
|
+
function renderTokensCss() {
|
|
68
|
+
const groups = [];
|
|
69
|
+
groups.push(
|
|
70
|
+
Object.entries(_chunkHX7N52DBcjs.primitives).flatMap(
|
|
71
|
+
([scale, steps]) => Object.entries(steps).map(([step, value]) => `${cssVarName(`${scale}-${step}`)}: ${value};`)
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
groups.push(roles.map((role) => `${cssVarName(role.name)}: ${colorValue(role.ref)};`));
|
|
75
|
+
groups.push(Object.entries(_chunkHX7N52DBcjs.spacing).map(([key, px]) => `${cssVarName(`spacing-${key}`)}: ${rem(px)};`));
|
|
76
|
+
groups.push(Object.entries(_chunkHX7N52DBcjs.radius).map(([key, item]) => `${cssVarName(`radius-${key}`)}: ${item.value}px;`));
|
|
77
|
+
groups.push(Object.entries(_chunkHX7N52DBcjs.elevation).map(([key, item]) => `${cssVarName(`elevation-${key}`)}: ${item.value};`));
|
|
78
|
+
groups.push(Object.entries(_chunkHX7N52DBcjs.fonts).map(([key, stack]) => `${cssVarName(`font-${key}`)}: ${stack.join(", ")};`));
|
|
79
|
+
const indent = (lines) => lines.map((line) => ` ${line}`).join("\n");
|
|
80
|
+
const body = [["color-scheme: light;"], ...groups].map(indent).join("\n\n");
|
|
81
|
+
const darkLines = roles.map((role) => ({ light: role, dark: darkRoleFor(role.name) })).filter(({ light, dark }) => light.ref !== dark.ref).map(({ dark }) => `${cssVarName(dark.name)}: ${colorValue(dark.ref)};`);
|
|
82
|
+
const darkElevation = Object.entries(_chunkHX7N52DBcjs.elevation).flatMap(
|
|
83
|
+
([key, item]) => item.dark === void 0 ? [] : [`${cssVarName(`elevation-${key}`)}: ${item.dark};`]
|
|
84
|
+
);
|
|
85
|
+
const darkBody = [["color-scheme: dark;"], darkLines, darkElevation].map(indent).join("\n\n");
|
|
86
|
+
return `:root {
|
|
87
|
+
${body}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.${darkClass} {
|
|
91
|
+
${darkBody}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
exports.prefix = prefix; exports.flattenRoles = flattenRoles; exports.roles = roles; exports.darkRoles = darkRoles; exports.darkClass = darkClass; exports.darkRoleFor = darkRoleFor; exports.isHex = isHex; exports.splitAlpha = splitAlpha; exports.resolveColor = resolveColor; exports.cssVarName = cssVarName; exports.cssVar = cssVar; exports.primitiveName = primitiveName; exports.resolvePrimitive = resolvePrimitive; exports.rem = rem; exports.renderTokensCss = renderTokensCss;
|