@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:** Text input field with built-in label, validation, and helper text following Material Design 3 patterns.
|
|
4
4
|
|
|
5
|
+
## When to Use This Component
|
|
6
|
+
|
|
7
|
+
Use Input when you need **single-line text entry** from the user (names, emails, search terms, etc.).
|
|
8
|
+
|
|
9
|
+
**Decision Tree:**
|
|
10
|
+
|
|
11
|
+
| Scenario | Use This | Why |
|
|
12
|
+
| -------------------------------------------------- | ------------------------------------ | ------------------------------------------ |
|
|
13
|
+
| Single-line text (name, email, username, search) | Input ✅ | Optimized for single-line entry |
|
|
14
|
+
| Multi-line text (comments, descriptions, messages) | Textarea | Allows line breaks, expandable height |
|
|
15
|
+
| Select from predefined options (4+ choices) | Select | More efficient than typing, prevents typos |
|
|
16
|
+
| Select from 2-3 options | RadioGroup | Visual comparison of all options |
|
|
17
|
+
| Binary choice (yes/no, on/off) | Switch or Checkbox | Visual metaphor for state |
|
|
18
|
+
| Date selection | Input with type="date" or DatePicker | Structured date entry |
|
|
19
|
+
| Number entry | Input with type="number" | Numeric keyboard on mobile |
|
|
20
|
+
|
|
21
|
+
**Component Comparison:**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// ✅ Use Input for single-line text
|
|
25
|
+
<Input label="Email address" type="email" />
|
|
26
|
+
<Input label="Username" />
|
|
27
|
+
<Input label="Search products" type="search" />
|
|
28
|
+
|
|
29
|
+
// ❌ Don't use Input for multi-line text - use Textarea
|
|
30
|
+
<Input label="Comments" /> // Wrong - can't enter line breaks
|
|
31
|
+
|
|
32
|
+
<Textarea label="Comments" /> // Correct
|
|
33
|
+
|
|
34
|
+
// ❌ Don't use Input when Select would be clearer
|
|
35
|
+
<Input label="Country" placeholder="Enter country name" /> // Wrong - prone to typos
|
|
36
|
+
|
|
37
|
+
<Select.Root collection={countries}>
|
|
38
|
+
<Select.Label>Country</Select.Label>
|
|
39
|
+
<Select.Control>
|
|
40
|
+
<Select.Trigger>
|
|
41
|
+
<Select.ValueText placeholder="Select country" />
|
|
42
|
+
</Select.Trigger>
|
|
43
|
+
</Select.Control>
|
|
44
|
+
<Select.Content>
|
|
45
|
+
{/* country options */}
|
|
46
|
+
</Select.Content>
|
|
47
|
+
</Select.Root> // Correct
|
|
48
|
+
|
|
49
|
+
// ❌ Don't use Input for binary choices - use Switch
|
|
50
|
+
<Input label="Enable notifications" type="checkbox" /> // Wrong - not an Input use case
|
|
51
|
+
|
|
52
|
+
<Switch.Root>
|
|
53
|
+
<Switch.Label>Enable notifications</Switch.Label>
|
|
54
|
+
<Switch.Control>
|
|
55
|
+
<Switch.Thumb />
|
|
56
|
+
</Switch.Control>
|
|
57
|
+
</Switch.Root> // Correct
|
|
58
|
+
```
|
|
59
|
+
|
|
5
60
|
## Import
|
|
6
61
|
|
|
7
62
|
```typescript
|
|
@@ -12,10 +67,10 @@ import { Input } from '@discourser/design-system';
|
|
|
12
67
|
|
|
13
68
|
The Input component supports 2 Material Design 3 variants:
|
|
14
69
|
|
|
15
|
-
| Variant
|
|
16
|
-
|
|
17
|
-
| `outlined` | Outlined border around input
|
|
18
|
-
| `filled`
|
|
70
|
+
| Variant | Visual Style | Usage | When to Use |
|
|
71
|
+
| ---------- | ------------------------------------ | ------------------- | -------------------------------- |
|
|
72
|
+
| `outlined` | Outlined border around input | Default text inputs | Most common, clear boundaries |
|
|
73
|
+
| `filled` | Filled background with bottom border | Alternative style | When you want less visual weight |
|
|
19
74
|
|
|
20
75
|
### Visual Characteristics
|
|
21
76
|
|
|
@@ -24,28 +79,28 @@ The Input component supports 2 Material Design 3 variants:
|
|
|
24
79
|
|
|
25
80
|
## Sizes
|
|
26
81
|
|
|
27
|
-
| Size | Height | Font Size | Usage
|
|
28
|
-
|
|
29
|
-
| `sm` | 40px
|
|
30
|
-
| `md` | 56px
|
|
82
|
+
| Size | Height | Font Size | Usage |
|
|
83
|
+
| ---- | ------ | --------- | ---------------------------- |
|
|
84
|
+
| `sm` | 40px | bodySmall | Compact forms, dense layouts |
|
|
85
|
+
| `md` | 56px | bodyLarge | Default, most use cases |
|
|
31
86
|
|
|
32
87
|
## Props
|
|
33
88
|
|
|
34
|
-
| Prop
|
|
35
|
-
|
|
36
|
-
| `label`
|
|
37
|
-
| `helperText`
|
|
38
|
-
| `errorText`
|
|
39
|
-
| `variant`
|
|
40
|
-
| `size`
|
|
41
|
-
| `state`
|
|
42
|
-
| `disabled`
|
|
43
|
-
| `value`
|
|
44
|
-
| `defaultValue` | `string`
|
|
45
|
-
| `onChange`
|
|
46
|
-
| `placeholder`
|
|
47
|
-
| `type`
|
|
48
|
-
| `required`
|
|
89
|
+
| Prop | Type | Default | Description |
|
|
90
|
+
| -------------- | ------------------------------ | ------------ | ------------------------------------------------- |
|
|
91
|
+
| `label` | `string` | - | Label text (highly recommended for accessibility) |
|
|
92
|
+
| `helperText` | `string` | - | Helper text displayed below input |
|
|
93
|
+
| `errorText` | `string` | - | Error message (also sets error state) |
|
|
94
|
+
| `variant` | `'outlined' \| 'filled'` | `'outlined'` | Visual style variant |
|
|
95
|
+
| `size` | `'sm' \| 'md'` | `'md'` | Input size |
|
|
96
|
+
| `state` | `'error'` | - | Visual state (auto-set if errorText provided) |
|
|
97
|
+
| `disabled` | `boolean` | `false` | Disable input |
|
|
98
|
+
| `value` | `string` | - | Controlled value |
|
|
99
|
+
| `defaultValue` | `string` | - | Uncontrolled default value |
|
|
100
|
+
| `onChange` | `(event: ChangeEvent) => void` | - | Change handler |
|
|
101
|
+
| `placeholder` | `string` | - | Placeholder text |
|
|
102
|
+
| `type` | `string` | `'text'` | HTML input type (text, email, password, etc.) |
|
|
103
|
+
| `required` | `boolean` | `false` | Mark as required field |
|
|
49
104
|
|
|
50
105
|
**Note:** Input extends `InputHTMLAttributes<HTMLInputElement>` (excluding 'size'), so all standard HTML input attributes are supported.
|
|
51
106
|
|
|
@@ -414,23 +469,23 @@ const formik = useFormik({
|
|
|
414
469
|
|
|
415
470
|
## Variant Selection Guide
|
|
416
471
|
|
|
417
|
-
| Scenario
|
|
418
|
-
|
|
419
|
-
| Standard forms | `outlined`
|
|
420
|
-
| Dense forms
|
|
421
|
-
| Minimal UI
|
|
422
|
-
| Search bars
|
|
423
|
-
| Settings forms | `outlined`
|
|
472
|
+
| Scenario | Recommended Variant | Reasoning |
|
|
473
|
+
| -------------- | ------------------------ | --------------------------------- |
|
|
474
|
+
| Standard forms | `outlined` | Clear boundaries, default choice |
|
|
475
|
+
| Dense forms | `outlined` + `size="sm"` | Compact while maintaining clarity |
|
|
476
|
+
| Minimal UI | `filled` | Lighter visual weight |
|
|
477
|
+
| Search bars | `outlined` or `filled` | Either works, depends on design |
|
|
478
|
+
| Settings forms | `outlined` | Clear separation of fields |
|
|
424
479
|
|
|
425
480
|
## State Behaviors
|
|
426
481
|
|
|
427
|
-
| State
|
|
428
|
-
|
|
429
|
-
| **Default**
|
|
430
|
-
| **Hover**
|
|
431
|
-
| **Focus**
|
|
432
|
-
| **Error**
|
|
433
|
-
| **Disabled** | 38% opacity, no interaction
|
|
482
|
+
| State | Visual Change | Behavior |
|
|
483
|
+
| ------------ | --------------------------------------- | ------------------ |
|
|
484
|
+
| **Default** | Normal border/background | Ready for input |
|
|
485
|
+
| **Hover** | Border darkens or background changes | Visual feedback |
|
|
486
|
+
| **Focus** | 2px border, primary color | Active input state |
|
|
487
|
+
| **Error** | Error color border, error message shown | Validation failed |
|
|
488
|
+
| **Disabled** | 38% opacity, no interaction | Cannot be edited |
|
|
434
489
|
|
|
435
490
|
## Responsive Considerations
|
|
436
491
|
|