@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,41 @@
|
|
|
2
2
|
|
|
3
3
|
**Purpose:** Primary interactive element for user actions following Material Design 3 patterns.
|
|
4
4
|
|
|
5
|
+
## When to Use This Component
|
|
6
|
+
|
|
7
|
+
Use Button when you need a clickable element that **triggers an action** (submit, save, cancel, etc.).
|
|
8
|
+
|
|
9
|
+
**Decision Tree:**
|
|
10
|
+
|
|
11
|
+
| Scenario | Use This | Why |
|
|
12
|
+
| ---------------------------------------- | ----------------------------- | ------------------------------------------------- |
|
|
13
|
+
| Trigger an action (submit, save, delete) | Button ✅ | Semantic action element |
|
|
14
|
+
| Navigate to a different page/route | `<a>` tag or Next.js `<Link>` | Navigation should use links for SEO/accessibility |
|
|
15
|
+
| Icon-only action (close, menu, settings) | IconButton | Better for icon-only affordances |
|
|
16
|
+
| Toggle state (on/off, enable/disable) | Switch | Visual metaphor for state changes |
|
|
17
|
+
| Select from options (exclusive choice) | RadioGroup | For mutually exclusive selections |
|
|
18
|
+
| Select multiple options | Checkbox | For multiple selections |
|
|
19
|
+
|
|
20
|
+
**Component Comparison:**
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
// ✅ Use Button for actions
|
|
24
|
+
<Button onClick={handleSave}>Save</Button>
|
|
25
|
+
<Button onClick={handleDelete}>Delete</Button>
|
|
26
|
+
|
|
27
|
+
// ❌ Don't use Button for navigation - use Link
|
|
28
|
+
<Button onClick={() => router.push('/page')}>Go to Page</Button> // Wrong
|
|
29
|
+
<Link href="/page">Go to Page</Link> // Correct
|
|
30
|
+
|
|
31
|
+
// ❌ Don't use Button for icon-only - use IconButton
|
|
32
|
+
<Button><CloseIcon /></Button> // Wrong
|
|
33
|
+
<IconButton aria-label="Close"><CloseIcon /></IconButton> // Correct
|
|
34
|
+
|
|
35
|
+
// ❌ Don't use Button for toggles - use Switch
|
|
36
|
+
<Button onClick={toggleDarkMode}>Dark Mode</Button> // Wrong
|
|
37
|
+
<Switch checked={isDarkMode} onCheckedChange={setDarkMode}>Dark Mode</Switch> // Correct
|
|
38
|
+
```
|
|
39
|
+
|
|
5
40
|
## Import
|
|
6
41
|
|
|
7
42
|
```typescript
|
|
@@ -12,13 +47,13 @@ import { Button } from '@discourser/design-system';
|
|
|
12
47
|
|
|
13
48
|
The Button component supports 5 Material Design 3 variants, each with specific use cases:
|
|
14
49
|
|
|
15
|
-
| Variant
|
|
16
|
-
|
|
17
|
-
| `filled`
|
|
18
|
-
| `outlined` | Transparent background with border
|
|
19
|
-
| `text`
|
|
20
|
-
| `elevated` | Elevated surface with subtle shadow
|
|
21
|
-
| `tonal`
|
|
50
|
+
| Variant | Visual Style | Usage | When to Use |
|
|
51
|
+
| ---------- | ------------------------------------- | ----------------- | ------------------------------------------------------------------ |
|
|
52
|
+
| `filled` | Solid background with primary color | Primary actions | Submit forms, confirm dialogs, main CTAs |
|
|
53
|
+
| `outlined` | Transparent background with border | Secondary actions | Cancel buttons, back navigation, alternative options |
|
|
54
|
+
| `text` | Transparent background, no border | Tertiary actions | Links, less prominent actions, dialog actions |
|
|
55
|
+
| `elevated` | Elevated surface with subtle shadow | Floating actions | FAB-like buttons, actions that need emphasis but not primary color |
|
|
56
|
+
| `tonal` | Filled with secondary container color | Medium emphasis | Secondary CTAs, soft highlights, supportive actions |
|
|
22
57
|
|
|
23
58
|
### Visual Characteristics
|
|
24
59
|
|
|
@@ -30,27 +65,27 @@ The Button component supports 5 Material Design 3 variants, each with specific u
|
|
|
30
65
|
|
|
31
66
|
## Sizes
|
|
32
67
|
|
|
33
|
-
| Size | Height | Padding (Horizontal) | Font Size
|
|
34
|
-
|
|
35
|
-
| `sm` | 32px
|
|
36
|
-
| `md` | 40px
|
|
37
|
-
| `lg` | 48px
|
|
68
|
+
| Size | Height | Padding (Horizontal) | Font Size | Usage |
|
|
69
|
+
| ---- | ------ | -------------------- | ----------- | --------------------------------------------- |
|
|
70
|
+
| `sm` | 32px | 16px (md) | labelMedium | Compact UI, dense layouts, small dialogs |
|
|
71
|
+
| `md` | 40px | 24px (lg) | labelLarge | Default, most use cases |
|
|
72
|
+
| `lg` | 48px | 32px (xl) | labelLarge | Touch targets, mobile emphasis, hero sections |
|
|
38
73
|
|
|
39
74
|
**Recommendation:** Use `md` for most cases. Use `lg` for mobile-first designs or prominent CTAs.
|
|
40
75
|
|
|
41
76
|
## Props
|
|
42
77
|
|
|
43
|
-
| Prop
|
|
44
|
-
|
|
45
|
-
| `variant`
|
|
46
|
-
| `size`
|
|
47
|
-
| `leftIcon`
|
|
48
|
-
| `rightIcon` | `ReactNode`
|
|
49
|
-
| `disabled`
|
|
50
|
-
| `onClick`
|
|
51
|
-
| `type`
|
|
52
|
-
| `className` | `string`
|
|
53
|
-
| `children`
|
|
78
|
+
| Prop | Type | Default | Description |
|
|
79
|
+
| ----------- | ----------------------------------------------------------- | ---------- | -------------------------------------- |
|
|
80
|
+
| `variant` | `'filled' \| 'outlined' \| 'text' \| 'elevated' \| 'tonal'` | `'filled'` | Visual style variant |
|
|
81
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
|
|
82
|
+
| `leftIcon` | `ReactNode` | - | Icon or element before button text |
|
|
83
|
+
| `rightIcon` | `ReactNode` | - | Icon or element after button text |
|
|
84
|
+
| `disabled` | `boolean` | `false` | Disable button interaction |
|
|
85
|
+
| `onClick` | `(event: MouseEvent) => void` | - | Click handler |
|
|
86
|
+
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
|
|
87
|
+
| `className` | `string` | - | Additional CSS classes (use sparingly) |
|
|
88
|
+
| `children` | `ReactNode` | Required | Button text content |
|
|
54
89
|
|
|
55
90
|
**Note:** Button extends `ButtonHTMLAttributes<HTMLButtonElement>`, so all standard HTML button attributes are supported.
|
|
56
91
|
|
|
@@ -242,26 +277,26 @@ The Button component follows WCAG 2.1 Level AA standards:
|
|
|
242
277
|
|
|
243
278
|
## Variant Selection Guide
|
|
244
279
|
|
|
245
|
-
| Scenario
|
|
246
|
-
|
|
247
|
-
| Form submission
|
|
248
|
-
| Cancel/Back
|
|
249
|
-
| Dialog confirmation
|
|
250
|
-
| Dialog dismiss
|
|
251
|
-
| Save draft
|
|
252
|
-
| Delete/Destructive
|
|
253
|
-
| Filter/Sort
|
|
254
|
-
| Floating action button | `elevated`
|
|
255
|
-
| Link-like actions
|
|
280
|
+
| Scenario | Recommended Variant | Reasoning |
|
|
281
|
+
| ---------------------- | -------------------- | ----------------------------------------- |
|
|
282
|
+
| Form submission | `filled` | Primary action, needs highest emphasis |
|
|
283
|
+
| Cancel/Back | `outlined` or `text` | Secondary action, lower emphasis |
|
|
284
|
+
| Dialog confirmation | `filled` | Primary action in dialog |
|
|
285
|
+
| Dialog dismiss | `text` | Tertiary action, minimal emphasis |
|
|
286
|
+
| Save draft | `tonal` | Medium emphasis, not primary action |
|
|
287
|
+
| Delete/Destructive | `filled` or `tonal` | High attention, but consider error colors |
|
|
288
|
+
| Filter/Sort | `text` or `outlined` | Lower emphasis, frequent use |
|
|
289
|
+
| Floating action button | `elevated` | Needs to float above content |
|
|
290
|
+
| Link-like actions | `text` | Minimal emphasis, inline with text |
|
|
256
291
|
|
|
257
292
|
## State Behaviors
|
|
258
293
|
|
|
259
|
-
| State
|
|
260
|
-
|
|
261
|
-
| **Hover**
|
|
262
|
-
| **Active**
|
|
263
|
-
| **Focus**
|
|
264
|
-
| **Disabled** | 38% opacity, no interaction
|
|
294
|
+
| State | Visual Change | Behavior |
|
|
295
|
+
| ------------ | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
296
|
+
| **Hover** | Opacity change or shadow | `filled`: 92% opacity + level1 shadow<br />`outlined`: 8% primary background<br />`elevated`: Increase shadow to level2 |
|
|
297
|
+
| **Active** | Further opacity/shadow change | `filled`: 88% opacity<br />`outlined`: 12% primary background |
|
|
298
|
+
| **Focus** | 2px outline | Primary color outline, 2px offset |
|
|
299
|
+
| **Disabled** | 38% opacity, no interaction | Cannot be clicked, greyed out appearance |
|
|
265
300
|
|
|
266
301
|
## Responsive Considerations
|
|
267
302
|
|
|
@@ -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
|
|
16
|
-
|
|
17
|
-
| `elevated` | Surface with shadow, elevated appearance | Default cards, content containers | Most common use case, provides visual hierarchy
|
|
18
|
-
| `filled`
|
|
19
|
-
| `outlined` | Outlined border, no shadow
|
|
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
|
|
30
|
-
|
|
31
|
-
| `variant`
|
|
32
|
-
| `interactive` | `boolean`
|
|
33
|
-
| `onClick`
|
|
34
|
-
| `className`
|
|
35
|
-
| `children`
|
|
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
|
|
251
|
-
|
|
252
|
-
| Product cards
|
|
253
|
-
| Form sections
|
|
254
|
-
| Dashboard widgets | `elevated`
|
|
255
|
-
| List items
|
|
256
|
-
| Content previews
|
|
257
|
-
| Settings sections | `outlined`
|
|
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
|
|
262
|
-
|
|
263
|
-
| **Hover**
|
|
264
|
-
| **Active**
|
|
265
|
-
| **Default** | No hover effects
|
|
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
|
|