@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +27 -3
  3. package/dist/adherence-summary.js +2 -2
  4. package/dist/anatomy.d.ts +6 -2
  5. package/dist/anatomy.js +3 -2
  6. package/dist/glossary.d.ts +1 -1
  7. package/dist/glossary.js +3 -8
  8. package/dist/lib/adherence-types.d.ts +2 -0
  9. package/dist/lib/colour.d.ts +16 -0
  10. package/dist/lib/colour.js +99 -0
  11. package/dist/lib/contrast.js +1 -7
  12. package/dist/lib/design-md.d.ts +27 -0
  13. package/dist/lib/design-md.js +176 -0
  14. package/dist/lib/markdown.js +1 -0
  15. package/dist/lib/terms.d.ts +1 -1
  16. package/dist/lib/terms.js +1 -1
  17. package/dist/lib/wrap.d.ts +5 -0
  18. package/dist/lib/wrap.js +5 -0
  19. package/dist/logo-usage.js +3 -3
  20. package/dist/next/config.d.ts +9 -0
  21. package/dist/next/markdown.d.ts +1 -1
  22. package/dist/next/markdown.js +15 -1
  23. package/dist/next/pages.js +2 -2
  24. package/dist/next/proxy.js +3 -2
  25. package/dist/page-actions.d.ts +2 -1
  26. package/dist/page-actions.js +4 -3
  27. package/dist/playground.js +1 -1
  28. package/dist/shell.js +6 -4
  29. package/dist/standards.js +1 -1
  30. package/dist/styles.css +28 -35
  31. package/dist/type-ramp.js +1 -1
  32. package/dist/variant-matrix.d.ts +6 -2
  33. package/dist/variant-matrix.js +3 -2
  34. package/dist/workbench.js +3 -2
  35. package/package.json +1 -1
  36. package/src/adherence-summary.tsx +7 -2
  37. package/src/anatomy.tsx +6 -4
  38. package/src/glossary.tsx +10 -22
  39. package/src/lib/adherence-types.ts +2 -0
  40. package/src/lib/colour.ts +104 -0
  41. package/src/lib/contrast.ts +2 -8
  42. package/src/lib/design-md.ts +193 -0
  43. package/src/lib/markdown.ts +1 -0
  44. package/src/lib/terms.tsx +1 -1
  45. package/src/lib/wrap.tsx +6 -0
  46. package/src/logo-usage.tsx +20 -12
  47. package/src/next/config.ts +7 -0
  48. package/src/next/markdown.ts +16 -1
  49. package/src/next/pages.tsx +7 -3
  50. package/src/next/proxy.ts +3 -2
  51. package/src/page-actions.tsx +10 -2
  52. package/src/playground.tsx +2 -2
  53. package/src/shell.tsx +6 -4
  54. package/src/standards.tsx +2 -2
  55. package/src/styles.css +9 -8
  56. package/src/type-ramp.tsx +3 -6
  57. package/src/variant-matrix.tsx +11 -4
  58. package/src/workbench.tsx +2 -1
@@ -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-primary-foreground shadow-xs transition-transform duration-(--dt-duration-fast) data-[checked]:translate-x-4" />
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: basePath, groups: [] },
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={basePath} 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")}>
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 === basePath && (
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-5xl font-light tracking-tight">{section.rows[0].value}</p>
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-2xl font-light tracking-tight tabular-nums">{row.value}</dd>
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, radii,
13
- * shadows, leading and tracking follow the project's scale where it has one.
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, var(--radius-xs, 0.125rem));
113
- --radius-sm: var(--docs-radius-sm, var(--radius-sm, 0.25rem));
114
- --radius-md: var(--docs-radius-md, var(--radius-md, 0.375rem));
115
- --radius-lg: var(--docs-radius-lg, var(--radius-lg, 0.5rem));
116
- --radius-xl: var(--docs-radius-xl, var(--radius-xl, 0.75rem));
117
- --radius-2xl: var(--docs-radius-2xl, var(--radius-2xl, 1rem));
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
- <div className="flex flex-col gap-6" style={{ fontFamily: `var(${f.name})` }}>
38
- <span className="text-8xl leading-none font-light tracking-tighter">Aa</span>
39
- <span className="text-sm leading-relaxed break-all text-muted-foreground">
40
- ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 &amp;?!
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}>
@@ -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
- <Component {...props} {...coerce(extra)}>
42
- {content}
43
- </Component>
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}>{wrap && isValidElement(wrap) ? cloneElement(wrap, undefined, node) : node}</Boundary>
385
+ <Boundary label={entry.name}>{wrapIn(wrap, node)}</Boundary>
385
386
  </div>
386
387
  </div>
387
388
  </div>