@bridgebrew/design-system 0.0.0-stage → 0.1.9

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.
@@ -0,0 +1,157 @@
1
+ // Foundations: the theme's tokens, shown with what they set (a swatch's fill, a specimen's type, a box's radius or
2
+ // shadow), read live with `var(--…)`, so every theme shows its own values.
3
+ import * as React from 'react';
4
+ import { Card, ICON_NAMES, Icon, Input, Section } from '@bridge/ui';
5
+ import { Group, Sample, useTheme } from './parts.tsx';
6
+
7
+ const colorGroups: { title: string; description: string; tokens: string[] }[] = [
8
+ { title: 'Backgrounds', description: 'The page, raised surfaces, and the hover and active fills.', tokens: ['--bg', '--bg-surface', '--bg-hover', '--bg-active', '--bg-sidebar', '--bg-badge'] },
9
+ { title: 'Text', description: 'From the strongest to the faintest.', tokens: ['--fg', '--fg-secondary', '--fg-muted', '--fg-placeholder'] },
10
+ { title: 'Borders', description: 'Hairlines between regions, inside lists, and around inputs.', tokens: ['--border', '--border-subtle', '--border-input'] },
11
+ { title: 'Accent', description: 'Primary actions, selection and focus; -fg is text on the accent.', tokens: ['--accent', '--accent-hover', '--accent-fg', '--accent-subtle'] },
12
+ { title: 'Status', description: 'Errors, success and warnings; warning-text is the readable yellow.', tokens: ['--destructive', '--destructive-subtle', '--destructive-fg', '--success', '--success-subtle', '--success-fg', '--warning', '--warning-subtle', '--warning-fg', '--warning-text'] },
13
+ { title: 'Labels', description: 'The Label chips: background, text and dot.', tokens: ['--label-bug-bg', '--label-bug-fg', '--label-bug-dot', '--label-feature-bg', '--label-feature-fg', '--label-feature-dot', '--label-improvement-bg', '--label-improvement-fg', '--label-improvement-dot', '--label-tag-dot'] },
14
+ ];
15
+
16
+ /** A token's value on the page now; `px` gives a rem length in pixels. */
17
+ const valueOf = (token: string) => getComputedStyle(document.documentElement).getPropertyValue(token).trim();
18
+ const px = (token: string) => {
19
+ const value = valueOf(token);
20
+ return value.endsWith('rem') ? `${Number.parseFloat(value) * 16}px` : value;
21
+ };
22
+
23
+ function Colors() {
24
+ useTheme();
25
+ return colorGroups.map(({ title, description, tokens }) => (
26
+ <Group key={title} title={title} description={description} layout="grid">
27
+ {tokens.map((token) => (
28
+ <Sample key={token} title={token} description={valueOf(token)}>
29
+ <Card variant="outline" className="ds-swatch" style={{ background: `var(${token})` }} />
30
+ </Sample>
31
+ ))}
32
+ </Group>
33
+ ));
34
+ }
35
+
36
+ const scale = [
37
+ ['2xl', 'Display; not used by the kit yet'],
38
+ ['xl', 'Page titles: Section lg, Input inline-title'],
39
+ ['lg', 'Large headings'],
40
+ ['base', 'Dialog titles, Button lg'],
41
+ ['field', 'Inline descriptions: Textarea'],
42
+ ['sm', 'Body text: inputs, menus, lists, buttons'],
43
+ ['xs', 'Captions, badges, labels, hints'],
44
+ ] as const;
45
+ const weights = [['normal', 400], ['medium', 500], ['semibold', 600], ['bold', 700]] as const;
46
+ const specimen = 'Ship the storyboard before the sprint review';
47
+
48
+ function Typography() {
49
+ useTheme();
50
+ return (
51
+ <>
52
+ <Group title="Scale" description="Each size with its paired line height (--text-<size>, --text-<size>--line-height)." layout="stack">
53
+ {scale.map(([size, use]) => (
54
+ <Sample key={size} title={`${size} · ${px(`--text-${size}`)} / ${px(`--text-${size}--line-height`)}`} description={use} wide>
55
+ <p className="ds-specimen" style={{ fontFamily: 'var(--font-sans)', fontSize: `var(--text-${size})`, lineHeight: `var(--text-${size}--line-height)`, color: 'var(--fg)' }}>{specimen}</p>
56
+ </Sample>
57
+ ))}
58
+ </Group>
59
+ <Group title="Weights" description="Medium for labels and buttons, semibold for titles." layout="grid">
60
+ {weights.map(([weight, value]) => (
61
+ <Sample key={weight} title={`${weight} · ${value}`}>
62
+ <p className="ds-specimen" style={{ fontFamily: 'var(--font-sans)', fontSize: 'var(--text-lg)', lineHeight: 'var(--text-lg--line-height)', fontWeight: value, color: 'var(--fg)' }}>Bridge</p>
63
+ </Sample>
64
+ ))}
65
+ </Group>
66
+ <Group title="Families" description="The system stack for text, a monospace stack for code." layout="stack">
67
+ {(['sans', 'mono'] as const).map((family) => (
68
+ <Sample key={family} title={`--font-${family}`} description={valueOf(`--font-${family}`)} wide>
69
+ <p className="ds-specimen" style={{ fontFamily: `var(--font-${family})`, fontSize: 'var(--text-base)', lineHeight: 'var(--text-base--line-height)', color: 'var(--fg)' }}>
70
+ {family === 'sans' ? 'Aa Bb Cc 0123456789 — the quick brown fox' : 'const theme = getTheme(); // 0O 1lI'}
71
+ </p>
72
+ </Sample>
73
+ ))}
74
+ </Group>
75
+ <Group title="Text colours" description="The four text tokens on the page background." layout="grid">
76
+ {(['--fg', '--fg-secondary', '--fg-muted', '--fg-placeholder'] as const).map((token) => (
77
+ <Sample key={token} title={token}>
78
+ <p className="ds-specimen" style={{ fontFamily: 'var(--font-sans)', fontSize: 'var(--text-sm)', lineHeight: 'var(--text-sm--line-height)', color: `var(${token})` }}>Quarterly report</p>
79
+ </Sample>
80
+ ))}
81
+ </Group>
82
+ </>
83
+ );
84
+ }
85
+
86
+ const heights = [['xs', 'Compact chips'], ['sm', 'Button sm, Picker sm, Select sm'], ['md', 'Button default, menu items, sidebar rows'], ['lg', 'Outline inputs, property rows, Button lg']] as const;
87
+ const radii = [['sm', 'Buttons, menu items'], ['default', 'Inputs, segment groups, toasts'], ['dropdown', 'Cards, menus, popups'], ['dialog', 'Dialogs']] as const;
88
+ const shadows = [['xs', ''], ['sm', 'Elevated cards'], ['md', 'Drag overlays'], ['lg', ''], ['xl', ''], ['2xl', ''], ['dropdown', 'Menus and popups'], ['dialog', 'Dialogs'], ['tooltip', 'Tooltips']] as const;
89
+
90
+ function Sizes() {
91
+ useTheme();
92
+ return (
93
+ <>
94
+ <Group title="Heights" description="Every control sits on one of four heights (--height-<size>)." layout="grid">
95
+ {heights.map(([size, use]) => (
96
+ <Sample key={size} title={`${size} · ${valueOf(`--height-${size}`)}`} description={use}>
97
+ <Card variant="outline" className="ds-bar" style={{ height: `var(--height-${size})`, background: 'var(--accent-subtle)' }} />
98
+ </Sample>
99
+ ))}
100
+ </Group>
101
+ <Group title="Radii" description="Corner radii (--radius-<name>); pills are fully rounded." layout="grid">
102
+ {radii.map(([name, use]) => (
103
+ <Sample key={name} title={`${name} · ${valueOf(`--radius-${name}`)}`} description={use}>
104
+ <Card variant="outline" className="ds-box" style={{ borderRadius: `var(--radius-${name})` }} />
105
+ </Sample>
106
+ ))}
107
+ </Group>
108
+ <Group title="Shadows" description="Elevation (--shadow-<name>); the overlay ones follow the theme." layout="grid">
109
+ {shadows.map(([name, use]) => (
110
+ <Sample key={name} title={name} description={use || undefined}>
111
+ <Card variant="ghost" className="ds-box" style={{ boxShadow: `var(--shadow-${name})`, background: 'var(--bg-surface)' }} />
112
+ </Sample>
113
+ ))}
114
+ </Group>
115
+ </>
116
+ );
117
+ }
118
+
119
+ function Icons() {
120
+ const [query, setQuery] = React.useState('');
121
+ const shown = ICON_NAMES.filter((name) => name.includes(query.trim().toLowerCase()));
122
+ return (
123
+ <Section
124
+ title={`${shown.length} of ${ICON_NAMES.length} icons`}
125
+ description='By name, as a manifest or <Icon name="…" /> takes it; an unknown name shows "file".'
126
+ actions={(
127
+ <div className="ds-control">
128
+ <Input
129
+ variant="outline"
130
+ size="default"
131
+ type="search"
132
+ aria-label="Search icons"
133
+ placeholder="Search icons"
134
+ icon={<Icon name="search" size={14} />}
135
+ value={query}
136
+ onChange={(event) => setQuery(event.currentTarget.value)}
137
+ />
138
+ </div>
139
+ )}
140
+ >
141
+ {shown.length === 0 ? (
142
+ <Card variant="outline" size="lg" className="ds-empty"><Section size="sm" title="No icon matches" description="Icons are named in kebab-case, e.g. map-pin." /></Card>
143
+ ) : (
144
+ <div className="ds-icons">
145
+ {shown.map((name) => (
146
+ <Card key={name} variant="outline" className="ds-icon-tile">
147
+ <Icon name={name} size={20} />
148
+ <Section size="sm" title={name} />
149
+ </Card>
150
+ ))}
151
+ </div>
152
+ )}
153
+ </Section>
154
+ );
155
+ }
156
+
157
+ export const foundations = { colors: Colors, typography: Typography, sizes: Sizes, icons: Icons };