@awarebydefault/display-case 1.0.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 +309 -0
- package/display-case.prompt.md +64 -0
- package/docs/ai-agents.md +126 -0
- package/docs/cli.md +99 -0
- package/docs/configuration.md +410 -0
- package/docs/documentation-panel.md +50 -0
- package/docs/examples/README.md +14 -0
- package/docs/examples/multi-variant.case.tsx +30 -0
- package/docs/examples/plain.case.tsx +22 -0
- package/docs/examples/tweak-control.placard.md +80 -0
- package/docs/examples/tweaks.case.tsx +39 -0
- package/docs/hierarchy.md +59 -0
- package/docs/quick-start.md +78 -0
- package/docs/style-engines.md +180 -0
- package/docs/testing.md +245 -0
- package/docs/theming.md +97 -0
- package/docs/tweaks.md +75 -0
- package/docs/writing-cases.md +144 -0
- package/docs/writing-placard-docs.md +194 -0
- package/package.json +113 -0
- package/skills/display-case-author-case/README.md +20 -0
- package/skills/display-case-author-case/SKILL.md +40 -0
- package/skills/display-case-author-placard-doc/README.md +24 -0
- package/skills/display-case-author-placard-doc/SKILL.md +65 -0
- package/skills/display-case-review/README.md +19 -0
- package/skills/display-case-review/SKILL.md +30 -0
- package/skills/display-case-snapshot/README.md +20 -0
- package/skills/display-case-snapshot/SKILL.md +29 -0
- package/src/checks/a11y-scanner.test.ts +240 -0
- package/src/checks/a11y-scanner.ts +410 -0
- package/src/checks/check-text.test.ts +53 -0
- package/src/checks/check-text.ts +78 -0
- package/src/checks/check.test.ts +194 -0
- package/src/checks/check.ts +473 -0
- package/src/checks/providers/pixelmatch-diff.test.ts +79 -0
- package/src/checks/providers/pixelmatch-diff.ts +30 -0
- package/src/checks/providers/playwright-driver.ts +104 -0
- package/src/checks/ssr-check.test.ts +73 -0
- package/src/checks/ssr-check.ts +96 -0
- package/src/checks/structure-check.cross-package.test.ts +165 -0
- package/src/checks/structure-check.test.ts +651 -0
- package/src/checks/structure-check.ts +988 -0
- package/src/checks/tokens-check.test.ts +159 -0
- package/src/checks/tokens-check.ts +162 -0
- package/src/cli.ts +218 -0
- package/src/commands/agents.test.ts +24 -0
- package/src/commands/agents.ts +28 -0
- package/src/commands/init-run.test.ts +123 -0
- package/src/commands/init.test.ts +63 -0
- package/src/commands/init.ts +412 -0
- package/src/commands/publish.test.ts +210 -0
- package/src/commands/publish.ts +292 -0
- package/src/core/affected.test.ts +99 -0
- package/src/core/affected.ts +144 -0
- package/src/core/catalog.test.ts +152 -0
- package/src/core/catalog.ts +92 -0
- package/src/core/discovery.test.ts +184 -0
- package/src/core/discovery.ts +250 -0
- package/src/core/manifest.ts +41 -0
- package/src/core/mdx-lite/__fixtures__/box-stub.tsx +7 -0
- package/src/core/mdx-lite/index.ts +393 -0
- package/src/core/mdx-lite/mdx-lite.test.ts +345 -0
- package/src/core/mdx-plugin.test.ts +60 -0
- package/src/core/mdx-plugin.ts +30 -0
- package/src/flow-step.test-d.ts +39 -0
- package/src/index.test.ts +100 -0
- package/src/index.ts +564 -0
- package/src/render/collect-styles.emotion.test.tsx +114 -0
- package/src/render/collect-styles.test.tsx +72 -0
- package/src/render/collect-styles.ts +33 -0
- package/src/render/documents.test.ts +184 -0
- package/src/render/documents.ts +88 -0
- package/src/render/render-node.test.tsx +160 -0
- package/src/render/render-node.tsx +133 -0
- package/src/render/ssr-primer.test.tsx +25 -0
- package/src/render/ssr-primer.tsx +54 -0
- package/src/render/ssr-render.test.tsx +142 -0
- package/src/render/ssr-render.tsx +63 -0
- package/src/render/ssr-shell.test.tsx +57 -0
- package/src/render/ssr-shell.tsx +54 -0
- package/src/server/prod-server.ts +237 -0
- package/src/server/server.test.ts +117 -0
- package/src/server/server.ts +1039 -0
- package/src/style-engine.test-d.ts +37 -0
- package/src/testing/test-helpers.ts +27 -0
- package/src/types/pixelmatch.d.ts +12 -0
- package/src/ui/browser-entry.tsx +51 -0
- package/src/ui/chrome.css +485 -0
- package/src/ui/design-system/README.md +88 -0
- package/src/ui/design-system/components/controls/Button.case.tsx +52 -0
- package/src/ui/design-system/components/controls/Button.css +89 -0
- package/src/ui/design-system/components/controls/Button.placard.md +14 -0
- package/src/ui/design-system/components/controls/Button.test.tsx +45 -0
- package/src/ui/design-system/components/controls/Button.tsx +41 -0
- package/src/ui/design-system/components/controls/IconButton.case.tsx +52 -0
- package/src/ui/design-system/components/controls/IconButton.css +67 -0
- package/src/ui/design-system/components/controls/IconButton.placard.md +13 -0
- package/src/ui/design-system/components/controls/IconButton.test.tsx +39 -0
- package/src/ui/design-system/components/controls/IconButton.tsx +47 -0
- package/src/ui/design-system/components/controls/Input.case.tsx +50 -0
- package/src/ui/design-system/components/controls/Input.css +52 -0
- package/src/ui/design-system/components/controls/Input.placard.md +12 -0
- package/src/ui/design-system/components/controls/Input.test.tsx +43 -0
- package/src/ui/design-system/components/controls/Input.tsx +45 -0
- package/src/ui/design-system/components/controls/Select.case.tsx +48 -0
- package/src/ui/design-system/components/controls/Select.css +44 -0
- package/src/ui/design-system/components/controls/Select.placard.md +15 -0
- package/src/ui/design-system/components/controls/Select.test.tsx +57 -0
- package/src/ui/design-system/components/controls/Select.tsx +58 -0
- package/src/ui/design-system/components/controls/SelectMenu.case.tsx +100 -0
- package/src/ui/design-system/components/controls/SelectMenu.css +72 -0
- package/src/ui/design-system/components/controls/SelectMenu.placard.md +18 -0
- package/src/ui/design-system/components/controls/SelectMenu.test.tsx +66 -0
- package/src/ui/design-system/components/controls/SelectMenu.tsx +377 -0
- package/src/ui/design-system/components/index.ts +66 -0
- package/src/ui/design-system/components/primer-specimen/ColorRamp.case.tsx +44 -0
- package/src/ui/design-system/components/primer-specimen/ColorRamp.placard.md +15 -0
- package/src/ui/design-system/components/primer-specimen/ColorRamp.tsx +51 -0
- package/src/ui/design-system/components/primer-specimen/DefinitionList.case.tsx +38 -0
- package/src/ui/design-system/components/primer-specimen/DefinitionList.placard.md +15 -0
- package/src/ui/design-system/components/primer-specimen/DefinitionList.tsx +41 -0
- package/src/ui/design-system/components/primer-specimen/FontFamilies.case.tsx +24 -0
- package/src/ui/design-system/components/primer-specimen/FontFamilies.placard.md +12 -0
- package/src/ui/design-system/components/primer-specimen/FontFamilies.tsx +41 -0
- package/src/ui/design-system/components/primer-specimen/GlyphGrid.case.tsx +27 -0
- package/src/ui/design-system/components/primer-specimen/GlyphGrid.placard.md +13 -0
- package/src/ui/design-system/components/primer-specimen/GlyphGrid.tsx +34 -0
- package/src/ui/design-system/components/primer-specimen/LayoutMock.case.tsx +36 -0
- package/src/ui/design-system/components/primer-specimen/LayoutMock.placard.md +7 -0
- package/src/ui/design-system/components/primer-specimen/LayoutMock.tsx +36 -0
- package/src/ui/design-system/components/primer-specimen/SpacingScale.case.tsx +20 -0
- package/src/ui/design-system/components/primer-specimen/SpacingScale.placard.md +12 -0
- package/src/ui/design-system/components/primer-specimen/SpacingScale.tsx +33 -0
- package/src/ui/design-system/components/primer-specimen/SpecimenBoxRow.case.tsx +56 -0
- package/src/ui/design-system/components/primer-specimen/SpecimenBoxRow.placard.md +17 -0
- package/src/ui/design-system/components/primer-specimen/SpecimenBoxRow.tsx +45 -0
- package/src/ui/design-system/components/primer-specimen/StatusList.case.tsx +17 -0
- package/src/ui/design-system/components/primer-specimen/StatusList.placard.md +16 -0
- package/src/ui/design-system/components/primer-specimen/StatusList.tsx +39 -0
- package/src/ui/design-system/components/primer-specimen/SwatchGrid.case.tsx +26 -0
- package/src/ui/design-system/components/primer-specimen/SwatchGrid.placard.md +15 -0
- package/src/ui/design-system/components/primer-specimen/SwatchGrid.tsx +42 -0
- package/src/ui/design-system/components/primer-specimen/TypeScale.case.tsx +23 -0
- package/src/ui/design-system/components/primer-specimen/TypeScale.placard.md +14 -0
- package/src/ui/design-system/components/primer-specimen/TypeScale.tsx +34 -0
- package/src/ui/design-system/components/primer-specimen/WeightSpecimen.case.tsx +28 -0
- package/src/ui/design-system/components/primer-specimen/WeightSpecimen.placard.md +15 -0
- package/src/ui/design-system/components/primer-specimen/WeightSpecimen.tsx +46 -0
- package/src/ui/design-system/components/primer-specimen/index.ts +31 -0
- package/src/ui/design-system/components/primer-specimen/styles.css +476 -0
- package/src/ui/design-system/components/shell/A11yPage.case.tsx +237 -0
- package/src/ui/design-system/components/shell/A11yPage.placard.md +15 -0
- package/src/ui/design-system/components/shell/CaseTemplate.case.tsx +32 -0
- package/src/ui/design-system/components/shell/CaseTemplate.placard.md +5 -0
- package/src/ui/design-system/components/shell/CasesPage.case.tsx +141 -0
- package/src/ui/design-system/components/shell/CasesPage.placard.md +12 -0
- package/src/ui/design-system/components/shell/PrimerPage.case.tsx +22 -0
- package/src/ui/design-system/components/shell/PrimerPage.placard.md +3 -0
- package/src/ui/design-system/components/shell/PrimerTemplate.case.tsx +22 -0
- package/src/ui/design-system/components/shell/PrimerTemplate.placard.md +5 -0
- package/src/ui/design-system/components/shell/ShellView.case.tsx +57 -0
- package/src/ui/design-system/components/shell/ShellView.placard.md +5 -0
- package/src/ui/design-system/components/shell/ShellView.tsx +678 -0
- package/src/ui/design-system/components/shell/shell-fixtures.tsx +727 -0
- package/src/ui/design-system/components/showcase/A11yBadge.case.tsx +46 -0
- package/src/ui/design-system/components/showcase/A11yBadge.css +27 -0
- package/src/ui/design-system/components/showcase/A11yBadge.placard.md +11 -0
- package/src/ui/design-system/components/showcase/A11yBadge.test.tsx +31 -0
- package/src/ui/design-system/components/showcase/A11yBadge.tsx +41 -0
- package/src/ui/design-system/components/showcase/A11yPanel.case.tsx +121 -0
- package/src/ui/design-system/components/showcase/A11yPanel.css +198 -0
- package/src/ui/design-system/components/showcase/A11yPanel.placard.md +19 -0
- package/src/ui/design-system/components/showcase/A11yPanel.test.tsx +81 -0
- package/src/ui/design-system/components/showcase/A11yPanel.tsx +144 -0
- package/src/ui/design-system/components/showcase/Chip.case.tsx +48 -0
- package/src/ui/design-system/components/showcase/Chip.css +51 -0
- package/src/ui/design-system/components/showcase/Chip.placard.md +13 -0
- package/src/ui/design-system/components/showcase/Chip.test.tsx +46 -0
- package/src/ui/design-system/components/showcase/Chip.tsx +54 -0
- package/src/ui/design-system/components/showcase/Eyebrow.case.tsx +30 -0
- package/src/ui/design-system/components/showcase/Eyebrow.css +16 -0
- package/src/ui/design-system/components/showcase/Eyebrow.placard.md +10 -0
- package/src/ui/design-system/components/showcase/Eyebrow.test.tsx +38 -0
- package/src/ui/design-system/components/showcase/Eyebrow.tsx +29 -0
- package/src/ui/design-system/components/showcase/FlowNav.case.tsx +35 -0
- package/src/ui/design-system/components/showcase/FlowNav.css +29 -0
- package/src/ui/design-system/components/showcase/FlowNav.placard.md +13 -0
- package/src/ui/design-system/components/showcase/FlowNav.test.tsx +48 -0
- package/src/ui/design-system/components/showcase/FlowNav.tsx +58 -0
- package/src/ui/design-system/components/showcase/ImpactTag.case.tsx +19 -0
- package/src/ui/design-system/components/showcase/ImpactTag.css +36 -0
- package/src/ui/design-system/components/showcase/ImpactTag.placard.md +14 -0
- package/src/ui/design-system/components/showcase/ImpactTag.test.tsx +40 -0
- package/src/ui/design-system/components/showcase/ImpactTag.tsx +35 -0
- package/src/ui/design-system/components/showcase/NavItem.case.tsx +86 -0
- package/src/ui/design-system/components/showcase/NavItem.css +111 -0
- package/src/ui/design-system/components/showcase/NavItem.placard.md +13 -0
- package/src/ui/design-system/components/showcase/NavItem.test.tsx +65 -0
- package/src/ui/design-system/components/showcase/NavItem.tsx +95 -0
- package/src/ui/design-system/components/showcase/RenderAddress.case.tsx +21 -0
- package/src/ui/design-system/components/showcase/RenderAddress.css +35 -0
- package/src/ui/design-system/components/showcase/RenderAddress.placard.md +7 -0
- package/src/ui/design-system/components/showcase/RenderAddress.test.tsx +26 -0
- package/src/ui/design-system/components/showcase/RenderAddress.tsx +43 -0
- package/src/ui/design-system/components/showcase/SegmentedToggle.case.tsx +84 -0
- package/src/ui/design-system/components/showcase/SegmentedToggle.css +61 -0
- package/src/ui/design-system/components/showcase/SegmentedToggle.placard.md +21 -0
- package/src/ui/design-system/components/showcase/SegmentedToggle.test.tsx +81 -0
- package/src/ui/design-system/components/showcase/SegmentedToggle.tsx +75 -0
- package/src/ui/design-system/components/showcase/Sidebar.case.tsx +67 -0
- package/src/ui/design-system/components/showcase/Sidebar.css +6 -0
- package/src/ui/design-system/components/showcase/Sidebar.placard.md +14 -0
- package/src/ui/design-system/components/showcase/Sidebar.test.tsx +32 -0
- package/src/ui/design-system/components/showcase/Sidebar.tsx +30 -0
- package/src/ui/design-system/components/showcase/Stage.case.tsx +51 -0
- package/src/ui/design-system/components/showcase/Stage.css +91 -0
- package/src/ui/design-system/components/showcase/Stage.placard.md +15 -0
- package/src/ui/design-system/components/showcase/Stage.test.tsx +84 -0
- package/src/ui/design-system/components/showcase/Stage.tsx +97 -0
- package/src/ui/design-system/components/showcase/TweaksPanel.case.tsx +81 -0
- package/src/ui/design-system/components/showcase/TweaksPanel.css +169 -0
- package/src/ui/design-system/components/showcase/TweaksPanel.placard.md +20 -0
- package/src/ui/design-system/components/showcase/TweaksPanel.tsx +230 -0
- package/src/ui/design-system/components/showcase/Wordmark.case.tsx +42 -0
- package/src/ui/design-system/components/showcase/Wordmark.css +31 -0
- package/src/ui/design-system/components/showcase/Wordmark.placard.md +10 -0
- package/src/ui/design-system/components/showcase/Wordmark.test.tsx +22 -0
- package/src/ui/design-system/components/showcase/Wordmark.tsx +22 -0
- package/src/ui/design-system/primer-specimens/brand.tsx +26 -0
- package/src/ui/design-system/primer-specimens/colors.tsx +83 -0
- package/src/ui/design-system/primer-specimens/components.tsx +308 -0
- package/src/ui/design-system/primer-specimens/foundations.tsx +71 -0
- package/src/ui/design-system/primer-specimens/index.ts +25 -0
- package/src/ui/design-system/primer-specimens/showcase.tsx +68 -0
- package/src/ui/design-system/primer-specimens/spacing.tsx +101 -0
- package/src/ui/design-system/primer-specimens/type.tsx +75 -0
- package/src/ui/design-system/primer.mdx +236 -0
- package/src/ui/design-system/styles.css +14 -0
- package/src/ui/design-system/tokens/colors.css +172 -0
- package/src/ui/design-system/tokens/fonts.css +18 -0
- package/src/ui/design-system/tokens/spacing.css +48 -0
- package/src/ui/design-system/tokens/typography.css +49 -0
- package/src/ui/markdown.test.tsx +54 -0
- package/src/ui/markdown.tsx +19 -0
- package/src/ui/primer-mount.tsx +76 -0
- package/src/ui/primer.css +175 -0
- package/src/ui/primer.tsx +277 -0
- package/src/ui/render-mount.tsx +284 -0
- package/src/ui/shell-core.test.ts +340 -0
- package/src/ui/shell-core.ts +295 -0
- package/src/ui/shell.tsx +60 -0
- package/src/ui/test-ids.ts +53 -0
- package/src/ui/use-shell.ts +1230 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Case — FontFamilies
|
|
3
|
+
* A stack of font-family rows: a mono tag, a large sample set in the family, and
|
|
4
|
+
* a mono note listing the stack. Generic specimen primitive for a Primer — use
|
|
5
|
+
* it to document a type pairing (a UI sans, a code mono, …).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface FontFamily {
|
|
9
|
+
/** Mono uppercase tag (e.g. `Sans · UI`); also the React key. */
|
|
10
|
+
tag: string
|
|
11
|
+
/** Large sample, rendered in this family. */
|
|
12
|
+
sample: string
|
|
13
|
+
/** Mono note under the sample — typically the font stack. */
|
|
14
|
+
note?: string
|
|
15
|
+
/** Render the sample in the mono family instead of the sans family. */
|
|
16
|
+
mono?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FontFamiliesProps {
|
|
20
|
+
families: FontFamily[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function FontFamilies({ families }: FontFamiliesProps) {
|
|
24
|
+
return (
|
|
25
|
+
<div className="dcpl-fam">
|
|
26
|
+
{families.map((f) => (
|
|
27
|
+
<div className="dcpl-famrow" key={f.tag}>
|
|
28
|
+
<div className="dcpl-famtag">{f.tag}</div>
|
|
29
|
+
<div>
|
|
30
|
+
<div
|
|
31
|
+
className="dcpl-famsample"
|
|
32
|
+
data-font={f.mono ? 'mono' : 'sans'}>
|
|
33
|
+
{f.sample}
|
|
34
|
+
</div>
|
|
35
|
+
{f.note ? <div className="dcpl-famnote">{f.note}</div> : null}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineCases, tweak } from '@awarebydefault/display-case'
|
|
2
|
+
import { GlyphGrid, type GlyphSpec } from './GlyphGrid'
|
|
3
|
+
|
|
4
|
+
const glyphs: GlyphSpec[] = [
|
|
5
|
+
{ glyph: '☰', use: 'Toggle nav' },
|
|
6
|
+
{ glyph: '▸', use: 'Disclosure' },
|
|
7
|
+
{ glyph: '⟲', use: 'Rotate' },
|
|
8
|
+
{ glyph: '✕', use: 'Close' },
|
|
9
|
+
{ glyph: '★', use: 'Emphasis' },
|
|
10
|
+
{ glyph: '←', use: 'Prev' },
|
|
11
|
+
{ glyph: '→', use: 'Next' },
|
|
12
|
+
{ glyph: '+', use: 'Zoom in' },
|
|
13
|
+
{ glyph: '−', use: 'Zoom out' },
|
|
14
|
+
{ glyph: '×', use: 'Dimension' },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
export default defineCases(
|
|
18
|
+
'GlyphGrid',
|
|
19
|
+
{
|
|
20
|
+
Playground: {
|
|
21
|
+
tweaks: { columns: tweak.number(5) },
|
|
22
|
+
render: (t) => <GlyphGrid glyphs={glyphs} columns={t.columns} />,
|
|
23
|
+
},
|
|
24
|
+
Vocabulary: () => <GlyphGrid glyphs={glyphs} />,
|
|
25
|
+
},
|
|
26
|
+
{ level: 'molecule' },
|
|
27
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
**GlyphGrid** — a grid of glyph tiles, each a large glyph over a short usage caption; reach for it to document an icon vocabulary (Unicode glyphs, an icon-font codepoint set, or any single-character marks).
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
<GlyphGrid
|
|
5
|
+
columns={5}
|
|
6
|
+
glyphs={[
|
|
7
|
+
{ glyph: '☰', use: 'Toggle nav' },
|
|
8
|
+
{ glyph: '✕', use: 'Close' },
|
|
9
|
+
]}
|
|
10
|
+
/>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`use` doubles as the React key — keep captions unique across the grid.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Case — GlyphGrid
|
|
3
|
+
* A grid of glyph tiles, each a large glyph over a short usage caption. Generic
|
|
4
|
+
* specimen primitive for a Primer — use it to document an icon vocabulary
|
|
5
|
+
* (Unicode glyphs, an icon-font codepoint set, or any single-character marks).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface GlyphSpec {
|
|
9
|
+
/** The glyph to render large. */
|
|
10
|
+
glyph: string
|
|
11
|
+
/** Short usage caption (also the React key). */
|
|
12
|
+
use: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface GlyphGridProps {
|
|
16
|
+
glyphs: GlyphSpec[]
|
|
17
|
+
/** Number of columns in the grid. */
|
|
18
|
+
columns?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function GlyphGrid({ glyphs, columns = 5 }: GlyphGridProps) {
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
className="dcpl-icongrid"
|
|
25
|
+
style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }}>
|
|
26
|
+
{glyphs.map((g) => (
|
|
27
|
+
<div className="dcpl-iconitem" key={g.use}>
|
|
28
|
+
<div className="dcpl-iconglyph">{g.glyph}</div>
|
|
29
|
+
<div className="dcpl-iconuse">{g.use}</div>
|
|
30
|
+
</div>
|
|
31
|
+
))}
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineCases, tweak } from '@awarebydefault/display-case'
|
|
2
|
+
import { LayoutMock } from './LayoutMock'
|
|
3
|
+
|
|
4
|
+
export default defineCases(
|
|
5
|
+
'LayoutMock',
|
|
6
|
+
{
|
|
7
|
+
Playground: {
|
|
8
|
+
tweaks: {
|
|
9
|
+
header: tweak.text('header'),
|
|
10
|
+
sidebar: tweak.text('sidebar'),
|
|
11
|
+
main: tweak.text('main · the stage'),
|
|
12
|
+
sidebarWidth: tweak.text('32%'),
|
|
13
|
+
},
|
|
14
|
+
render: (t) => (
|
|
15
|
+
<LayoutMock
|
|
16
|
+
header={t.header}
|
|
17
|
+
sidebar={t.sidebar}
|
|
18
|
+
main={t.main}
|
|
19
|
+
sidebarWidth={t.sidebarWidth || undefined}
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
},
|
|
23
|
+
Shell: () => (
|
|
24
|
+
<LayoutMock header="header" sidebar="sidebar" main="main · the stage" />
|
|
25
|
+
),
|
|
26
|
+
WideSidebar: () => (
|
|
27
|
+
<LayoutMock
|
|
28
|
+
header="toolbar"
|
|
29
|
+
sidebar="nav tree"
|
|
30
|
+
main="preview"
|
|
31
|
+
sidebarWidth="44%"
|
|
32
|
+
/>
|
|
33
|
+
),
|
|
34
|
+
},
|
|
35
|
+
{ level: 'molecule' },
|
|
36
|
+
)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
**LayoutMock** — a miniature three-region wireframe (header over a sidebar + main split); reach for it to sketch an app's shell layout without committing to real chrome.
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
<LayoutMock header="header" sidebar="sidebar" main="main · the stage" />
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Each region takes any node; omit one to leave it empty. `sidebarWidth` defaults `32%`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Display Case — LayoutMock
|
|
5
|
+
* A miniature three-region wireframe — header over a sidebar + main split.
|
|
6
|
+
* Generic specimen primitive for a Primer — use it to sketch an app's shell
|
|
7
|
+
* layout without committing to real chrome. Each region accepts any label or
|
|
8
|
+
* node; omit a region to leave it empty.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface LayoutMockProps {
|
|
12
|
+
header?: ReactNode
|
|
13
|
+
sidebar?: ReactNode
|
|
14
|
+
main?: ReactNode
|
|
15
|
+
/** Width of the sidebar region (any CSS length). */
|
|
16
|
+
sidebarWidth?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function LayoutMock({
|
|
20
|
+
header = 'header',
|
|
21
|
+
sidebar = 'sidebar',
|
|
22
|
+
main = 'main',
|
|
23
|
+
sidebarWidth = '32%',
|
|
24
|
+
}: LayoutMockProps) {
|
|
25
|
+
return (
|
|
26
|
+
<div className="dcpl-layout">
|
|
27
|
+
<div className="dcpl-layout-head">{header}</div>
|
|
28
|
+
<div className="dcpl-layout-body">
|
|
29
|
+
<div className="dcpl-layout-side" style={{ width: sidebarWidth }}>
|
|
30
|
+
{sidebar}
|
|
31
|
+
</div>
|
|
32
|
+
<div className="dcpl-layout-main">{main}</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineCases } from '@awarebydefault/display-case'
|
|
2
|
+
import { type SpaceStep, SpacingScale } from './SpacingScale'
|
|
3
|
+
|
|
4
|
+
const steps: SpaceStep[] = [
|
|
5
|
+
{ token: 'space-1', value: '2px', width: 2 },
|
|
6
|
+
{ token: 'space-2', value: '4px', width: 4 },
|
|
7
|
+
{ token: 'space-4', value: '8px', width: 8 },
|
|
8
|
+
{ token: 'space-6', value: '12px', width: 12 },
|
|
9
|
+
{ token: 'space-8', value: '16px', width: 16 },
|
|
10
|
+
{ token: 'space-10', value: '20px', width: 20 },
|
|
11
|
+
{ token: 'space-16', value: '32px', width: 32 },
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
export default defineCases(
|
|
15
|
+
'SpacingScale',
|
|
16
|
+
{
|
|
17
|
+
Scale: () => <SpacingScale steps={steps} />,
|
|
18
|
+
},
|
|
19
|
+
{ level: 'molecule' },
|
|
20
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
**SpacingScale** — a column of spacing rows, each a mono token tag, its resolved value, and a bar whose width visualises the step; reach for it to show a spacing scale to scale.
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
<SpacingScale
|
|
5
|
+
steps={[
|
|
6
|
+
{ token: 'space-4', value: '8px', width: 8 },
|
|
7
|
+
{ token: 'space-8', value: '16px', width: 16 },
|
|
8
|
+
]}
|
|
9
|
+
/>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`value` (the display string) and `width` (the bar length in px) are independent inputs the caller keeps in sync — neither is derived from the other, so a mismatch will silently render a misleading bar.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Case — SpacingScale
|
|
3
|
+
* A column of spacing rows: a mono token tag, its resolved value, and a bar
|
|
4
|
+
* whose width visualises the step. Generic specimen primitive for a Primer —
|
|
5
|
+
* use it to show a spacing scale to scale.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface SpaceStep {
|
|
9
|
+
/** Mono token tag (e.g. `space-4`); also the React key. */
|
|
10
|
+
token: string
|
|
11
|
+
/** Resolved value shown in mono (e.g. `8px`). */
|
|
12
|
+
value: string
|
|
13
|
+
/** Bar width in pixels — visualises the step. */
|
|
14
|
+
width: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SpacingScaleProps {
|
|
18
|
+
steps: SpaceStep[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function SpacingScale({ steps }: SpacingScaleProps) {
|
|
22
|
+
return (
|
|
23
|
+
<div className="dcpl-spacescale">
|
|
24
|
+
{steps.map((s) => (
|
|
25
|
+
<div className="dcpl-spacerow" key={s.token}>
|
|
26
|
+
<div className="dcpl-spacetag">{s.token}</div>
|
|
27
|
+
<div className="dcpl-spacepx">{s.value}</div>
|
|
28
|
+
<div className="dcpl-spacebar" style={{ width: `${s.width}px` }} />
|
|
29
|
+
</div>
|
|
30
|
+
))}
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineCases } from '@awarebydefault/display-case'
|
|
2
|
+
import { type BoxSpec, SpecimenBoxRow } from './SpecimenBoxRow'
|
|
3
|
+
|
|
4
|
+
const radii: BoxSpec[] = [
|
|
5
|
+
{ label: 'none', note: '0', boxStyle: { borderRadius: '0' } },
|
|
6
|
+
{
|
|
7
|
+
label: 'sm',
|
|
8
|
+
note: '5px · controls',
|
|
9
|
+
boxStyle: { borderRadius: 'var(--dc-radius-sm)' },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: 'md',
|
|
13
|
+
note: '8px · panels',
|
|
14
|
+
boxStyle: { borderRadius: 'var(--dc-radius-md)' },
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: 'full',
|
|
18
|
+
note: 'pills · dots',
|
|
19
|
+
boxStyle: { borderRadius: 'var(--dc-radius-full)', width: '48px' },
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
const elevation: BoxSpec[] = [
|
|
24
|
+
{
|
|
25
|
+
note: 'border-line',
|
|
26
|
+
content: '1px border',
|
|
27
|
+
boxStyle: {
|
|
28
|
+
width: '134px',
|
|
29
|
+
height: '56px',
|
|
30
|
+
background: 'var(--dc-surface)',
|
|
31
|
+
borderRadius: 'var(--dc-radius-md)',
|
|
32
|
+
border: 'var(--dc-border-line)',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
note: 'menus / popovers only',
|
|
37
|
+
content: 'overlay',
|
|
38
|
+
boxStyle: {
|
|
39
|
+
width: '134px',
|
|
40
|
+
height: '56px',
|
|
41
|
+
background: 'var(--dc-surface)',
|
|
42
|
+
borderRadius: 'var(--dc-radius-md)',
|
|
43
|
+
border: 'var(--dc-border-line)',
|
|
44
|
+
boxShadow: 'var(--dc-shadow-overlay)',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
export default defineCases(
|
|
50
|
+
'SpecimenBoxRow',
|
|
51
|
+
{
|
|
52
|
+
Radius: () => <SpecimenBoxRow items={radii} />,
|
|
53
|
+
Elevation: () => <SpecimenBoxRow items={elevation} />,
|
|
54
|
+
},
|
|
55
|
+
{ level: 'molecule' },
|
|
56
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
**SpecimenBoxRow** — a row of labelled boxes, each a flat surface whose own style carries the thing
|
|
2
|
+
being shown (a corner radius, a border weight, an elevation shadow), over a
|
|
3
|
+
label + note. A reusable Primer specimen that generalises the radius and
|
|
4
|
+
elevation rows, so one component documents any box-led token.
|
|
5
|
+
|
|
6
|
+
```tsx
|
|
7
|
+
<SpecimenBoxRow
|
|
8
|
+
items={[
|
|
9
|
+
{ label: 'md', note: '8px · panels', boxStyle: { borderRadius: 'var(--dc-radius-md)' } },
|
|
10
|
+
{ note: 'overlay', content: 'overlay', boxStyle: { boxShadow: 'var(--dc-shadow-overlay)' } },
|
|
11
|
+
]}
|
|
12
|
+
/>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`boxStyle` paints the specimen itself (radius, border, shadow…); `content` is an optional node centred inside the box.
|
|
16
|
+
|
|
17
|
+
Use this when the token IS the box's own shape. For a flat colour chip beside a token use `SwatchGrid`; for a width bar use `SpacingScale`; for a glyph tile use `GlyphGrid`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Display Case — SpecimenBoxRow
|
|
5
|
+
* A row of labelled boxes — each a flat surface whose own style carries the
|
|
6
|
+
* thing being shown (a corner radius, a border weight, an elevation shadow),
|
|
7
|
+
* over a label + note. Generic specimen primitive for a Primer: it generalises
|
|
8
|
+
* the radius and elevation rows, so one component documents any box-led token.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface BoxSpec {
|
|
12
|
+
/** Bold label under the box (also the React key when `note` is absent). */
|
|
13
|
+
label?: string
|
|
14
|
+
/** Mono caption under the label. */
|
|
15
|
+
note?: string
|
|
16
|
+
/** Style applied to the box — the specimen itself (radius, border, shadow…). */
|
|
17
|
+
boxStyle?: CSSProperties
|
|
18
|
+
/** Optional content rendered inside the box (centred). */
|
|
19
|
+
content?: ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SpecimenBoxRowProps {
|
|
23
|
+
items: BoxSpec[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function SpecimenBoxRow({ items }: SpecimenBoxRowProps) {
|
|
27
|
+
return (
|
|
28
|
+
<div className="dcpl-boxrow">
|
|
29
|
+
{items.map((item, i) => (
|
|
30
|
+
<div
|
|
31
|
+
className="dcpl-boxitem"
|
|
32
|
+
// Labels/notes may repeat across a row, so fall back to the index.
|
|
33
|
+
key={item.label ?? item.note ?? i}>
|
|
34
|
+
<div className="dcpl-box" style={item.boxStyle}>
|
|
35
|
+
{item.content}
|
|
36
|
+
</div>
|
|
37
|
+
<div className="dcpl-boxlbl">
|
|
38
|
+
{item.label ? <b>{item.label}</b> : null}
|
|
39
|
+
{item.note ? <span>{item.note}</span> : null}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
))}
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineCases } from '@awarebydefault/display-case'
|
|
2
|
+
import { type StatusItem, StatusList } from './StatusList'
|
|
3
|
+
|
|
4
|
+
const hues: StatusItem[] = [
|
|
5
|
+
{ name: 'success', color: 'var(--dc-success)', caption: 'green-600' },
|
|
6
|
+
{ name: 'warning', color: 'var(--dc-warning)', caption: 'amber-500' },
|
|
7
|
+
{ name: 'danger', color: 'var(--dc-danger)', caption: 'red-600' },
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
export default defineCases(
|
|
11
|
+
'StatusList',
|
|
12
|
+
{
|
|
13
|
+
Statuses: () => <StatusList items={hues} />,
|
|
14
|
+
Single: () => <StatusList items={[hues[0]]} />,
|
|
15
|
+
},
|
|
16
|
+
{ level: 'molecule' },
|
|
17
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
**StatusList** — a row of status items, a coloured dot beside a name and a short caption, each
|
|
2
|
+
boxed in a hairline card. A reusable Primer specimen for documenting a small
|
|
3
|
+
reserved set of status hues (pass, warn, fail) or any dot-keyed legend.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<StatusList
|
|
7
|
+
items={[
|
|
8
|
+
{ name: 'success', color: 'var(--dc-success)', caption: 'green-600' },
|
|
9
|
+
{ name: 'danger', color: 'var(--dc-danger)', caption: 'red-600' },
|
|
10
|
+
]}
|
|
11
|
+
/>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Keep each `color` as the whole `var(--dc-…)` literal so the token check resolves it.
|
|
15
|
+
|
|
16
|
+
Use this for a fixed legend of named statuses. For an ordered single-family ramp reach for `ColorRamp`; for a grid of semantic role tokens reach for `SwatchGrid`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Case — StatusList
|
|
3
|
+
* A row of status items: a coloured dot beside a name and a short caption, each
|
|
4
|
+
* boxed in a hairline card. Generic specimen primitive for a Primer — use it to
|
|
5
|
+
* document a small reserved set of status hues (pass, warn, fail) or any other
|
|
6
|
+
* dot-keyed legend.
|
|
7
|
+
*
|
|
8
|
+
* Each item's `color` is a complete CSS value (`var(--dc-success)` or a hex);
|
|
9
|
+
* keep the whole `var(...)` literal so the token-conformance check resolves it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface StatusItem {
|
|
13
|
+
/** Status name shown in bold (also the React key). */
|
|
14
|
+
name: string
|
|
15
|
+
/** Complete CSS colour value painted on the dot. */
|
|
16
|
+
color: string
|
|
17
|
+
/** Short caption under the name (e.g. the underlying token). */
|
|
18
|
+
caption?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface StatusListProps {
|
|
22
|
+
items: StatusItem[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function StatusList({ items }: StatusListProps) {
|
|
26
|
+
return (
|
|
27
|
+
<div className="dcpl-status">
|
|
28
|
+
{items.map((s) => (
|
|
29
|
+
<div className="dcpl-statusitem" key={s.name}>
|
|
30
|
+
<div className="dcpl-statusdot" style={{ background: s.color }} />
|
|
31
|
+
<div>
|
|
32
|
+
<b>{s.name}</b>
|
|
33
|
+
{s.caption ? <span>{s.caption}</span> : null}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
))}
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineCases, tweak } from '@awarebydefault/display-case'
|
|
2
|
+
import { type Swatch, SwatchGrid } from './SwatchGrid'
|
|
3
|
+
|
|
4
|
+
const roles: Swatch[] = [
|
|
5
|
+
{ token: 'bg', color: 'var(--dc-bg)', role: 'canvas' },
|
|
6
|
+
{ token: 'bg-subtle', color: 'var(--dc-bg-subtle)', role: 'sidebar' },
|
|
7
|
+
{ token: 'surface', color: 'var(--dc-surface)', role: 'inputs' },
|
|
8
|
+
{ token: 'border', color: 'var(--dc-border)', role: 'hairline' },
|
|
9
|
+
{ token: 'fg', color: 'var(--dc-fg)', role: 'text' },
|
|
10
|
+
{ token: 'fg-muted', color: 'var(--dc-fg-muted)', role: 'labels' },
|
|
11
|
+
{ token: 'brand', color: 'var(--dc-brand)', role: 'accent' },
|
|
12
|
+
{ token: 'brand-subtle', color: 'var(--dc-brand-subtle)', role: 'wash' },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
export default defineCases(
|
|
16
|
+
'SwatchGrid',
|
|
17
|
+
{
|
|
18
|
+
Playground: {
|
|
19
|
+
tweaks: { columns: tweak.number(4) },
|
|
20
|
+
render: (t) => <SwatchGrid swatches={roles} columns={t.columns} />,
|
|
21
|
+
},
|
|
22
|
+
Roles: () => <SwatchGrid swatches={roles} />,
|
|
23
|
+
TwoUp: () => <SwatchGrid swatches={roles} columns={2} />,
|
|
24
|
+
},
|
|
25
|
+
{ level: 'molecule' },
|
|
26
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
**SwatchGrid** — a grid of UNORDERED semantic role tokens, each a colour chip beside a token name and a short role note; reach for it to document the roles a system exposes (canvas, surface, border, text, accent…).
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
<SwatchGrid
|
|
5
|
+
columns={4}
|
|
6
|
+
swatches={[
|
|
7
|
+
{ token: 'surface', color: 'var(--dc-surface)', role: 'inputs' },
|
|
8
|
+
{ token: 'brand', color: 'var(--dc-brand)', role: 'accent' },
|
|
9
|
+
]}
|
|
10
|
+
/>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For an ordered single family shown as a ramp, reach for `ColorRamp`.
|
|
14
|
+
|
|
15
|
+
Keep each `color` as the whole `var(--dc-…)` literal so the token check resolves it.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Case — SwatchGrid
|
|
3
|
+
* A grid of role swatches: a colour chip beside a token name and a short role
|
|
4
|
+
* note. Generic specimen primitive for a Primer — use it to document the
|
|
5
|
+
* semantic role tokens a system exposes (canvas, surface, border, text, accent…).
|
|
6
|
+
*
|
|
7
|
+
* Each swatch's `color` is a complete CSS value (`var(--dc-surface)` or a hex);
|
|
8
|
+
* keep the whole `var(...)` literal so the token-conformance check resolves it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface Swatch {
|
|
12
|
+
/** Token name shown in bold (also the React key). */
|
|
13
|
+
token: string
|
|
14
|
+
/** Complete CSS colour value painted on the chip. */
|
|
15
|
+
color: string
|
|
16
|
+
/** Short role note under the token. */
|
|
17
|
+
role?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SwatchGridProps {
|
|
21
|
+
swatches: Swatch[]
|
|
22
|
+
/** Number of columns in the grid. */
|
|
23
|
+
columns?: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function SwatchGrid({ swatches, columns = 4 }: SwatchGridProps) {
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
className="dcpl-swgrid"
|
|
30
|
+
style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }}>
|
|
31
|
+
{swatches.map((s) => (
|
|
32
|
+
<div className="dcpl-swrow" key={s.token}>
|
|
33
|
+
<div className="dcpl-swchip" style={{ background: s.color }} />
|
|
34
|
+
<div className="dcpl-swtok">
|
|
35
|
+
<b>{s.token}</b>
|
|
36
|
+
{s.role ? <span>{s.role}</span> : null}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineCases } from '@awarebydefault/display-case'
|
|
2
|
+
import { TypeScale, type TypeStep } from './TypeScale'
|
|
3
|
+
|
|
4
|
+
const scale: TypeStep[] = [
|
|
5
|
+
{ tag: 'xl · 28', size: '28px', sample: 'Doc heading' },
|
|
6
|
+
{ tag: 'lg · 20', size: '20px', sample: 'Section title' },
|
|
7
|
+
{ tag: 'md · 16', size: '16px', sample: 'Emphasis' },
|
|
8
|
+
{
|
|
9
|
+
tag: 'base · 14',
|
|
10
|
+
size: '14px',
|
|
11
|
+
sample: 'Chrome baseline — nav, buttons, body',
|
|
12
|
+
},
|
|
13
|
+
{ tag: 'sm · 12', size: '12px', sample: 'Secondary — captions' },
|
|
14
|
+
{ tag: 'xs · 11', size: '11px', sample: 'Eyebrow labels' },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
export default defineCases(
|
|
18
|
+
'TypeScale',
|
|
19
|
+
{
|
|
20
|
+
Scale: () => <TypeScale steps={scale} />,
|
|
21
|
+
},
|
|
22
|
+
{ level: 'molecule' },
|
|
23
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
**TypeScale** — a column of type-size rows, a mono tag beside a live sample rendered at the
|
|
2
|
+
step's size. A reusable Primer specimen for documenting a type scale at its
|
|
3
|
+
real sizes.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<TypeScale
|
|
7
|
+
steps={[
|
|
8
|
+
{ tag: 'lg · 20', size: '20px', sample: 'Section title' },
|
|
9
|
+
{ tag: 'base · 14', size: '14px', sample: 'Body baseline' },
|
|
10
|
+
]}
|
|
11
|
+
/>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Use this for size steps. For weights reach for `WeightSpecimen`; for which families exist reach for `FontFamilies`.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Case — TypeScale
|
|
3
|
+
* A column of type-size rows: a mono tag beside a live sample rendered at the
|
|
4
|
+
* step's size. Generic specimen primitive for a Primer — use it to document a
|
|
5
|
+
* type scale at its real sizes.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface TypeStep {
|
|
9
|
+
/** Mono tag on the left (e.g. `base · 14`); also the React key. */
|
|
10
|
+
tag: string
|
|
11
|
+
/** CSS font-size the sample renders at (e.g. `14px`, `1.5rem`). */
|
|
12
|
+
size: string
|
|
13
|
+
/** The sample text rendered at `size`. */
|
|
14
|
+
sample: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TypeScaleProps {
|
|
18
|
+
steps: TypeStep[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function TypeScale({ steps }: TypeScaleProps) {
|
|
22
|
+
return (
|
|
23
|
+
<div className="dcpl-scale">
|
|
24
|
+
{steps.map((s) => (
|
|
25
|
+
<div className="dcpl-scalerow" key={s.tag}>
|
|
26
|
+
<div className="dcpl-scaletag">{s.tag}</div>
|
|
27
|
+
<div className="dcpl-scalespec" style={{ fontSize: s.size }}>
|
|
28
|
+
{s.sample}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
))}
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineCases } from '@awarebydefault/display-case'
|
|
2
|
+
import { Eyebrow } from '../showcase/Eyebrow'
|
|
3
|
+
import { type WeightSpec, WeightSpecimen } from './WeightSpecimen'
|
|
4
|
+
|
|
5
|
+
const weights: WeightSpec[] = [
|
|
6
|
+
{ weight: 400, name: 'Normal', role: 'body' },
|
|
7
|
+
{ weight: 500, name: 'Medium', role: 'active' },
|
|
8
|
+
{ weight: 600, name: 'Semibold', role: 'titles' },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
export default defineCases(
|
|
12
|
+
'WeightSpecimen',
|
|
13
|
+
{
|
|
14
|
+
Weights: () => <WeightSpecimen weights={weights} />,
|
|
15
|
+
WithFooter: () => (
|
|
16
|
+
<WeightSpecimen
|
|
17
|
+
weights={weights}
|
|
18
|
+
footer={
|
|
19
|
+
<>
|
|
20
|
+
<div className="dcpl-divider" />
|
|
21
|
+
<Eyebrow>Group label · 11px / 500 / 0.08em uppercase</Eyebrow>
|
|
22
|
+
</>
|
|
23
|
+
}
|
|
24
|
+
/>
|
|
25
|
+
),
|
|
26
|
+
},
|
|
27
|
+
{ level: 'molecule' },
|
|
28
|
+
)
|