@reqvire-org/ads 0.3.42 → 0.3.43

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.
Files changed (94) hide show
  1. package/README.md +6 -4
  2. package/dist/bootstrap-ds/ADS.md +2 -1
  3. package/dist/bootstrap-ds/README.md +23 -14
  4. package/dist/bootstrap-ds/design-system/components/Actions/Button/Button.ads.fixture.ts +1 -0
  5. package/dist/bootstrap-ds/design-system/components/Actions/Button/Button.ads.scenario.tsx +13 -0
  6. package/dist/bootstrap-ds/design-system/components/Actions/Button/Button.tsx +49 -0
  7. package/dist/bootstrap-ds/design-system/components/Actions/Button/README.md +12 -0
  8. package/dist/bootstrap-ds/design-system/components/Forms/TextField/README.md +14 -0
  9. package/dist/bootstrap-ds/design-system/components/Forms/TextField/TextField.ads.fixture.ts +6 -0
  10. package/dist/bootstrap-ds/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +13 -0
  11. package/dist/bootstrap-ds/design-system/components/Forms/TextField/TextField.tsx +57 -0
  12. package/dist/bootstrap-ds/design-system/composition/Search/SearchPage/README.md +4 -0
  13. package/dist/bootstrap-ds/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +7 -0
  14. package/dist/bootstrap-ds/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +16 -0
  15. package/dist/bootstrap-ds/design-system/index.ts +4 -1
  16. package/dist/bootstrap-ds/design-system/patterns/Search/SearchBar/README.md +12 -0
  17. package/dist/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +1 -0
  18. package/dist/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +11 -0
  19. package/dist/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.tsx +41 -0
  20. package/dist/bootstrap-ds/design-system/review/demo-frame/DemoFrame.tsx +29 -0
  21. package/dist/bootstrap-ds/design-system/review/index.ts +2 -0
  22. package/dist/bootstrap-ds/design-system/review/screen-frame/ScreenFrame.tsx +34 -0
  23. package/dist/bootstrap-ds/design-system/review/token-preview/TokenPreview.tsx +107 -19
  24. package/dist/bootstrap-ds/design-system/tokens/Color.ads.fixture.ts +18 -0
  25. package/dist/bootstrap-ds/design-system/tokens/{Foundation.ads.scenario.tsx → Color.ads.scenario.tsx} +1 -1
  26. package/dist/{skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Foundation.ads.fixture.ts → bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.fixture.ts} +1 -13
  27. package/dist/bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.scenario.tsx +4 -0
  28. package/dist/bootstrap-ds-preact/design-system/review/demo-frame/DemoFrame.tsx +29 -0
  29. package/dist/bootstrap-ds-preact/design-system/review/screen-frame/ScreenFrame.tsx +34 -0
  30. package/dist/bootstrap-ds-preact/design-system/review/token-preview/TokenPreview.tsx +119 -0
  31. package/dist/bootstrap-ds-preact/design-system/showcase/mcp/main.tsx +6 -0
  32. package/dist/bootstrap-ds-preact/ds.config.json +19 -0
  33. package/dist/bootstrap-ds-preact/package.json +38 -0
  34. package/dist/bootstrap-ds-preact/src/vite-env.d.ts +7 -0
  35. package/dist/bootstrap-ds-preact/tsconfig.json +36 -0
  36. package/dist/bootstrap-ds-preact/vite.config.ts +23 -0
  37. package/dist/init.mjs +15 -7
  38. package/dist/mcp/showcase-host.mjs +5 -1
  39. package/dist/preview-builder.mjs +8 -2
  40. package/dist/skills/ads-break-ui/SKILL.md +2 -2
  41. package/dist/skills/ads-designer/SKILL.md +33 -19
  42. package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +2 -1
  43. package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +23 -14
  44. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/Button.ads.fixture.ts +1 -0
  45. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/Button.ads.scenario.tsx +13 -0
  46. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/Button.tsx +49 -0
  47. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/README.md +12 -0
  48. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/README.md +14 -0
  49. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/TextField.ads.fixture.ts +6 -0
  50. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +13 -0
  51. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/TextField.tsx +57 -0
  52. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/Search/SearchPage/README.md +4 -0
  53. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +7 -0
  54. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +16 -0
  55. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/index.ts +4 -1
  56. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/README.md +12 -0
  57. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +1 -0
  58. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +11 -0
  59. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.tsx +41 -0
  60. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/demo-frame/DemoFrame.tsx +29 -0
  61. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/index.ts +2 -0
  62. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/screen-frame/ScreenFrame.tsx +34 -0
  63. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/token-preview/TokenPreview.tsx +107 -19
  64. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Color.ads.fixture.ts +18 -0
  65. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/{Foundation.ads.scenario.tsx → Color.ads.scenario.tsx} +1 -1
  66. package/dist/{bootstrap-ds/design-system/tokens/Foundation.ads.fixture.ts → skills/ads-designer/assets/bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.fixture.ts} +1 -13
  67. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.scenario.tsx +4 -0
  68. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/review/demo-frame/DemoFrame.tsx +29 -0
  69. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/review/screen-frame/ScreenFrame.tsx +34 -0
  70. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/review/token-preview/TokenPreview.tsx +119 -0
  71. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/showcase/mcp/main.tsx +6 -0
  72. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/ds.config.json +19 -0
  73. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/package.json +38 -0
  74. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/src/vite-env.d.ts +7 -0
  75. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/tsconfig.json +36 -0
  76. package/dist/skills/ads-designer/assets/bootstrap-ds-preact/vite.config.ts +23 -0
  77. package/dist/skills/ads-designer/references/cli.md +1 -1
  78. package/dist/skills/ads-designer/references/design-craft.md +1 -1
  79. package/dist/skills/ads-import/SKILL.md +2 -2
  80. package/dist/skills/ads-import/references/cli.md +1 -1
  81. package/dist/skills/ads-motion/SKILL.md +2 -2
  82. package/dist/skills/ads-port/SKILL.md +3 -3
  83. package/dist/skills/ads-port/references/cli.md +1 -1
  84. package/docs/ADS.md +7 -7
  85. package/docs/ARCHITECTURE.md +3 -2
  86. package/docs/CHANGELOG.md +33 -12
  87. package/docs/GUIDE.md +16 -14
  88. package/package.json +1 -1
  89. package/dist/bootstrap-ds/design-system/components/.gitkeep +0 -0
  90. package/dist/bootstrap-ds/design-system/composition/.gitkeep +0 -0
  91. package/dist/bootstrap-ds/design-system/patterns/.gitkeep +0 -0
  92. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/.gitkeep +0 -0
  93. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/.gitkeep +0 -0
  94. package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/.gitkeep +0 -0
package/README.md CHANGED
@@ -25,7 +25,7 @@ Data, UX, Skin, and the performance reasons behind that choice.
25
25
  ADS manages its batch-task cache internally; see [cache controls and CI wiring](docs/CACHING.md).
26
26
 
27
27
  ADS supports **React and native Preact** with the same architecture guards and
28
- MCP preview flow. The empty starter uses React; this repository’s working example
28
+ MCP preview flow. The starter comes for React and for Preact; this repository’s working example
29
29
  uses Preact. See [implementation support](docs/GUIDE.md#implementation-support).
30
30
 
31
31
  ## What ADS does
@@ -233,7 +233,7 @@ happens automatically; no separate project showcase rebuild is needed.
233
233
 
234
234
  For an existing app, `init` adds the showcase launch script; it does not install
235
235
  a preview compiler. Integrate the [starter compiler and mount adapter](docs/GUIDE.md#showcase)
236
- with your build. The copied empty starter already includes that setup.
236
+ with your build. The copied starter already includes that setup.
237
237
 
238
238
  There are no required showcase page files. Add a colocated scenario and fixture
239
239
  for tokens and each public UI owner; larger entries live under `composition/`.
@@ -336,8 +336,10 @@ The [dummy project](tests/fixtures/guard-project/README.md) tests the generic gu
336
336
 
337
337
  There are two different starting points in this checkout:
338
338
 
339
- - [bootstrap-ds/](bootstrap-ds/README.md) is an empty React application starter:
340
- token defaults, build setup, empty product component folders, a development-only token review renderer, and a project preview compiler adapter. It is bundled with `ads-designer` so an agent can copy it when starting
339
+ - [bootstrap-ds/](bootstrap-ds/README.md) is the React application starter, and
340
+ [bootstrap-ds-preact/](bootstrap-ds-preact/) the files that make it Preact:
341
+ token defaults in two groups, build setup, one example component in each of two groups,
342
+ a pattern and a composition, development-only review renderers, and a project preview compiler adapter. It is bundled with `ads-designer` so an agent can copy it when starting
341
343
  from zero. `ads init` uses its empty foundation files when a project has no ADS.
342
344
  - [design-system/](design-system/README.md) is this repository's working example,
343
345
  with real components, patterns, and scenarios inspected through the built-in showcase. It demonstrates the architecture
@@ -24,7 +24,8 @@ The starter declares React in `ds.config.json`. Keep that choice, JSX, runtime
24
24
  dependencies and the preview mount adapter consistent. Init records a choice for
25
25
  an unconfigured project; it does not convert copied React source to Preact.
26
26
 
27
- The starter has no components or patterns yet. Add only what the product needs.
27
+ The starter has one example of each layer (Button, TextField, SearchBar,
28
+ SearchPage). Rename, restyle or replace them; add only what the product needs.
28
29
  Keep the ADS in root `design-system/`, beside application `src/`.
29
30
  Keep public exports in `design-system/index.ts`; consumers use its `@ds` alias.
30
31
  `styles.css` is the foundation CSS entry and contains token imports only.
@@ -1,9 +1,13 @@
1
- # Empty native design system
1
+ # Starter native design system
2
2
 
3
- This private React/TypeScript workspace contains semantic CSS tokens, a project-owned
3
+ This private React or Preact TypeScript workspace contains semantic CSS tokens, a project-owned
4
4
  token review renderer, a public barrel, Linaria extraction and a preview compiler
5
- adapter. It has no product components, icons, fonts or example screens. The minimal showcase
6
- shell and MCP client come from ADS tooling.
5
+ adapter, plus one example of each layer to build on: two token groups (Color; Space, type &
6
+ motion), two components in two groups (`components/Actions/Button`,
7
+ `components/Forms/TextField`), one pattern (`patterns/Search/SearchBar`) and one
8
+ composition (`composition/Search/SearchPage`). Rename, restyle or replace them as the
9
+ product's own; it has no icons or fonts. The minimal showcase shell and MCP client
10
+ come from ADS tooling.
7
11
 
8
12
  Read the local [contract](ADS.md) and the
9
13
  [architecture](https://github.com/reqvire-org/ads/blob/main/docs/ARCHITECTURE.md).
@@ -11,12 +15,15 @@ Read the local [contract](ADS.md) and the
11
15
  ## Start
12
16
 
13
17
  Copy the contents of `bootstrap-ds/`, including dotfiles, into a new project.
14
- The installed `ads-designer` skill contains the same files in
15
- `assets/bootstrap-ds/`. Set the project name in `package.json`. Install Bun 1.4.1+ for ADS tooling and previews. The application can keep its
18
+ It is the React starter. For Preact, then copy `bootstrap-ds-preact/` over it
19
+ (its package, compiler settings, scenario mount, token preview and scenario
20
+ types) and delete the React `package-lock.json`. The installed `ads-designer`
21
+ skill contains the same files in `assets/bootstrap-ds/` and
22
+ `assets/bootstrap-ds-preact/`. Set the project name in `package.json`. Install Bun 1.4.1+ for ADS tooling and previews. The application can keep its
16
23
  Node/npm build pipeline. Use a current ADS release.
17
24
 
18
25
  ```sh
19
- npx @reqvire-org/ads init --framework react
26
+ npx @reqvire-org/ads init --framework react # or preact
20
27
  npm install
21
28
  npm run build
22
29
  npm run dev:showcase
@@ -40,10 +47,10 @@ Bun projects and preserves their scripts/lockfiles. Use `bun install` and
40
47
 
41
48
  For an existing application, merge only the ADS source and required extraction,
42
49
  aliases and preview adapter. Preserve its framework, entry points and build.
43
- The starter declares `"framework": "react"` in `ds.config.json`. For an existing
44
- native Preact app without a saved ADS framework, use `ads init --framework preact`.
45
- Init records that choice and generates native hook imports without migrating the
46
- app or rewriting its compiler. Subsequent init runs reuse the saved choice.
50
+ Each starter declares its framework in `ds.config.json`. For an existing app
51
+ without a saved ADS framework, use `ads init --framework react` or
52
+ `--framework preact`. Init records that choice and adds that framework's token
53
+ preview and scenario mount without migrating the app or rewriting its compiler. Subsequent init runs reuse the saved choice.
47
54
  Init adds missing foundation files and connects architectural checks; it does
48
55
  not configure Linaria or generate product component source. Generated `.ds/` files are
49
56
  ignored; original artwork and provenance belong in `assets/brand/`.
@@ -51,14 +58,16 @@ ignored; original artwork and provenance belong in `assets/brand/`.
51
58
  ## Inspect and add UI
52
59
 
53
60
  When an agent already runs `ads mcp`, open its `ads_status.showcaseUrl`. MCP starts
54
- the website automatically. Otherwise `npm run dev:showcase` runs `ads showcase`.
61
+ the website automatically. Otherwise `npm run dev:showcase` runs `ads showcase`; give it a port the ADS MCP
62
+ does not use, since both serve a showcase.
55
63
  Its shell is minimal: tabs, collapsible left menu, theme switch and App slot.
56
64
  Its MCP client discovers entries, invokes preview tools and follows notifications.
57
65
  There are no required TokensPage/ComponentsPage/PatternsPage/CompositionPage
58
66
  files, and no separate project browser app to implement or rebuild.
59
67
 
60
- The existing `tokens/Foundation.ads.scenario.tsx` and colocated fixture visually demonstrate all
61
- starter token values. The fixture owns `{ token, property, probe }` bindings;
68
+ The `tokens/Color.ads.scenario.tsx` and `tokens/SpaceTypeMotion.ads.scenario.tsx`
69
+ groups and their colocated fixtures visually demonstrate all starter token values,
70
+ one tile per token with its current value. The fixture owns `{ token, property, probe }` bindings;
62
71
  the development-only `TokenPreview` renderer, exported through `@ds/review`, owns their presentation and applies the real CSS
63
72
  variables. Add/remove samples alongside token definitions. `ads check` rejects
64
73
  missing coverage and invented names; the App verifies the declared CSS bindings
@@ -0,0 +1 @@
1
+ export const fixture = { title: "Button", primary: "Save", secondary: "Cancel", disabled: "Unavailable" } as const;
@@ -0,0 +1,13 @@
1
+ import { Button } from "@ds";
2
+ import { DemoFrame } from "@ds/review";
3
+ import { fixture } from "./Button.ads.fixture";
4
+ export const scenario = { title: fixture.title, covers: ["Button"] };
5
+ export default function Scenario() {
6
+ return (
7
+ <DemoFrame>
8
+ <Button label={fixture.primary} variant="primary" />
9
+ <Button label={fixture.secondary} />
10
+ <Button label={fixture.disabled} disabled />
11
+ </DemoFrame>
12
+ );
13
+ }
@@ -0,0 +1,49 @@
1
+ import { css, cx } from "@linaria/atomic";
2
+
3
+ export interface ButtonProps {
4
+ label: string;
5
+ /** `primary` for the main action of a view; `secondary` for the others. */
6
+ variant?: "primary" | "secondary";
7
+ type?: "button" | "submit";
8
+ disabled?: boolean;
9
+ onClick?: () => void;
10
+ }
11
+
12
+ const base = css`
13
+ display: inline-flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ padding-block: var(--space-4);
17
+ padding-inline: var(--space-8);
18
+ border-width: var(--border-w);
19
+ border-style: solid;
20
+ border-color: transparent;
21
+ border-radius: var(--radius-md);
22
+ font-size: var(--text-base);
23
+ font-weight: var(--weight-semibold);
24
+ line-height: var(--leading-normal);
25
+ cursor: pointer;
26
+ &:disabled { cursor: default; opacity: 0.5; }
27
+ `;
28
+ const variants = {
29
+ primary: css`
30
+ background: var(--accent);
31
+ color: var(--accent-fg);
32
+ &:hover:not(:disabled) { background: var(--accent-hover); }
33
+ `,
34
+ secondary: css`
35
+ background: var(--bg-surface);
36
+ border-color: var(--border-default);
37
+ color: var(--text-body);
38
+ &:hover:not(:disabled) { border-color: var(--accent); }
39
+ `,
40
+ };
41
+
42
+ /** A labelled action. */
43
+ export function Button({ label, variant = "secondary", type = "button", disabled, onClick }: ButtonProps) {
44
+ return (
45
+ <button type={type} className={cx("ds-button", base, variants[variant])} disabled={disabled} onClick={onClick}>
46
+ {label}
47
+ </button>
48
+ );
49
+ }
@@ -0,0 +1,12 @@
1
+ # Button
2
+
3
+ A labelled action. `variant="primary"` marks the main action of a view; other actions use the
4
+ default `secondary`. `type="submit"` submits its form.
5
+
6
+ | Prop | Type | Default |
7
+ |---|---|---|
8
+ | `label` | `string` | — |
9
+ | `variant` | `"primary" \| "secondary"` | `"secondary"` |
10
+ | `type` | `"button" \| "submit"` | `"button"` |
11
+ | `disabled` | `boolean` | `false` |
12
+ | `onClick` | `() => void` | — |
@@ -0,0 +1,14 @@
1
+ # TextField
2
+
3
+ A labelled single-line text input. `id` ties the label to the input. Pass `value` and
4
+ `onValueChange` to own its value, or only `name` to let a form read it on submit.
5
+
6
+ | Prop | Type | Default |
7
+ |---|---|---|
8
+ | `id` | `string` | — |
9
+ | `label` | `string` | — |
10
+ | `name` | `string` | — |
11
+ | `placeholder` | `string` | — |
12
+ | `value` | `string` | — |
13
+ | `disabled` | `boolean` | `false` |
14
+ | `onValueChange` | `(value: string) => void` | — |
@@ -0,0 +1,6 @@
1
+ export const fixture = {
2
+ title: "Text field",
3
+ email: { id: "text-field-email", label: "Email", placeholder: "you@example.com" },
4
+ filled: { id: "text-field-name", label: "Name", value: "Ada Lovelace" },
5
+ disabled: { id: "text-field-disabled", label: "Team", value: "Design", disabled: true },
6
+ } as const;
@@ -0,0 +1,13 @@
1
+ import { TextField } from "@ds";
2
+ import { DemoFrame } from "@ds/review";
3
+ import { fixture } from "./TextField.ads.fixture";
4
+ export const scenario = { title: fixture.title, covers: ["TextField"] };
5
+ export default function Scenario() {
6
+ return (
7
+ <DemoFrame layout="column">
8
+ <TextField {...fixture.email} />
9
+ <TextField {...fixture.filled} />
10
+ <TextField {...fixture.disabled} />
11
+ </DemoFrame>
12
+ );
13
+ }
@@ -0,0 +1,57 @@
1
+ import { css, cx } from "@linaria/atomic";
2
+
3
+ export interface TextFieldProps {
4
+ /** Ties the label to the input. */
5
+ id: string;
6
+ label: string;
7
+ /** The form field name its value is submitted under. */
8
+ name?: string;
9
+ placeholder?: string;
10
+ /** The current value; without it the field keeps its own. */
11
+ value?: string;
12
+ disabled?: boolean;
13
+ onValueChange?: (value: string) => void;
14
+ }
15
+
16
+ const field = css`
17
+ display: flex;
18
+ flex-direction: column;
19
+ gap: var(--space-2);
20
+ min-width: 0;
21
+ `;
22
+ const labelStyle = css`
23
+ font-size: var(--text-sm);
24
+ font-weight: var(--weight-semibold);
25
+ color: var(--text-body);
26
+ `;
27
+ const input = css`
28
+ padding-block: var(--space-4);
29
+ padding-inline: var(--space-4);
30
+ border: var(--border-w) solid var(--border-default);
31
+ border-radius: var(--radius-md);
32
+ background: var(--bg-surface);
33
+ color: var(--text-body);
34
+ font-size: var(--text-base);
35
+ line-height: var(--leading-normal);
36
+ &::placeholder { color: var(--text-muted); }
37
+ &:disabled { opacity: 0.5; }
38
+ `;
39
+
40
+ /** A labelled single-line text input. */
41
+ export function TextField({ id, label, name, placeholder, value, disabled, onValueChange }: TextFieldProps) {
42
+ return (
43
+ <div className={cx("ds-text-field", field)}>
44
+ <label className={labelStyle} htmlFor={id}>{label}</label>
45
+ <input
46
+ id={id}
47
+ className={input}
48
+ name={name}
49
+ type="text"
50
+ placeholder={placeholder}
51
+ value={value}
52
+ disabled={disabled}
53
+ onInput={event => onValueChange?.(event.currentTarget.value)}
54
+ />
55
+ </div>
56
+ );
57
+ }
@@ -0,0 +1,4 @@
1
+ # Search page
2
+
3
+ A review-only screen in the review `ScreenFrame`: the `SearchBar` pattern and a secondary `Button`. Compositions
4
+ show how public components and patterns fit together; they are not exported from `@ds`.
@@ -0,0 +1,7 @@
1
+ export const fixture = {
2
+ title: "Search page",
3
+ heading: "Find anything in the design system",
4
+ description: "Search tokens, components and patterns by name.",
5
+ search: { id: "search-page-query", label: "Search", placeholder: "Button, colors, search…" },
6
+ browse: "Browse all components",
7
+ } as const;
@@ -0,0 +1,16 @@
1
+ import { Button, SearchBar } from "@ds";
2
+ import { ScreenFrame } from "@ds/review";
3
+ import { fixture } from "./SearchPage.ads.fixture";
4
+
5
+ // A screen composed from public parts, for review only: it is not exported from @ds.
6
+ export const scenario = { title: fixture.title, covers: ["SearchBar", "Button"] };
7
+ export default function Scenario() {
8
+ return (
9
+ <ScreenFrame title={fixture.heading} description={fixture.description}>
10
+ <SearchBar {...fixture.search} />
11
+ <div>
12
+ <Button label={fixture.browse} />
13
+ </div>
14
+ </ScreenFrame>
15
+ );
16
+ }
@@ -1,4 +1,7 @@
1
1
  // Load local foundation styles; the compile check also extracts dist/styles.css.
2
2
  import "./styles.css";
3
3
 
4
- // Add public component and pattern exports here as they are implemented.
4
+ // Public components and patterns. Add new ones here as they are implemented.
5
+ export { Button, type ButtonProps } from "./components/Actions/Button/Button";
6
+ export { TextField, type TextFieldProps } from "./components/Forms/TextField/TextField";
7
+ export { SearchBar, type SearchBarProps } from "./patterns/Search/SearchBar/SearchBar";
@@ -0,0 +1,12 @@
1
+ # SearchBar
2
+
3
+ A search form built from `TextField` and a primary `Button`. Enter or the button calls
4
+ `onSearch` with the trimmed query; the page decides what searching means.
5
+
6
+ | Prop | Type | Default |
7
+ |---|---|---|
8
+ | `id` | `string` | — |
9
+ | `label` | `string` | — |
10
+ | `placeholder` | `string` | — |
11
+ | `submitLabel` | `string` | `"Search"` |
12
+ | `onSearch` | `(query: string) => void` | — |
@@ -0,0 +1 @@
1
+ export const fixture = { title: "Search bar", id: "search-bar-query", label: "Search the docs", placeholder: "Tokens, components…" } as const;
@@ -0,0 +1,11 @@
1
+ import { SearchBar } from "@ds";
2
+ import { DemoFrame } from "@ds/review";
3
+ import { fixture } from "./SearchBar.ads.fixture";
4
+ export const scenario = { title: fixture.title, covers: ["SearchBar"] };
5
+ export default function Scenario() {
6
+ return (
7
+ <DemoFrame layout="column">
8
+ <SearchBar id={fixture.id} label={fixture.label} placeholder={fixture.placeholder} />
9
+ </DemoFrame>
10
+ );
11
+ }
@@ -0,0 +1,41 @@
1
+ import { css, cx } from "@linaria/atomic";
2
+ import { Button } from "../../../components/Actions/Button/Button";
3
+ import { TextField } from "../../../components/Forms/TextField/TextField";
4
+
5
+ export interface SearchBarProps {
6
+ id: string;
7
+ label: string;
8
+ placeholder?: string;
9
+ submitLabel?: string;
10
+ /** Called with the typed query when the person searches. */
11
+ onSearch?: (query: string) => void;
12
+ }
13
+
14
+ const form = css`
15
+ display: flex;
16
+ align-items: flex-end;
17
+ gap: var(--space-4);
18
+ `;
19
+ const query = css`
20
+ flex: 1;
21
+ min-width: 0;
22
+ `;
23
+
24
+ /** A search field with its submit action: Enter or the button searches. */
25
+ export function SearchBar({ id, label, placeholder, submitLabel = "Search", onSearch }: SearchBarProps) {
26
+ return (
27
+ <form
28
+ role="search"
29
+ className={cx("ds-search-bar", form)}
30
+ onSubmit={event => {
31
+ event.preventDefault();
32
+ onSearch?.(String(new FormData(event.currentTarget).get("query") ?? "").trim());
33
+ }}
34
+ >
35
+ <div className={query}>
36
+ <TextField id={id} label={label} name="query" placeholder={placeholder} />
37
+ </div>
38
+ <Button label={submitLabel} variant="primary" type="submit" />
39
+ </form>
40
+ );
41
+ }
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from "react";
2
+ import { css, cx } from "@linaria/atomic";
3
+
4
+ export interface DemoFrameProps {
5
+ /** `row` lays examples side by side; `column` stacks them at a readable width. */
6
+ layout?: "row" | "column";
7
+ children?: ReactNode;
8
+ }
9
+
10
+ const frame = css`
11
+ display: flex;
12
+ gap: var(--space-8);
13
+ padding: var(--space-12);
14
+ `;
15
+ const layouts = {
16
+ row: css`
17
+ flex-wrap: wrap;
18
+ align-items: flex-start;
19
+ `,
20
+ column: css`
21
+ flex-direction: column;
22
+ max-width: calc(var(--space-16) * 12);
23
+ `,
24
+ };
25
+
26
+ /** Development-only framing for component and pattern scenarios: spacing between examples. */
27
+ export function DemoFrame({ layout = "row", children }: DemoFrameProps) {
28
+ return <div className={cx(frame, layouts[layout])}>{children}</div>;
29
+ }
@@ -1 +1,3 @@
1
1
  export { TokenPreview } from "./token-preview/TokenPreview";
2
+ export { ScreenFrame } from "./screen-frame/ScreenFrame";
3
+ export { DemoFrame } from "./demo-frame/DemoFrame";
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from "react";
2
+ import { css } from "@linaria/atomic";
3
+
4
+ export interface ScreenFrameProps { title: string; description?: string; children?: ReactNode; }
5
+
6
+ const frame = css`
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: var(--space-8);
10
+ max-width: calc(var(--space-16) * 20);
11
+ padding: var(--space-12);
12
+ `;
13
+ const heading = css`
14
+ margin: 0;
15
+ font-size: var(--text-xl);
16
+ font-weight: var(--weight-semibold);
17
+ line-height: var(--leading-tight);
18
+ color: var(--text-strong);
19
+ `;
20
+ const lead = css`
21
+ margin: 0;
22
+ color: var(--text-muted);
23
+ `;
24
+
25
+ /** Development-only page framing for composition scenarios: a heading and the page width. */
26
+ export function ScreenFrame({ title, description, children }: ScreenFrameProps) {
27
+ return (
28
+ <main className={frame}>
29
+ <h1 className={heading}>{title}</h1>
30
+ {description ? <p className={lead}>{description}</p> : null}
31
+ {children}
32
+ </main>
33
+ );
34
+ }
@@ -1,31 +1,119 @@
1
- import { useLayoutEffect, useRef } from "react";
1
+ import { useLayoutEffect, useRef, useState } from "react";
2
2
  import { css, cx } from "@linaria/atomic";
3
3
 
4
4
  export interface TokenSample { token: `--${string}`; property: string; }
5
5
  export interface TokenPreviewProps { title: string; samples: readonly TokenSample[]; text: string; }
6
+
7
+ const grid = css`
8
+ display: grid;
9
+ grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-8) * 10), 1fr));
10
+ gap: var(--space-8);
11
+ padding: var(--space-8);
12
+ `;
13
+ const heading = css`
14
+ grid-column: 1 / -1;
15
+ margin: 0;
16
+ font-size: var(--text-base);
17
+ font-weight: var(--weight-semibold);
18
+ color: var(--text-body);
19
+ `;
20
+ const tile = css`
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: var(--space-4);
24
+ padding: var(--space-8);
25
+ border: var(--border-w) solid var(--border-default);
26
+ border-radius: var(--radius-md);
27
+ background: var(--bg-surface);
28
+ overflow: hidden;
29
+ `;
30
+ const label = css`
31
+ font-size: var(--text-sm);
32
+ color: var(--text-muted);
33
+ overflow-wrap: anywhere;
34
+ `;
35
+ // Each sample shows its token through the property it styles: colors as swatches, lengths as
36
+ // bars, radius as a shape, type as text.
6
37
  const sampleStyle = css`
7
- display: inline-block;
8
- position: relative;
9
- white-space: pre-line;
10
- &[data-ads-property="animation-duration"] { animation-duration: var(--ux-token-preview-value); }
11
- &[data-ads-property="animation-timing-function"] { animation-timing-function: var(--ux-token-preview-value); }
12
- &[data-ads-property="background-color"] { background-color: var(--ux-token-preview-value); }
13
- &[data-ads-property="border-radius"] { border-radius: var(--ux-token-preview-value); }
14
- &[data-ads-property="box-shadow"] { box-shadow: var(--ux-token-preview-value); }
15
- &[data-ads-property="color"] { color: var(--ux-token-preview-value); }
16
- &[data-ads-property="font-family"] { font-family: var(--ux-token-preview-value); }
38
+ display: block;
39
+ min-height: calc(var(--space-8) * 2);
40
+ color: var(--text-body);
41
+ font-size: var(--text-base);
42
+ &[data-ads-property="background-color"] {
43
+ border: var(--border-w) solid var(--border-default);
44
+ border-radius: var(--radius-md);
45
+ background-color: var(--ux-token-preview-value);
46
+ }
47
+ &[data-ads-property="color"] { color: var(--ux-token-preview-value); font-size: calc(var(--text-base) * 2); line-height: 1; }
48
+ &[data-ads-property="width"] {
49
+ width: var(--ux-token-preview-value);
50
+ min-height: var(--space-8);
51
+ background: var(--accent);
52
+ }
53
+ &[data-ads-property="border-radius"] {
54
+ width: calc(var(--space-8) * 3);
55
+ border: var(--focus-w) solid var(--accent);
56
+ border-radius: var(--ux-token-preview-value);
57
+ }
58
+ &[data-ads-property="font-family"] { font-family: var(--ux-token-preview-value); font-size: calc(var(--text-base) * 2); line-height: 1; }
17
59
  &[data-ads-property="font-size"] { font-size: var(--ux-token-preview-value); }
18
- &[data-ads-property="font-weight"] { font-weight: var(--ux-token-preview-value); }
60
+ &[data-ads-property="font-weight"] { font-weight: var(--ux-token-preview-value); font-size: calc(var(--text-base) * 2); line-height: 1; }
19
61
  &[data-ads-property="line-height"] { line-height: var(--ux-token-preview-value); }
20
- &[data-ads-property="width"] { width: var(--ux-token-preview-value); }
21
- &[data-ads-property="z-index"] { z-index: var(--ux-token-preview-value); }
62
+ &[data-ads-property="box-shadow"] {
63
+ border-radius: var(--radius-md);
64
+ background: var(--bg-surface);
65
+ box-shadow: var(--ux-token-preview-value);
66
+ }
67
+ /* Durations and easing move a dot across the tile. */
68
+ &[data-ads-property="animation-duration"], &[data-ads-property="animation-timing-function"] {
69
+ width: var(--space-8);
70
+ border-radius: 50%;
71
+ background: var(--accent);
72
+ animation-name: ux-token-preview-travel;
73
+ animation-iteration-count: infinite;
74
+ animation-direction: alternate;
75
+ }
76
+ &[data-ads-property="animation-duration"] {
77
+ animation-duration: calc(var(--ux-token-preview-value) * 8);
78
+ animation-timing-function: var(--ease-standard);
79
+ }
80
+ &[data-ads-property="animation-timing-function"] {
81
+ animation-duration: calc(var(--dur-normal) * 6);
82
+ animation-timing-function: var(--ux-token-preview-value);
83
+ }
84
+ &[data-ads-property="z-index"] { z-index: var(--ux-token-preview-value); position: relative; }
85
+ @keyframes ux-token-preview-travel { to { transform: translateX(calc(var(--space-8) * 6)); } }
22
86
  `;
23
- function Sample({ sample, text }: { sample: TokenSample; text: string }) {
87
+
88
+ function TokenTile({ sample, text }: { sample: TokenSample; text: string }) {
24
89
  const ref = useRef<HTMLSpanElement>(null);
25
- useLayoutEffect(() => { ref.current?.style.setProperty("--ux-token-preview-value", `var(${sample.token})`); }, [sample.token]);
26
- return <span ref={ref} className={cx("ux-token-preview__sample", sampleStyle)} data-ads-token={sample.token} data-ads-property={sample.property}>{text}</span>;
90
+ const [value, setValue] = useState("");
91
+ useLayoutEffect(() => {
92
+ ref.current?.style.setProperty("--ux-token-preview-value", `var(${sample.token})`);
93
+ // The value as the page computes it now, again when the theme changes.
94
+ const read = () => setValue(getComputedStyle(document.documentElement).getPropertyValue(sample.token).trim());
95
+ read();
96
+ const observer = new MutationObserver(read);
97
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
98
+ return () => observer.disconnect();
99
+ }, [sample.token]);
100
+ return (
101
+ <article className={cx("ux-token-preview__item", tile)}>
102
+ <span ref={ref} className={cx("ux-token-preview__sample", sampleStyle)} data-ads-token={sample.token} data-ads-property={sample.property}>
103
+ {["background-color", "width", "border-radius", "box-shadow", "animation-duration", "animation-timing-function"].includes(sample.property) ? "" : text}
104
+ </span>
105
+ <code className={cx("ux-token-preview__name", label)}>{sample.token}</code>
106
+ <small className={label}>{value}</small>
107
+ </article>
108
+ );
27
109
  }
28
- /** Project-owned review UI. Values always come from the real foundation CSS. */
110
+
111
+ /** Project-owned review UI: one tile per token. Values always come from the real foundation CSS. */
29
112
  export function TokenPreview({ title, samples, text }: TokenPreviewProps) {
30
- return <section className="ux-token-preview"><h1>{title}</h1>{samples.map(sample => <div key={`${sample.token}:${sample.property}`} className="ux-token-preview__item"><code className="ux-token-preview__name">{sample.token}</code><Sample sample={sample} text={text}/></div>)}</section>;
113
+ return (
114
+ <section aria-label={title} className={cx("ux-token-preview", grid)}>
115
+ <h1 className={heading}>{title}</h1>
116
+ {samples.map(sample => <TokenTile key={`${sample.token}:${sample.property}`} sample={sample} text={text} />)}
117
+ </section>
118
+ );
31
119
  }
@@ -0,0 +1,18 @@
1
+ export const fixture = {
2
+ "title": "Color",
3
+ "text": "Aa",
4
+ samples: [
5
+ {"token": "--accent", "property": "background-color", "probe": "rgb(31, 97, 163)"},
6
+ {"token": "--accent-fg", "property": "background-color", "probe": "rgb(31, 97, 163)"},
7
+ {"token": "--accent-hover", "property": "background-color", "probe": "rgb(31, 97, 163)"},
8
+ {"token": "--bg-canvas", "property": "background-color", "probe": "rgb(31, 97, 163)"},
9
+ {"token": "--bg-hover", "property": "background-color", "probe": "rgb(31, 97, 163)"},
10
+ {"token": "--bg-surface", "property": "background-color", "probe": "rgb(31, 97, 163)"},
11
+ {"token": "--border-default", "property": "background-color", "probe": "rgb(31, 97, 163)"},
12
+ {"token": "--border-focus", "property": "background-color", "probe": "rgb(31, 97, 163)"},
13
+ {"token": "--text-body", "property": "color", "probe": "rgb(31, 97, 163)"},
14
+ {"token": "--text-inverse", "property": "color", "probe": "rgb(31, 97, 163)"},
15
+ {"token": "--text-muted", "property": "color", "probe": "rgb(31, 97, 163)"},
16
+ {"token": "--text-strong", "property": "color", "probe": "rgb(31, 97, 163)"},
17
+ ]
18
+ } as const;
@@ -1,4 +1,4 @@
1
1
  import { TokenPreview } from "@ds/review";
2
- import { fixture } from "./Foundation.ads.fixture";
2
+ import { fixture } from "./Color.ads.fixture";
3
3
  export const scenario = { title: fixture.title, covers: ["TokenPreview"], samples: fixture.samples };
4
4
  export default function Scenario() { return <TokenPreview {...fixture} />; }