@discourser/design-system 0.4.0 → 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 +67 -123
  4. package/guidelines/components/accordion.md +93 -0
  5. package/guidelines/components/avatar.md +70 -0
  6. package/guidelines/components/badge.md +61 -0
  7. package/guidelines/components/button.md +75 -40
  8. package/guidelines/components/card.md +84 -25
  9. package/guidelines/components/checkbox.md +88 -0
  10. package/guidelines/components/dialog.md +619 -31
  11. package/guidelines/components/drawer.md +655 -0
  12. package/guidelines/components/heading.md +71 -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 +71 -0
  18. package/guidelines/components/progress.md +63 -0
  19. package/guidelines/components/radio-group.md +95 -0
  20. package/guidelines/components/select.md +507 -0
  21. package/guidelines/components/skeleton.md +76 -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 +654 -0
  26. package/guidelines/components/textarea.md +70 -0
  27. package/guidelines/components/toast.md +77 -0
  28. package/guidelines/components/tooltip.md +80 -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 +9 -5
  34. package/guidelines/overview-imports.md +314 -0
  35. package/guidelines/overview-patterns.md +3852 -0
  36. package/package.json +4 -2
@@ -2,6 +2,77 @@
2
2
 
3
3
  **Purpose:** Semantic heading component for establishing content hierarchy and structure following Material Design 3 typography patterns.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Heading when you need to **establish semantic document structure and visual hierarchy** with properly ordered heading levels (h1-h6).
8
+
9
+ ### Decision Tree
10
+
11
+ | Scenario | Use Heading? | Alternative | Reasoning |
12
+ | ---------------------------- | ------------ | ----------------------------- | ----------------------------------------------------- |
13
+ | Page titles, section headers | ✅ Yes | - | Headings provide semantic structure for accessibility |
14
+ | Article titles, card headers | ✅ Yes | - | Establishes content hierarchy |
15
+ | Document outline structure | ✅ Yes | - | Screen readers use headings for navigation |
16
+ | Emphasized body text | ❌ No | Text with `fontWeight="bold"` | Don't use headings just for styling |
17
+ | Navigation labels | ❌ No | Text or label elements | Navigation isn't part of content hierarchy |
18
+ | Button labels or UI text | ❌ No | Button or Text | Headings are for content structure |
19
+
20
+ ### Component Comparison
21
+
22
+ ```typescript
23
+ // ✅ Heading - Page and section structure
24
+ <article>
25
+ <Heading as="h1" size="4xl">
26
+ Main Article Title
27
+ </Heading>
28
+
29
+ <Heading as="h2" size="2xl">
30
+ Section One
31
+ </Heading>
32
+ <p>Content...</p>
33
+
34
+ <Heading as="h3" size="xl">
35
+ Subsection
36
+ </Heading>
37
+ <p>More content...</p>
38
+
39
+ <Heading as="h2" size="2xl">
40
+ Section Two
41
+ </Heading>
42
+ <p>Content...</p>
43
+ </article>
44
+
45
+ // ❌ Don't use Heading for emphasized text - Use Text
46
+ <Heading as="h3" size="md">
47
+ Just some bold text
48
+ </Heading>
49
+
50
+ // ✅ Better: Use Text with fontWeight for emphasis
51
+ <Text fontSize="md" fontWeight="bold">
52
+ Just some bold text
53
+ </Text>
54
+
55
+ // ❌ Don't skip heading levels (h1 → h3)
56
+ <Heading as="h1" size="3xl">Title</Heading>
57
+ <Heading as="h3" size="xl">Section</Heading> {/* Should be h2 */}
58
+
59
+ // ✅ Better: Use proper heading hierarchy
60
+ <Heading as="h1" size="3xl">Title</Heading>
61
+ <Heading as="h2" size="xl">Section</Heading>
62
+
63
+ // ❌ Don't use Heading for navigation - Use Text
64
+ <nav>
65
+ <Heading as="h3" size="sm">Menu</Heading>
66
+ <a href="/home">Home</a>
67
+ </nav>
68
+
69
+ // ✅ Better: Use Text for navigation labels
70
+ <nav aria-label="Main navigation">
71
+ <Text fontSize="sm" fontWeight="medium">Menu</Text>
72
+ <a href="/home">Home</a>
73
+ </nav>
74
+ ```
75
+
5
76
  ## Import
6
77
 
7
78
  ```typescript
@@ -2,6 +2,61 @@
2
2
 
3
3
  **Purpose:** Icon-only interactive button for compact actions following Material Design 3 patterns.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use IconButton when you need an **icon-only action** without accompanying text, typically for common, recognizable actions.
8
+
9
+ **Decision Tree:**
10
+
11
+ | Scenario | Use This | Why |
12
+ | ------------------------------------------------ | ---------------------- | ----------------------------------------------------- |
13
+ | Icon-only action (close, menu, settings, delete) | IconButton ✅ | Optimized for icons, proper sizing and spacing |
14
+ | Action with text label | Button | Text provides clarity, better for less common actions |
15
+ | Toggle state (on/off, enabled/disabled) | Switch | Visual metaphor for binary states |
16
+ | Select from options | RadioGroup or Checkbox | Better for multi-choice scenarios |
17
+ | Brief contextual help on icon | IconButton + Tooltip | Combine for accessibility |
18
+
19
+ **Component Comparison:**
20
+
21
+ ```typescript
22
+ // ✅ Use IconButton for icon-only actions
23
+ <IconButton aria-label="Close dialog">
24
+ <CloseIcon />
25
+ </IconButton>
26
+
27
+ <IconButton aria-label="Open menu">
28
+ <MenuIcon />
29
+ </IconButton>
30
+
31
+ // ❌ Don't use Button without text for icon-only actions
32
+ <Button onClick={handleClose}>
33
+ <CloseIcon />
34
+ </Button> // Wrong - Button expects text content
35
+
36
+ <IconButton aria-label="Close">
37
+ <CloseIcon />
38
+ </IconButton> // Correct
39
+
40
+ // ❌ Don't use IconButton when text label is needed
41
+ <IconButton aria-label="Submit form">
42
+ <SendIcon />
43
+ </IconButton> // Wrong - "Submit" action needs visible text
44
+
45
+ <Button leftIcon={<SendIcon />}>
46
+ Submit
47
+ </Button> // Correct
48
+
49
+ // ✅ Use IconButton with Tooltip for clarity
50
+ <Tooltip.Root>
51
+ <Tooltip.Trigger asChild>
52
+ <IconButton aria-label="Add to favorites">
53
+ <HeartIcon />
54
+ </IconButton>
55
+ </Tooltip.Trigger>
56
+ <Tooltip.Content>Add to favorites</Tooltip.Content>
57
+ </Tooltip.Root>
58
+ ```
59
+
5
60
  ## Import
6
61
 
7
62
  ```typescript
@@ -12,12 +67,12 @@ import { IconButton } from '@discourser/design-system';
12
67
 
13
68
  The IconButton component supports 4 Material Design 3 variants:
14
69
 
15
- | Variant | Visual Style | Usage | When to Use |
16
- |---------|-------------|-------|-------------|
17
- | `standard` | Transparent background | Default icon actions | Most common, minimal emphasis |
18
- | `filled` | Primary color background | High emphasis icon actions | Important actions that need prominence |
19
- | `tonal` | Secondary container background | Medium emphasis actions | Supportive actions with some emphasis |
20
- | `outlined` | Outlined border | Secondary icon actions | Alternative to standard with more definition |
70
+ | Variant | Visual Style | Usage | When to Use |
71
+ | ---------- | ------------------------------ | -------------------------- | -------------------------------------------- |
72
+ | `standard` | Transparent background | Default icon actions | Most common, minimal emphasis |
73
+ | `filled` | Primary color background | High emphasis icon actions | Important actions that need prominence |
74
+ | `tonal` | Secondary container background | Medium emphasis actions | Supportive actions with some emphasis |
75
+ | `outlined` | Outlined border | Secondary icon actions | Alternative to standard with more definition |
21
76
 
22
77
  ### Visual Characteristics
23
78
 
@@ -28,26 +83,26 @@ The IconButton component supports 4 Material Design 3 variants:
28
83
 
29
84
  ## Sizes
30
85
 
31
- | Size | Dimensions | Icon Size | Usage |
32
- |------|-----------|-----------|-------|
33
- | `sm` | 32×32px | 18×18px | Compact UI, dense layouts, inline actions |
34
- | `md` | 40×40px | 24×24px | Default, most use cases |
35
- | `lg` | 48×48px | 24×24px | Touch targets, mobile emphasis, FAB |
86
+ | Size | Dimensions | Icon Size | Usage |
87
+ | ---- | ---------- | --------- | ----------------------------------------- |
88
+ | `sm` | 32×32px | 18×18px | Compact UI, dense layouts, inline actions |
89
+ | `md` | 40×40px | 24×24px | Default, most use cases |
90
+ | `lg` | 48×48px | 24×24px | Touch targets, mobile emphasis, FAB |
36
91
 
37
92
  **Important:** Icon sizes are automatically set by the component via CSS. Ensure your SVG icons inherit currentColor and size.
38
93
 
39
94
  ## Props
40
95
 
41
- | Prop | Type | Default | Description |
42
- |------|------|---------|-------------|
43
- | `children` | `ReactNode` | Required | Icon element (SVG, icon component) |
44
- | `aria-label` | `string` | **Required** | Accessible label for screen readers |
45
- | `variant` | `'standard' \| 'filled' \| 'tonal' \| 'outlined'` | `'standard'` | Visual style variant |
46
- | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
47
- | `disabled` | `boolean` | `false` | Disable button interaction |
48
- | `onClick` | `(event: MouseEvent) => void` | - | Click handler |
49
- | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
50
- | `className` | `string` | - | Additional CSS classes (use sparingly) |
96
+ | Prop | Type | Default | Description |
97
+ | ------------ | ------------------------------------------------- | ------------ | -------------------------------------- |
98
+ | `children` | `ReactNode` | Required | Icon element (SVG, icon component) |
99
+ | `aria-label` | `string` | **Required** | Accessible label for screen readers |
100
+ | `variant` | `'standard' \| 'filled' \| 'tonal' \| 'outlined'` | `'standard'` | Visual style variant |
101
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
102
+ | `disabled` | `boolean` | `false` | Disable button interaction |
103
+ | `onClick` | `(event: MouseEvent) => void` | - | Click handler |
104
+ | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
105
+ | `className` | `string` | - | Additional CSS classes (use sparingly) |
51
106
 
52
107
  **Critical:** `aria-label` is **required** for accessibility. Icon buttons have no visible text, so screen readers need this label.
53
108
 
@@ -299,25 +354,25 @@ const WrongIcon = () => (
299
354
 
300
355
  ## Variant Selection Guide
301
356
 
302
- | Scenario | Recommended Variant | Reasoning |
303
- |----------|-------------------|-----------|
304
- | Close button (dialogs) | `standard` | Minimal emphasis, common action |
305
- | Primary action (FAB) | `filled` | High emphasis, main action |
306
- | Edit/Modify action | `tonal` | Medium emphasis, supportive |
307
- | Delete action | `outlined` | Secondary action, needs definition |
308
- | Menu/Navigation | `standard` | Minimal emphasis, frequently used |
309
- | Toggle (active state) | `filled` | Shows active state clearly |
310
- | Toggle (inactive state) | `standard` or `outlined` | Shows inactive state |
311
- | Action bar items | `standard` | Consistent, minimal emphasis |
357
+ | Scenario | Recommended Variant | Reasoning |
358
+ | ----------------------- | ------------------------ | ---------------------------------- |
359
+ | Close button (dialogs) | `standard` | Minimal emphasis, common action |
360
+ | Primary action (FAB) | `filled` | High emphasis, main action |
361
+ | Edit/Modify action | `tonal` | Medium emphasis, supportive |
362
+ | Delete action | `outlined` | Secondary action, needs definition |
363
+ | Menu/Navigation | `standard` | Minimal emphasis, frequently used |
364
+ | Toggle (active state) | `filled` | Shows active state clearly |
365
+ | Toggle (inactive state) | `standard` or `outlined` | Shows inactive state |
366
+ | Action bar items | `standard` | Consistent, minimal emphasis |
312
367
 
313
368
  ## State Behaviors
314
369
 
315
- | State | Visual Change | Behavior |
316
- |-------|---------------|----------|
317
- | **Hover** | Background color change or opacity | `standard`: 8% background<br />`filled`/`tonal`: 92% opacity |
318
- | **Active** | Slight opacity change | Further visual feedback on click |
319
- | **Focus** | 2px outline | Primary color outline, 2px offset |
320
- | **Disabled** | 38% opacity, no interaction | Cannot be clicked, greyed out |
370
+ | State | Visual Change | Behavior |
371
+ | ------------ | ---------------------------------- | ------------------------------------------------------------ |
372
+ | **Hover** | Background color change or opacity | `standard`: 8% background<br />`filled`/`tonal`: 92% opacity |
373
+ | **Active** | Slight opacity change | Further visual feedback on click |
374
+ | **Focus** | 2px outline | Primary color outline, 2px offset |
375
+ | **Disabled** | 38% opacity, no interaction | Cannot be clicked, greyed out |
321
376
 
322
377
  ## Responsive Considerations
323
378