@discourser/design-system 0.3.1 → 0.5.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 (36) hide show
  1. package/README.md +12 -4
  2. package/dist/styles.css +5126 -0
  3. package/guidelines/Guidelines.md +92 -41
  4. package/guidelines/components/accordion.md +732 -0
  5. package/guidelines/components/avatar.md +1015 -0
  6. package/guidelines/components/badge.md +728 -0
  7. package/guidelines/components/button.md +75 -40
  8. package/guidelines/components/card.md +84 -25
  9. package/guidelines/components/checkbox.md +671 -0
  10. package/guidelines/components/dialog.md +619 -31
  11. package/guidelines/components/drawer.md +1616 -0
  12. package/guidelines/components/heading.md +576 -0
  13. package/guidelines/components/icon-button.md +92 -37
  14. package/guidelines/components/input-addon.md +685 -0
  15. package/guidelines/components/input-group.md +830 -0
  16. package/guidelines/components/input.md +92 -37
  17. package/guidelines/components/popover.md +1271 -0
  18. package/guidelines/components/progress.md +836 -0
  19. package/guidelines/components/radio-group.md +852 -0
  20. package/guidelines/components/select.md +1662 -0
  21. package/guidelines/components/skeleton.md +802 -0
  22. package/guidelines/components/slider.md +911 -0
  23. package/guidelines/components/spinner.md +783 -0
  24. package/guidelines/components/switch.md +105 -38
  25. package/guidelines/components/tabs.md +1488 -0
  26. package/guidelines/components/textarea.md +495 -0
  27. package/guidelines/components/toast.md +784 -0
  28. package/guidelines/components/tooltip.md +912 -0
  29. package/guidelines/design-tokens/colors.md +309 -72
  30. package/guidelines/design-tokens/elevation.md +615 -45
  31. package/guidelines/design-tokens/spacing.md +654 -74
  32. package/guidelines/design-tokens/typography.md +432 -50
  33. package/guidelines/overview-components.md +60 -8
  34. package/guidelines/overview-imports.md +314 -0
  35. package/guidelines/overview-patterns.md +3852 -0
  36. package/package.json +4 -2
@@ -0,0 +1,314 @@
1
+ # Package Installation & Imports
2
+
3
+ This guide explains how to install and import components from the Discourser Design System.
4
+
5
+ ## Installation
6
+
7
+ Install the design system package and its peer dependencies:
8
+
9
+ ```bash
10
+ npm install @discourser/design-system react react-dom
11
+ ```
12
+
13
+ Or with yarn:
14
+
15
+ ```bash
16
+ yarn add @discourser/design-system react react-dom
17
+ ```
18
+
19
+ Or with pnpm:
20
+
21
+ ```bash
22
+ pnpm add @discourser/design-system react react-dom
23
+ ```
24
+
25
+ ## Import Patterns
26
+
27
+ The design system exports components in two patterns: **Simple Components** and **Compound Components**.
28
+
29
+ ### Simple Components
30
+
31
+ These components are exported directly and can be imported using named imports:
32
+
33
+ ```typescript
34
+ import {
35
+ Button,
36
+ Card,
37
+ Input,
38
+ InputAddon,
39
+ InputGroup,
40
+ Textarea,
41
+ Heading,
42
+ Badge,
43
+ Spinner,
44
+ Toaster,
45
+ toaster,
46
+ } from '@discourser/design-system';
47
+ ```
48
+
49
+ **Simple components include:**
50
+
51
+ - Button
52
+ - Card
53
+ - Input
54
+ - InputAddon
55
+ - InputGroup
56
+ - Textarea
57
+ - Heading
58
+ - Badge
59
+ - Spinner
60
+ - Toast (Toaster component and toaster API)
61
+
62
+ ### Compound Components
63
+
64
+ These components use a compound pattern with multiple sub-components. Import them as namespaces:
65
+
66
+ ```typescript
67
+ import * as Checkbox from '@discourser/design-system';
68
+ import * as RadioGroup from '@discourser/design-system';
69
+ import * as Select from '@discourser/design-system';
70
+ import * as Dialog from '@discourser/design-system';
71
+ import * as Drawer from '@discourser/design-system';
72
+ import * as Popover from '@discourser/design-system';
73
+ import * as Tooltip from '@discourser/design-system';
74
+ import * as Accordion from '@discourser/design-system';
75
+ import * as Tabs from '@discourser/design-system';
76
+ import * as Avatar from '@discourser/design-system';
77
+ import * as Progress from '@discourser/design-system';
78
+ import * as Skeleton from '@discourser/design-system';
79
+ import * as IconButton from '@discourser/design-system';
80
+ import * as Switch from '@discourser/design-system';
81
+ import * as Slider from '@discourser/design-system';
82
+ ```
83
+
84
+ **Compound components include:**
85
+
86
+ - Checkbox (Checkbox.Root, Checkbox.Control, Checkbox.Label, Checkbox.Indicator)
87
+ - RadioGroup (RadioGroup.Root, RadioGroup.Item, RadioGroup.ItemControl, RadioGroup.ItemText)
88
+ - Select (Select.Root, Select.Control, Select.Trigger, Select.Content, Select.Item, etc.)
89
+ - Dialog (Dialog.Root, Dialog.Trigger, Dialog.Content, Dialog.Title, etc.)
90
+ - Drawer (Drawer.Root, Drawer.Trigger, Drawer.Content, etc.)
91
+ - Popover (Popover.Root, Popover.Trigger, Popover.Content, etc.)
92
+ - Tooltip (Tooltip.Root, Tooltip.Trigger, Tooltip.Content)
93
+ - Accordion (Accordion.Root, Accordion.Item, Accordion.Trigger, Accordion.Content)
94
+ - Tabs (Tabs.Root, Tabs.List, Tabs.Trigger, Tabs.Content, etc.)
95
+ - Avatar (Avatar.Root, Avatar.Image, Avatar.Fallback)
96
+ - Progress (Progress.Root, Progress.Track, Progress.Range, etc.)
97
+ - Skeleton (Skeleton.Root, Skeleton.Item)
98
+ - IconButton (IconButton.Root)
99
+ - Switch (Switch.Root, Switch.Control, Switch.Thumb, Switch.Label)
100
+ - Slider (Slider.Root, Slider.Control, Slider.Track, Slider.Thumb, etc.)
101
+
102
+ ### Styling Utilities
103
+
104
+ For advanced custom styling, import Panda CSS utilities:
105
+
106
+ ```typescript
107
+ // CSS function for inline styles
108
+ import { css } from '@discourser/design-system/styled-system/css';
109
+
110
+ // Recipe functions for component variants
111
+ import { button } from '@discourser/design-system/styled-system/recipes';
112
+
113
+ // Styled function for creating styled components
114
+ import { styled } from '@discourser/design-system/styled-system/jsx';
115
+ ```
116
+
117
+ **When to use styling utilities:**
118
+
119
+ - Use `css()` for one-off custom styles that don't belong in a component variant
120
+ - Use recipe functions when you need to replicate component styles
121
+ - Use `styled()` when creating new styled components
122
+ - **Always prefer using component variants** over custom styling
123
+
124
+ ## Common Import Patterns
125
+
126
+ ### Basic Form
127
+
128
+ ```typescript
129
+ import { Input, Textarea, Select, Button } from '@discourser/design-system';
130
+ import { css } from '@discourser/design-system/styled-system/css';
131
+
132
+ function ContactForm() {
133
+ return (
134
+ <form className={css({ display: 'flex', flexDirection: 'column', gap: 'lg' })}>
135
+ <Input label="Name" />
136
+ <Input label="Email" type="email" />
137
+ <Textarea label="Message" rows={5} />
138
+ <Button type="submit">Send</Button>
139
+ </form>
140
+ );
141
+ }
142
+ ```
143
+
144
+ ### Dialog with Form
145
+
146
+ ```typescript
147
+ import * as Dialog from '@discourser/design-system';
148
+ import { Input, Button } from '@discourser/design-system';
149
+
150
+ function CreateDialog() {
151
+ return (
152
+ <Dialog.Root>
153
+ <Dialog.Trigger>
154
+ <Button>Create Item</Button>
155
+ </Dialog.Trigger>
156
+ <Dialog.Content>
157
+ <Dialog.Title>Create New Item</Dialog.Title>
158
+ <Input label="Name" />
159
+ <Input label="Description" />
160
+ <Button>Save</Button>
161
+ </Dialog.Content>
162
+ </Dialog.Root>
163
+ );
164
+ }
165
+ ```
166
+
167
+ ### Navigation with Drawer
168
+
169
+ ```typescript
170
+ import * as Drawer from '@discourser/design-system';
171
+ import { IconButton } from '@discourser/design-system';
172
+ import { MenuIcon } from 'your-icon-library';
173
+
174
+ function Navigation() {
175
+ return (
176
+ <Drawer.Root>
177
+ <Drawer.Trigger asChild>
178
+ <IconButton aria-label="Open menu">
179
+ <MenuIcon />
180
+ </IconButton>
181
+ </Drawer.Trigger>
182
+ <Drawer.Content>
183
+ <nav>
184
+ <a href="/dashboard">Dashboard</a>
185
+ <a href="/settings">Settings</a>
186
+ </nav>
187
+ </Drawer.Content>
188
+ </Drawer.Root>
189
+ );
190
+ }
191
+ ```
192
+
193
+ ### Search with InputGroup
194
+
195
+ ```typescript
196
+ import { InputGroup, Input } from '@discourser/design-system';
197
+ import { SearchIcon } from 'your-icon-library';
198
+
199
+ function SearchBar() {
200
+ return (
201
+ <InputGroup startElement={<SearchIcon />}>
202
+ <Input placeholder="Search..." />
203
+ </InputGroup>
204
+ );
205
+ }
206
+ ```
207
+
208
+ ### Toast Notifications
209
+
210
+ ```typescript
211
+ import { Button, toaster } from '@discourser/design-system';
212
+
213
+ function SaveButton() {
214
+ const handleSave = async () => {
215
+ try {
216
+ await saveData();
217
+ toaster.success({
218
+ title: 'Saved!',
219
+ description: 'Your changes have been saved.'
220
+ });
221
+ } catch (error) {
222
+ toaster.error({
223
+ title: 'Failed to save',
224
+ description: error.message
225
+ });
226
+ }
227
+ };
228
+
229
+ return <Button onClick={handleSave}>Save</Button>;
230
+ }
231
+ ```
232
+
233
+ ## TypeScript Support
234
+
235
+ All components are fully typed with TypeScript. Import types as needed:
236
+
237
+ ```typescript
238
+ import { Button, type ButtonProps } from '@discourser/design-system';
239
+ import type { InputProps } from '@discourser/design-system';
240
+ import type * as Dialog from '@discourser/design-system';
241
+
242
+ // Use component props in your custom components
243
+ function CustomButton(props: ButtonProps) {
244
+ return <Button {...props} />;
245
+ }
246
+
247
+ // Type dialog state
248
+ const [open, setOpen] = useState<boolean>(false);
249
+ ```
250
+
251
+ ## Tree Shaking
252
+
253
+ The design system is optimized for tree shaking. Only import what you use:
254
+
255
+ ```typescript
256
+ // ✅ Good - Only imports Button
257
+ import { Button } from '@discourser/design-system';
258
+
259
+ // ❌ Avoid - Imports entire package
260
+ import * as DesignSystem from '@discourser/design-system';
261
+ ```
262
+
263
+ ## Package Structure
264
+
265
+ The design system package includes:
266
+
267
+ - **Components** - All React components
268
+ - **Styled System** - Panda CSS utilities (`styled-system/`)
269
+ - `css` - CSS function
270
+ - `jsx` - JSX factory
271
+ - `patterns` - Layout patterns
272
+ - `recipes` - Component recipes
273
+ - `tokens` - Design tokens
274
+ - **Types** - TypeScript definitions
275
+ - **Guidelines** - This documentation folder
276
+
277
+ ## Best Practices
278
+
279
+ ### ✅ DO:
280
+
281
+ ```typescript
282
+ // Import only what you need
283
+ import { Button, Input } from '@discourser/design-system';
284
+
285
+ // Use TypeScript types
286
+ import type { ButtonProps } from '@discourser/design-system';
287
+
288
+ // Import compound components as namespaces
289
+ import * as Dialog from '@discourser/design-system';
290
+
291
+ // Use semantic tokens via css()
292
+ import { css } from '@discourser/design-system/styled-system/css';
293
+ const style = css({ bg: 'primary', color: 'onPrimary' });
294
+ ```
295
+
296
+ ### ❌ DO NOT:
297
+
298
+ ```typescript
299
+ // Don't import the entire package
300
+ import * as DS from '@discourser/design-system';
301
+
302
+ // Don't mix import patterns
303
+ import { Checkbox } from '@discourser/design-system'; // Wrong for compound components
304
+ // Should be: import * as Checkbox from '@discourser/design-system';
305
+
306
+ // Don't bypass the design system
307
+ import { Button as MUIButton } from '@mui/material'; // Use design system Button instead
308
+ ```
309
+
310
+ ## Related Files
311
+
312
+ - **[overview-components.md](overview-components.md)** - Complete list of available components
313
+ - **[overview-patterns.md](overview-patterns.md)** - Common UI patterns and examples
314
+ - **[Guidelines.md](Guidelines.md)** - Main navigation and workflow