@designtools/docs 0.2.3 → 0.3.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 +14 -0
- package/README.md +27 -3
- package/dist/adherence-summary.js +2 -2
- package/dist/anatomy.d.ts +6 -2
- package/dist/anatomy.js +3 -2
- package/dist/glossary.d.ts +1 -1
- package/dist/glossary.js +3 -8
- package/dist/lib/adherence-types.d.ts +2 -0
- package/dist/lib/colour.d.ts +16 -0
- package/dist/lib/colour.js +99 -0
- package/dist/lib/contrast.js +1 -7
- package/dist/lib/design-md.d.ts +27 -0
- package/dist/lib/design-md.js +176 -0
- package/dist/lib/markdown.js +1 -0
- package/dist/lib/terms.d.ts +1 -1
- package/dist/lib/terms.js +1 -1
- package/dist/lib/wrap.d.ts +5 -0
- package/dist/lib/wrap.js +5 -0
- package/dist/logo-usage.js +3 -3
- package/dist/next/config.d.ts +9 -0
- package/dist/next/markdown.d.ts +1 -1
- package/dist/next/markdown.js +15 -1
- package/dist/next/pages.js +2 -2
- package/dist/next/proxy.js +3 -2
- package/dist/page-actions.d.ts +2 -1
- package/dist/page-actions.js +4 -3
- package/dist/playground.js +1 -1
- package/dist/shell.js +6 -4
- package/dist/standards.js +1 -1
- package/dist/styles.css +28 -35
- package/dist/type-ramp.js +1 -1
- package/dist/variant-matrix.d.ts +6 -2
- package/dist/variant-matrix.js +3 -2
- package/dist/workbench.js +3 -2
- package/package.json +1 -1
- package/src/adherence-summary.tsx +7 -2
- package/src/anatomy.tsx +6 -4
- package/src/glossary.tsx +10 -22
- package/src/lib/adherence-types.ts +2 -0
- package/src/lib/colour.ts +104 -0
- package/src/lib/contrast.ts +2 -8
- package/src/lib/design-md.ts +193 -0
- package/src/lib/markdown.ts +1 -0
- package/src/lib/terms.tsx +1 -1
- package/src/lib/wrap.tsx +6 -0
- package/src/logo-usage.tsx +20 -12
- package/src/next/config.ts +7 -0
- package/src/next/markdown.ts +16 -1
- package/src/next/pages.tsx +7 -3
- package/src/next/proxy.ts +3 -2
- package/src/page-actions.tsx +10 -2
- package/src/playground.tsx +2 -2
- package/src/shell.tsx +6 -4
- package/src/standards.tsx +2 -2
- package/src/styles.css +9 -8
- package/src/type-ramp.tsx +3 -6
- package/src/variant-matrix.tsx +11 -4
- package/src/workbench.tsx +2 -1
package/src/playground.tsx
CHANGED
|
@@ -250,9 +250,9 @@ export function FlagControl({ name, checked, onChange }: { name: string; checked
|
|
|
250
250
|
checked={checked}
|
|
251
251
|
onCheckedChange={onChange}
|
|
252
252
|
// drawn small, pressed large: the hit area reaches the docs' target without the switch growing
|
|
253
|
-
className="relative h-6 w-10 shrink-0 cursor-pointer rounded-full bg-input p-0.5 transition-colors duration-(--dt-duration-fast) after:absolute after:-inset-2.5 after:content-[''] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring data-[checked]:bg-primary"
|
|
253
|
+
className="relative h-6 w-10 shrink-0 cursor-pointer rounded-full bg-input p-0.5 transition-colors duration-(--dt-duration-fast) after:absolute after:-inset-2.5 after:content-[''] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring data-[checked]:bg-[var(--docs-accent,var(--primary))]"
|
|
254
254
|
>
|
|
255
|
-
<Switch.Thumb className="block size-5 rounded-full bg-
|
|
255
|
+
<Switch.Thumb className="block size-5 rounded-full bg-canvas shadow-xs ring-1 ring-border transition-transform duration-(--dt-duration-fast) data-[checked]:translate-x-4" />
|
|
256
256
|
</Switch.Root>
|
|
257
257
|
</div>
|
|
258
258
|
);
|
package/src/shell.tsx
CHANGED
|
@@ -93,6 +93,8 @@ export function DocsShell({
|
|
|
93
93
|
children: ReactNode;
|
|
94
94
|
}) {
|
|
95
95
|
const current = usePathname();
|
|
96
|
+
// the overview's own address: the base path, or the site root when the docs are served there (basePath "")
|
|
97
|
+
const home = basePath || "/";
|
|
96
98
|
const searchItems = useMemo(
|
|
97
99
|
() =>
|
|
98
100
|
searchIndex({
|
|
@@ -109,7 +111,7 @@ export function DocsShell({
|
|
|
109
111
|
const sections = useMemo<Section[]>(() => {
|
|
110
112
|
const families = groupFamilies(manifest);
|
|
111
113
|
const all: Section[] = [
|
|
112
|
-
{ id: "overview", label: "Overview", icon: House, href:
|
|
114
|
+
{ id: "overview", label: "Overview", icon: House, href: home, groups: [] },
|
|
113
115
|
{ id: "brand", label: "Brand", icon: BookOpen, groups: [{ links: brand }] },
|
|
114
116
|
{ id: "foundations", label: "Foundations", icon: Palette, groups: [{ links: foundations }] },
|
|
115
117
|
...(rules?.rules.length ? [{ id: "rules", label: "Rules", icon: Scale, href: `${basePath}/rules`, groups: [] }] : []),
|
|
@@ -135,7 +137,7 @@ export function DocsShell({
|
|
|
135
137
|
{ id: "standards", label: "Standards", icon: Gauge, groups: [{ links: standards }] },
|
|
136
138
|
];
|
|
137
139
|
return all.filter((s) => s.href || s.groups.some((g) => g.links.length));
|
|
138
|
-
}, [manifest, rules, patterns, brand, foundations, standards, basePath]);
|
|
140
|
+
}, [manifest, rules, patterns, brand, foundations, standards, basePath, home]);
|
|
139
141
|
|
|
140
142
|
// every page in navigation order, for the section a page sits in and its neighbours
|
|
141
143
|
const page = useMemo(() => {
|
|
@@ -156,7 +158,7 @@ export function DocsShell({
|
|
|
156
158
|
useEffect(() => setMenu(false), [current]);
|
|
157
159
|
|
|
158
160
|
const brandLink = (
|
|
159
|
-
<Link href={
|
|
161
|
+
<Link href={home} data-slot="docs-title" className={cx(target, "flex min-w-0 items-center gap-3 rounded-md focus-visible:outline-2 focus-visible:outline-ring")}>
|
|
160
162
|
{logo && (
|
|
161
163
|
<span data-slot="docs-logo" className="shrink-0">
|
|
162
164
|
<Live>{logo}</Live>
|
|
@@ -224,7 +226,7 @@ export function DocsShell({
|
|
|
224
226
|
{search && <DocsSearch items={searchItems} shortcuts={false} variant="icon" />}
|
|
225
227
|
</header>
|
|
226
228
|
|
|
227
|
-
{hero && current ===
|
|
229
|
+
{hero && current === home && (
|
|
228
230
|
<div data-slot="docs-hero" className="w-full">
|
|
229
231
|
<Live>{hero}</Live>
|
|
230
232
|
</div>
|
package/src/standards.tsx
CHANGED
|
@@ -26,13 +26,13 @@ export function Standards({ baselines, children }: { baselines: Record<string, u
|
|
|
26
26
|
{section.title}
|
|
27
27
|
</h3>
|
|
28
28
|
{single ? (
|
|
29
|
-
<p className="text-
|
|
29
|
+
<p className="text-xl leading-snug tracking-tight text-pretty">{section.rows[0].value}</p>
|
|
30
30
|
) : section.rows.length ? (
|
|
31
31
|
<dl className="flex flex-col gap-3">
|
|
32
32
|
{section.rows.map((row) => (
|
|
33
33
|
<div key={row.label} className="flex flex-col gap-0.5">
|
|
34
34
|
<dt className="text-xs text-muted-foreground">{row.label}</dt>
|
|
35
|
-
<dd className="text-
|
|
35
|
+
<dd className="text-lg leading-snug tracking-tight tabular-nums">{row.value}</dd>
|
|
36
36
|
</div>
|
|
37
37
|
))}
|
|
38
38
|
</dl>
|
package/src/styles.css
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* semantic names (--canvas, --surface, --primary, …), so a project on our tokens
|
|
10
10
|
* needs nothing; any other project sets those names on the docs. Fonts take
|
|
11
11
|
* --docs-font-sans / --docs-font-mono, else the project's --font-sans and
|
|
12
|
-
* --font-mono; headings --docs-display, else --font-display. Sizes,
|
|
13
|
-
*
|
|
12
|
+
* --font-mono; headings --docs-display, else --font-display. Sizes, shadows,
|
|
13
|
+
* leading and tracking follow the project's scale where it has one; corners
|
|
14
|
+
* are the docs' own (--docs-radius-*), never the project's.
|
|
14
15
|
* Every value has a fallback, so the docs render on a project with none of it.
|
|
15
16
|
*/
|
|
16
17
|
@layer theme, base, components, utilities;
|
|
@@ -109,12 +110,12 @@
|
|
|
109
110
|
--tracking-wide: var(--tracking-wide, 0.04em);
|
|
110
111
|
--tracking-widest: var(--tracking-widest, 0.16em);
|
|
111
112
|
|
|
112
|
-
--radius-xs: var(--docs-radius-xs,
|
|
113
|
-
--radius-sm: var(--docs-radius-sm,
|
|
114
|
-
--radius-md: var(--docs-radius-md,
|
|
115
|
-
--radius-lg: var(--docs-radius-lg,
|
|
116
|
-
--radius-xl: var(--docs-radius-xl,
|
|
117
|
-
--radius-2xl: var(--docs-radius-2xl,
|
|
113
|
+
--radius-xs: var(--docs-radius-xs, 0.125rem);
|
|
114
|
+
--radius-sm: var(--docs-radius-sm, 0.25rem);
|
|
115
|
+
--radius-md: var(--docs-radius-md, 0.375rem);
|
|
116
|
+
--radius-lg: var(--docs-radius-lg, 0.5rem);
|
|
117
|
+
--radius-xl: var(--docs-radius-xl, 0.75rem);
|
|
118
|
+
--radius-2xl: var(--docs-radius-2xl, 1rem);
|
|
118
119
|
|
|
119
120
|
--shadow-xs: var(--shadow-xs, 0 1px 2px 0 color-mix(in oklch, var(--shadow, #0b0d12) 6%, transparent));
|
|
120
121
|
--shadow-sm: var(--shadow-sm, 0 1px 3px 0 color-mix(in oklch, var(--shadow, #0b0d12) 10%, transparent));
|
package/src/type-ramp.tsx
CHANGED
|
@@ -34,12 +34,9 @@ export function TypeRamp({
|
|
|
34
34
|
<div className="grid gap-x-12 gap-y-10 md:grid-cols-2">
|
|
35
35
|
{families.map((f) => (
|
|
36
36
|
<figure key={f.name} data-slot="type-family" className="flex flex-col gap-5 border-t border-border pt-6">
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 &?!
|
|
41
|
-
</span>
|
|
42
|
-
</div>
|
|
37
|
+
<span className="text-8xl leading-none font-light tracking-tighter" style={{ fontFamily: `var(${f.name})` }}>
|
|
38
|
+
Aa
|
|
39
|
+
</span>
|
|
43
40
|
<figcaption className="flex flex-col gap-0.5">
|
|
44
41
|
<code className="font-mono text-xs font-medium">{shortName(f, "font")}</code>
|
|
45
42
|
<span className="truncate font-mono text-xs text-muted-foreground" title={f.values.default}>
|
package/src/variant-matrix.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { Live } from "./lib/live";
|
|
4
|
+
import { wrapIn } from "./lib/wrap";
|
|
4
5
|
import { Grid3x3, Moon, Sun } from "lucide-react";
|
|
5
|
-
import { type ReactNode, useEffect, useState } from "react";
|
|
6
|
+
import { type ReactElement, type ReactNode, useEffect, useState } from "react";
|
|
6
7
|
import { cx } from "./lib/cx";
|
|
7
8
|
import { coerce, Missing, useLookup } from "./lib/lookup";
|
|
8
9
|
import type { ComponentEntry, VariantAxis } from "./lib/manifest-types";
|
|
@@ -19,9 +20,12 @@ export function VariantMatrix({
|
|
|
19
20
|
props = {},
|
|
20
21
|
children,
|
|
21
22
|
axes: only,
|
|
23
|
+
wrap,
|
|
22
24
|
}: {
|
|
23
25
|
entry: ComponentEntry;
|
|
24
26
|
props?: Record<string, unknown>;
|
|
27
|
+
/** What each instance must sit in to work: a provider, its root. */
|
|
28
|
+
wrap?: ReactElement<{ children?: ReactNode }>;
|
|
25
29
|
/** What to render inside each instance. Defaults to the component's name. */
|
|
26
30
|
children?: ReactNode;
|
|
27
31
|
/** Limit and order the axes shown. */
|
|
@@ -38,9 +42,12 @@ export function VariantMatrix({
|
|
|
38
42
|
const content = children ?? entry.name;
|
|
39
43
|
const render = (extra: Record<string, string>) => (
|
|
40
44
|
<Live>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
{wrapIn(
|
|
46
|
+
wrap,
|
|
47
|
+
<Component {...props} {...coerce(extra)}>
|
|
48
|
+
{content}
|
|
49
|
+
</Component>,
|
|
50
|
+
)}
|
|
44
51
|
</Live>
|
|
45
52
|
);
|
|
46
53
|
const [rows, cols, ...rest] = axes;
|
package/src/workbench.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { handlerNames } from "./lib/handlers";
|
|
4
4
|
import { Live } from "./lib/live";
|
|
5
|
+
import { wrapIn } from "./lib/wrap";
|
|
5
6
|
import { Tabs } from "@base-ui/react/tabs";
|
|
6
7
|
import { Toggle } from "@base-ui/react/toggle";
|
|
7
8
|
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
@@ -381,7 +382,7 @@ export function Workbench({
|
|
|
381
382
|
}}
|
|
382
383
|
>
|
|
383
384
|
<div ref={target} data-slot="workbench-target" className="flex max-w-full items-center justify-center">
|
|
384
|
-
<Boundary label={entry.name}>{
|
|
385
|
+
<Boundary label={entry.name}>{wrapIn(wrap, node)}</Boundary>
|
|
385
386
|
</div>
|
|
386
387
|
</div>
|
|
387
388
|
</div>
|