@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.
- package/README.md +12 -4
- package/dist/styles.css +5126 -0
- package/guidelines/Guidelines.md +92 -41
- package/guidelines/components/accordion.md +732 -0
- package/guidelines/components/avatar.md +1015 -0
- package/guidelines/components/badge.md +728 -0
- package/guidelines/components/button.md +75 -40
- package/guidelines/components/card.md +84 -25
- package/guidelines/components/checkbox.md +671 -0
- package/guidelines/components/dialog.md +619 -31
- package/guidelines/components/drawer.md +1616 -0
- package/guidelines/components/heading.md +576 -0
- package/guidelines/components/icon-button.md +92 -37
- package/guidelines/components/input-addon.md +685 -0
- package/guidelines/components/input-group.md +830 -0
- package/guidelines/components/input.md +92 -37
- package/guidelines/components/popover.md +1271 -0
- package/guidelines/components/progress.md +836 -0
- package/guidelines/components/radio-group.md +852 -0
- package/guidelines/components/select.md +1662 -0
- package/guidelines/components/skeleton.md +802 -0
- package/guidelines/components/slider.md +911 -0
- package/guidelines/components/spinner.md +783 -0
- package/guidelines/components/switch.md +105 -38
- package/guidelines/components/tabs.md +1488 -0
- package/guidelines/components/textarea.md +495 -0
- package/guidelines/components/toast.md +784 -0
- package/guidelines/components/tooltip.md +912 -0
- package/guidelines/design-tokens/colors.md +309 -72
- package/guidelines/design-tokens/elevation.md +615 -45
- package/guidelines/design-tokens/spacing.md +654 -74
- package/guidelines/design-tokens/typography.md +432 -50
- package/guidelines/overview-components.md +60 -8
- package/guidelines/overview-imports.md +314 -0
- package/guidelines/overview-patterns.md +3852 -0
- package/package.json +4 -2
|
@@ -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
|
|
16
|
-
|
|
17
|
-
| `standard` | Transparent background
|
|
18
|
-
| `filled`
|
|
19
|
-
| `tonal`
|
|
20
|
-
| `outlined` | Outlined border
|
|
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
|
|
34
|
-
| `md` | 40×40px
|
|
35
|
-
| `lg` | 48×48px
|
|
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
|
|
42
|
-
|
|
43
|
-
| `children`
|
|
44
|
-
| `aria-label` | `string`
|
|
45
|
-
| `variant`
|
|
46
|
-
| `size`
|
|
47
|
-
| `disabled`
|
|
48
|
-
| `onClick`
|
|
49
|
-
| `type`
|
|
50
|
-
| `className`
|
|
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
|
|
303
|
-
|
|
304
|
-
| Close button (dialogs)
|
|
305
|
-
| Primary action (FAB)
|
|
306
|
-
| Edit/Modify action
|
|
307
|
-
| Delete action
|
|
308
|
-
| Menu/Navigation
|
|
309
|
-
| Toggle (active state)
|
|
310
|
-
| Toggle (inactive state) | `standard` or `outlined` | Shows inactive state
|
|
311
|
-
| Action bar items
|
|
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
|
|
316
|
-
|
|
317
|
-
| **Hover**
|
|
318
|
-
| **Active**
|
|
319
|
-
| **Focus**
|
|
320
|
-
| **Disabled** | 38% opacity, no interaction
|
|
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
|
|