@designtools/blocks 0.0.0-stage → 0.1.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 +9 -0
- package/LICENSE +21 -0
- package/README.md +117 -2
- package/dist/cli.js +381 -0
- package/package.json +59 -3
- package/registry/a11y-panel.tsx +99 -0
- package/registry/adherence-summary.tsx +110 -0
- package/registry/agent-view.tsx +57 -0
- package/registry/anatomy.tsx +88 -0
- package/registry/ask-claude.tsx +71 -0
- package/registry/code-view.tsx +74 -0
- package/registry/examples.tsx +96 -0
- package/registry/glossary.tsx +58 -0
- package/registry/imagery.tsx +39 -0
- package/registry/lib/adherence-types.ts +179 -0
- package/registry/lib/boundary.tsx +21 -0
- package/registry/lib/contrast.ts +44 -0
- package/registry/lib/cx.ts +4 -0
- package/registry/lib/jsx.ts +29 -0
- package/registry/lib/lookup.tsx +46 -0
- package/registry/lib/manifest-types.ts +273 -0
- package/registry/lib/manifest.ts +182 -0
- package/registry/lib/markdown.ts +283 -0
- package/registry/lib/status.tsx +30 -0
- package/registry/lib/text.tsx +27 -0
- package/registry/logo-usage.tsx +87 -0
- package/registry/pattern.tsx +68 -0
- package/registry/playground.tsx +180 -0
- package/registry/preview-frame.tsx +106 -0
- package/registry/props-table.tsx +110 -0
- package/registry/registry.generated.tsx +9 -0
- package/registry/rule.tsx +98 -0
- package/registry/scale.tsx +115 -0
- package/registry/shell.tsx +184 -0
- package/registry/standards.tsx +45 -0
- package/registry/swatches.tsx +146 -0
- package/registry/tsconfig.json +13 -0
- package/registry/type-ramp.tsx +105 -0
- package/registry/usage.tsx +72 -0
- package/registry/variant-matrix.tsx +105 -0
- package/registry/voice-terms.tsx +45 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { coerce, componentFor, Missing } from "./lib/lookup";
|
|
5
|
+
import type { ComponentEntry, VariantAxis } from "./lib/manifest-types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Every variant, rendered live. The first two axes form a grid; each further
|
|
9
|
+
* axis gets its own row, with the others at their defaults. Pass `props` for
|
|
10
|
+
* anything the component needs to render (an `options` list, a `value`).
|
|
11
|
+
*/
|
|
12
|
+
export function VariantMatrix({
|
|
13
|
+
entry,
|
|
14
|
+
props = {},
|
|
15
|
+
children,
|
|
16
|
+
axes: only,
|
|
17
|
+
}: {
|
|
18
|
+
entry: ComponentEntry;
|
|
19
|
+
props?: Record<string, unknown>;
|
|
20
|
+
/** What to render inside each instance. Defaults to the component's name. */
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/** Limit and order the axes shown. */
|
|
23
|
+
axes?: string[];
|
|
24
|
+
}) {
|
|
25
|
+
const Component = componentFor(entry);
|
|
26
|
+
const all = entry.variants?.axes ?? [];
|
|
27
|
+
const axes = only ? only.map((n) => all.find((a) => a.name === n)).filter((a): a is VariantAxis => !!a) : all;
|
|
28
|
+
if (!Component) return <Missing name={entry.name} />;
|
|
29
|
+
if (axes.length === 0) return <p className="text-sm text-muted-foreground">{entry.name} has no variants.</p>;
|
|
30
|
+
|
|
31
|
+
const content = children ?? entry.name;
|
|
32
|
+
const render = (extra: Record<string, string>) => (
|
|
33
|
+
<Component {...props} {...coerce(extra)}>
|
|
34
|
+
{content}
|
|
35
|
+
</Component>
|
|
36
|
+
);
|
|
37
|
+
const [rows, cols, ...rest] = axes;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div data-slot="variant-matrix" className="flex flex-col gap-8">
|
|
41
|
+
{cols ? (
|
|
42
|
+
<div className="overflow-x-auto">
|
|
43
|
+
<table className="border-collapse text-sm">
|
|
44
|
+
<caption className="sr-only">
|
|
45
|
+
{entry.name}: {rows.name} by {cols.name}
|
|
46
|
+
</caption>
|
|
47
|
+
<thead>
|
|
48
|
+
<tr>
|
|
49
|
+
<th scope="col" className="p-2 text-left text-xs font-normal text-muted-foreground">
|
|
50
|
+
<span className="font-mono">{rows.name}</span> \ <span className="font-mono">{cols.name}</span>
|
|
51
|
+
</th>
|
|
52
|
+
{cols.options.map((c) => (
|
|
53
|
+
<th key={c.name} scope="col" className="p-2 text-left font-mono text-xs font-medium">
|
|
54
|
+
{label(cols, c.name)}
|
|
55
|
+
</th>
|
|
56
|
+
))}
|
|
57
|
+
</tr>
|
|
58
|
+
</thead>
|
|
59
|
+
<tbody>
|
|
60
|
+
{rows.options.map((r) => (
|
|
61
|
+
<tr key={r.name}>
|
|
62
|
+
<th scope="row" className="p-2 text-left font-mono text-xs font-medium">
|
|
63
|
+
{label(rows, r.name)}
|
|
64
|
+
</th>
|
|
65
|
+
{cols.options.map((c) => (
|
|
66
|
+
<td key={c.name} data-slot="variant-cell" className="p-2 align-middle">
|
|
67
|
+
{render({ [rows.name]: r.name, [cols.name]: c.name })}
|
|
68
|
+
</td>
|
|
69
|
+
))}
|
|
70
|
+
</tr>
|
|
71
|
+
))}
|
|
72
|
+
</tbody>
|
|
73
|
+
</table>
|
|
74
|
+
</div>
|
|
75
|
+
) : (
|
|
76
|
+
<AxisRow axis={rows} render={render} />
|
|
77
|
+
)}
|
|
78
|
+
{rest.map((axis) => (
|
|
79
|
+
<AxisRow key={axis.name} axis={axis} render={render} />
|
|
80
|
+
))}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function AxisRow({ axis, render }: { axis: VariantAxis; render: (extra: Record<string, string>) => ReactNode }) {
|
|
86
|
+
return (
|
|
87
|
+
<div data-slot="variant-axis" className="flex flex-col gap-2">
|
|
88
|
+
<p className="font-mono text-xs text-muted-foreground">{axis.name}</p>
|
|
89
|
+
<div className="flex flex-wrap items-center gap-4">
|
|
90
|
+
{axis.options.map((o) => (
|
|
91
|
+
<figure key={o.name} className="flex flex-col items-start gap-1.5">
|
|
92
|
+
{render({ [axis.name]: o.name })}
|
|
93
|
+
<figcaption className="font-mono text-xs text-muted-foreground" title={o.description}>
|
|
94
|
+
{label(axis, o.name)}
|
|
95
|
+
</figcaption>
|
|
96
|
+
</figure>
|
|
97
|
+
))}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function label(axis: VariantAxis, option: string): string {
|
|
104
|
+
return axis.default === option ? `${option} (default)` : option;
|
|
105
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TermEntry } from "./lib/manifest-types";
|
|
2
|
+
import { inline } from "./lib/text";
|
|
3
|
+
|
|
4
|
+
/** The words to use, beside the ones not to: product terms first, then the system's names that have wrong forms. */
|
|
5
|
+
export function VoiceTerms({ terms }: { terms: TermEntry[] }) {
|
|
6
|
+
const shown = [...terms.filter((t) => t.kind === "product"), ...terms.filter((t) => t.kind !== "product" && t.wrong?.length)];
|
|
7
|
+
if (shown.length === 0) return <p className="text-sm text-muted-foreground">No terms yet. Add them to the taxonomy file.</p>;
|
|
8
|
+
return (
|
|
9
|
+
<div data-slot="voice-terms" className="overflow-x-auto">
|
|
10
|
+
<table className="w-full min-w-[28rem] border-collapse text-left text-sm">
|
|
11
|
+
<thead>
|
|
12
|
+
<tr className="border-b border-border text-xs text-muted-foreground">
|
|
13
|
+
<th scope="col" className="py-2 pr-4 font-medium">
|
|
14
|
+
Say
|
|
15
|
+
</th>
|
|
16
|
+
<th scope="col" className="py-2 pr-4 font-medium">
|
|
17
|
+
Not
|
|
18
|
+
</th>
|
|
19
|
+
<th scope="col" className="py-2 font-medium">
|
|
20
|
+
Why
|
|
21
|
+
</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody>
|
|
25
|
+
{shown.map((t) => (
|
|
26
|
+
<tr key={`${t.kind}:${t.name}`} className="border-b border-border align-top">
|
|
27
|
+
<th scope="row" className="py-2 pr-4 font-medium">
|
|
28
|
+
{t.name}
|
|
29
|
+
</th>
|
|
30
|
+
<td className="py-2 pr-4 text-muted-foreground">
|
|
31
|
+
{(t.wrong ?? []).map((w, i) => (
|
|
32
|
+
<span key={w}>
|
|
33
|
+
{i > 0 && ", "}
|
|
34
|
+
<s>{w}</s>
|
|
35
|
+
</span>
|
|
36
|
+
))}
|
|
37
|
+
</td>
|
|
38
|
+
<td className="py-2 text-muted-foreground">{t.note ? inline(t.note) : t.kind === "product" ? "" : `The ${t.kind}'s name in the code.`}</td>
|
|
39
|
+
</tr>
|
|
40
|
+
))}
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|