@discourser/design-system 0.4.0 → 0.6.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 (42) hide show
  1. package/README.md +12 -4
  2. package/dist/index.cjs +240 -260
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +67 -90
  5. package/dist/index.d.ts +67 -90
  6. package/dist/index.js +238 -258
  7. package/dist/index.js.map +1 -1
  8. package/dist/styles.css +5126 -0
  9. package/guidelines/Guidelines.md +67 -123
  10. package/guidelines/components/accordion.md +93 -0
  11. package/guidelines/components/avatar.md +70 -0
  12. package/guidelines/components/badge.md +61 -0
  13. package/guidelines/components/button.md +75 -40
  14. package/guidelines/components/card.md +84 -25
  15. package/guidelines/components/checkbox.md +88 -0
  16. package/guidelines/components/dialog.md +619 -31
  17. package/guidelines/components/drawer.md +655 -0
  18. package/guidelines/components/heading.md +71 -0
  19. package/guidelines/components/icon-button.md +92 -37
  20. package/guidelines/components/input-addon.md +685 -0
  21. package/guidelines/components/input-group.md +830 -0
  22. package/guidelines/components/input.md +92 -37
  23. package/guidelines/components/popover.md +71 -0
  24. package/guidelines/components/progress.md +63 -0
  25. package/guidelines/components/radio-group.md +95 -0
  26. package/guidelines/components/select.md +507 -0
  27. package/guidelines/components/skeleton.md +76 -0
  28. package/guidelines/components/slider.md +911 -0
  29. package/guidelines/components/spinner.md +783 -0
  30. package/guidelines/components/switch.md +105 -38
  31. package/guidelines/components/tabs.md +654 -0
  32. package/guidelines/components/textarea.md +70 -0
  33. package/guidelines/components/toast.md +77 -0
  34. package/guidelines/components/tooltip.md +80 -0
  35. package/guidelines/design-tokens/colors.md +309 -72
  36. package/guidelines/design-tokens/elevation.md +615 -45
  37. package/guidelines/design-tokens/spacing.md +654 -74
  38. package/guidelines/design-tokens/typography.md +432 -50
  39. package/guidelines/overview-components.md +9 -5
  40. package/guidelines/overview-imports.md +314 -0
  41. package/guidelines/overview-patterns.md +3852 -0
  42. package/package.json +14 -2
@@ -2,6 +2,65 @@
2
2
 
3
3
  **Purpose:** Container component for grouping related content with Material Design 3 elevation and styling.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Card when you need to **group related content** in a visually distinct container that feels like a physical surface.
8
+
9
+ **Decision Tree:**
10
+
11
+ | Scenario | Use This | Why |
12
+ | --------------------------------------------------------------- | -------------------- | --------------------------------------------------------- |
13
+ | Group related content (dashboard widget, product card, profile) | Card ✅ | Provides visual hierarchy and content separation |
14
+ | Modal overlay requiring user interaction | Dialog | Blocks interaction with page, requires explicit dismissal |
15
+ | Side panel navigation or supplementary content | Drawer | Slides from edge, preserves page context |
16
+ | Floating contextual content near trigger element | Popover | Positioned relative to trigger, temporary |
17
+ | Brief contextual help (under 2 sentences) | Tooltip | Lightweight, appears on hover |
18
+ | Collapsible sections within a page | Accordion | Manages vertical space, shows/hides content |
19
+ | Simple content wrapper without elevation | `<div>` with padding | When you don't need Material Design styling |
20
+
21
+ **Component Comparison:**
22
+
23
+ ```typescript
24
+ // ✅ Use Card for grouped content
25
+ <Card>
26
+ <h3>User Profile</h3>
27
+ <p>Name: John Doe</p>
28
+ <p>Email: john@example.com</p>
29
+ </Card>
30
+
31
+ // ❌ Don't use Card for modal overlays - use Dialog
32
+ <Card>
33
+ <h2>Confirm Delete</h2>
34
+ <Button>Delete</Button>
35
+ </Card> // Wrong - doesn't block background interaction
36
+
37
+ <Dialog.Root>
38
+ <Dialog.Content>
39
+ <Dialog.Title>Confirm Delete</Dialog.Title>
40
+ <Button>Delete</Button>
41
+ </Dialog.Content>
42
+ </Dialog.Root> // Correct
43
+
44
+ // ❌ Don't use Card for side panels - use Drawer
45
+ <Card className={css({ position: 'fixed', right: 0 })}>
46
+ Navigation links
47
+ </Card> // Wrong - Card isn't designed for this
48
+
49
+ <Drawer.Root>
50
+ <Drawer.Content>Navigation links</Drawer.Content>
51
+ </Drawer.Root> // Correct
52
+
53
+ // ❌ Don't use Card for tooltip-like hints - use Tooltip
54
+ <Card className={css({ position: 'absolute', fontSize: 'xs' })}>
55
+ Helpful hint
56
+ </Card> // Wrong - too heavy for brief help
57
+
58
+ <Tooltip.Root>
59
+ <Tooltip.Trigger>Hover me</Tooltip.Trigger>
60
+ <Tooltip.Content>Helpful hint</Tooltip.Content>
61
+ </Tooltip.Root> // Correct
62
+ ```
63
+
5
64
  ## Import
6
65
 
7
66
  ```typescript
@@ -12,11 +71,11 @@ import { Card } from '@discourser/design-system';
12
71
 
13
72
  The Card component supports 3 Material Design 3 variants:
14
73
 
15
- | Variant | Visual Style | Usage | When to Use |
16
- |---------|-------------|-------|-------------|
17
- | `elevated` | Surface with shadow, elevated appearance | Default cards, content containers | Most common use case, provides visual hierarchy |
18
- | `filled` | Filled background, no shadow | Secondary cards, less emphasis | When multiple cards are stacked, alternative style |
19
- | `outlined` | Outlined border, no shadow | Tertiary cards, minimal style | When you want subtle separation without elevation |
74
+ | Variant | Visual Style | Usage | When to Use |
75
+ | ---------- | ---------------------------------------- | --------------------------------- | -------------------------------------------------- |
76
+ | `elevated` | Surface with shadow, elevated appearance | Default cards, content containers | Most common use case, provides visual hierarchy |
77
+ | `filled` | Filled background, no shadow | Secondary cards, less emphasis | When multiple cards are stacked, alternative style |
78
+ | `outlined` | Outlined border, no shadow | Tertiary cards, minimal style | When you want subtle separation without elevation |
20
79
 
21
80
  ### Visual Characteristics
22
81
 
@@ -26,13 +85,13 @@ The Card component supports 3 Material Design 3 variants:
26
85
 
27
86
  ## Props
28
87
 
29
- | Prop | Type | Default | Description |
30
- |------|------|---------|-------------|
31
- | `variant` | `'elevated' \| 'filled' \| 'outlined'` | `'elevated'` | Visual style variant |
32
- | `interactive` | `boolean` | `false` | Makes card clickable with hover/active states |
33
- | `onClick` | `(event: MouseEvent) => void` | - | Click handler (sets interactive=true automatically) |
34
- | `className` | `string` | - | Additional CSS classes (use sparingly) |
35
- | `children` | `ReactNode` | Required | Card content |
88
+ | Prop | Type | Default | Description |
89
+ | ------------- | -------------------------------------- | ------------ | --------------------------------------------------- |
90
+ | `variant` | `'elevated' \| 'filled' \| 'outlined'` | `'elevated'` | Visual style variant |
91
+ | `interactive` | `boolean` | `false` | Makes card clickable with hover/active states |
92
+ | `onClick` | `(event: MouseEvent) => void` | - | Click handler (sets interactive=true automatically) |
93
+ | `className` | `string` | - | Additional CSS classes (use sparingly) |
94
+ | `children` | `ReactNode` | Required | Card content |
36
95
 
37
96
  **Note:** Card extends `HTMLAttributes<HTMLDivElement>`, so all standard HTML div attributes are supported.
38
97
 
@@ -247,22 +306,22 @@ The Card component follows accessibility best practices:
247
306
 
248
307
  ## Variant Selection Guide
249
308
 
250
- | Scenario | Recommended Variant | Reasoning |
251
- |----------|-------------------|-----------|
252
- | Product cards | `elevated` | Visual hierarchy, draws attention |
253
- | Form sections | `outlined` | Subtle separation without heavy elevation |
254
- | Dashboard widgets | `elevated` | Emphasizes different data sections |
255
- | List items | `outlined` or `filled` | Lighter style for repeated elements |
256
- | Content previews | `elevated` | Interactive, prominent |
257
- | Settings sections | `outlined` | Clean, minimal separation |
309
+ | Scenario | Recommended Variant | Reasoning |
310
+ | ----------------- | ---------------------- | ----------------------------------------- |
311
+ | Product cards | `elevated` | Visual hierarchy, draws attention |
312
+ | Form sections | `outlined` | Subtle separation without heavy elevation |
313
+ | Dashboard widgets | `elevated` | Emphasizes different data sections |
314
+ | List items | `outlined` or `filled` | Lighter style for repeated elements |
315
+ | Content previews | `elevated` | Interactive, prominent |
316
+ | Settings sections | `outlined` | Clean, minimal separation |
258
317
 
259
318
  ## State Behaviors
260
319
 
261
- | State | Visual Change | Applies When |
262
- |-------|---------------|--------------|
263
- | **Hover** | `elevated`: shadow increases to level2<br />`filled`/`outlined`: slight opacity change | Only when `interactive={true}` |
264
- | **Active** | Opacity reduces to 0.92 | Only when `interactive={true}` |
265
- | **Default** | No hover effects | When `interactive={false}` (default) |
320
+ | State | Visual Change | Applies When |
321
+ | ----------- | -------------------------------------------------------------------------------------- | ------------------------------------ |
322
+ | **Hover** | `elevated`: shadow increases to level2<br />`filled`/`outlined`: slight opacity change | Only when `interactive={true}` |
323
+ | **Active** | Opacity reduces to 0.92 | Only when `interactive={true}` |
324
+ | **Default** | No hover effects | When `interactive={false}` (default) |
266
325
 
267
326
  ## Responsive Considerations
268
327
 
@@ -2,6 +2,94 @@
2
2
 
3
3
  **Purpose:** Binary selection control for toggling options on/off, supporting single checkboxes and checkbox groups.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Checkbox when you need **binary selections** that are part of a form or when users can select multiple independent options.
8
+
9
+ **Decision Tree:**
10
+
11
+ | Scenario | Use This | Why |
12
+ | --------------------------------------------------------------- | ----------- | ----------------------------------------- |
13
+ | Form consent (accept terms, subscribe to newsletter) | Checkbox ✅ | Standard for form agreements |
14
+ | Multiple selections from a list (select interests, features) | Checkbox ✅ | Users can pick multiple items |
15
+ | Single binary choice in a form | Checkbox ✅ | Form submission context |
16
+ | Toggle setting with immediate effect (dark mode, notifications) | Switch | Visual metaphor for instant state changes |
17
+ | Mutually exclusive choices (select one from many) | RadioGroup | Only one option can be selected |
18
+ | Action trigger (save, delete) | Button | Explicit action with confirmation |
19
+
20
+ **Component Comparison:**
21
+
22
+ ```typescript
23
+ // ✅ Use Checkbox for form consent
24
+ <form onSubmit={handleSubmit}>
25
+ <Checkbox.Root name="terms">
26
+ <Checkbox.Control>
27
+ <Checkbox.Indicator />
28
+ </Checkbox.Control>
29
+ <Checkbox.Label>I accept the terms and conditions</Checkbox.Label>
30
+ </Checkbox.Root>
31
+ <Button type="submit">Sign Up</Button>
32
+ </form>
33
+
34
+ // ✅ Use Checkbox for multiple selections
35
+ <Checkbox.Group value={selectedInterests} onValueChange={setSelectedInterests}>
36
+ <Checkbox.Root value="sports">
37
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
38
+ <Checkbox.Label>Sports</Checkbox.Label>
39
+ </Checkbox.Root>
40
+ <Checkbox.Root value="music">
41
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
42
+ <Checkbox.Label>Music</Checkbox.Label>
43
+ </Checkbox.Root>
44
+ <Checkbox.Root value="travel">
45
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
46
+ <Checkbox.Label>Travel</Checkbox.Label>
47
+ </Checkbox.Root>
48
+ </Checkbox.Group>
49
+
50
+ // ❌ Don't use Checkbox for instant toggles - use Switch
51
+ <Checkbox.Root checked={isDarkMode} onCheckedChange={setDarkMode}>
52
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
53
+ <Checkbox.Label>Dark mode</Checkbox.Label>
54
+ </Checkbox.Root> // Wrong - settings that apply immediately should use Switch
55
+
56
+ <Switch.Root checked={isDarkMode} onCheckedChange={setDarkMode}>
57
+ <Switch.Label>Dark mode</Switch.Label>
58
+ <Switch.Control><Switch.Thumb /></Switch.Control>
59
+ </Switch.Root> // Correct
60
+
61
+ // ❌ Don't use Checkbox for exclusive choices - use RadioGroup
62
+ <Checkbox.Group>
63
+ <Checkbox.Root value="small">
64
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
65
+ <Checkbox.Label>Small</Checkbox.Label>
66
+ </Checkbox.Root>
67
+ <Checkbox.Root value="medium">
68
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
69
+ <Checkbox.Label>Medium</Checkbox.Label>
70
+ </Checkbox.Root>
71
+ <Checkbox.Root value="large">
72
+ <Checkbox.Control><Checkbox.Indicator /></Checkbox.Control>
73
+ <Checkbox.Label>Large</Checkbox.Label>
74
+ </Checkbox.Root>
75
+ </Checkbox.Group> // Wrong - users shouldn't select multiple sizes
76
+
77
+ <RadioGroup.Root>
78
+ <RadioGroup.Item value="small">
79
+ <RadioGroup.ItemControl />
80
+ <RadioGroup.ItemText>Small</RadioGroup.ItemText>
81
+ </RadioGroup.Item>
82
+ <RadioGroup.Item value="medium">
83
+ <RadioGroup.ItemControl />
84
+ <RadioGroup.ItemText>Medium</RadioGroup.ItemText>
85
+ </RadioGroup.Item>
86
+ <RadioGroup.Item value="large">
87
+ <RadioGroup.ItemControl />
88
+ <RadioGroup.ItemText>Large</RadioGroup.ItemText>
89
+ </RadioGroup.Item>
90
+ </RadioGroup.Root> // Correct
91
+ ```
92
+
5
93
  ## Import
6
94
 
7
95
  ```typescript