@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.
Files changed (36) hide show
  1. package/README.md +12 -4
  2. package/dist/styles.css +5126 -0
  3. package/guidelines/Guidelines.md +92 -41
  4. package/guidelines/components/accordion.md +732 -0
  5. package/guidelines/components/avatar.md +1015 -0
  6. package/guidelines/components/badge.md +728 -0
  7. package/guidelines/components/button.md +75 -40
  8. package/guidelines/components/card.md +84 -25
  9. package/guidelines/components/checkbox.md +671 -0
  10. package/guidelines/components/dialog.md +619 -31
  11. package/guidelines/components/drawer.md +1616 -0
  12. package/guidelines/components/heading.md +576 -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 +1271 -0
  18. package/guidelines/components/progress.md +836 -0
  19. package/guidelines/components/radio-group.md +852 -0
  20. package/guidelines/components/select.md +1662 -0
  21. package/guidelines/components/skeleton.md +802 -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 +1488 -0
  26. package/guidelines/components/textarea.md +495 -0
  27. package/guidelines/components/toast.md +784 -0
  28. package/guidelines/components/tooltip.md +912 -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 +60 -8
  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,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 | Visual Style | Usage | When to Use |
16
- |---------|-------------|-------|-------------|
17
- | `outlined` | Outlined border around input | Default text inputs | Most common, clear boundaries |
18
- | `filled` | Filled background with bottom border | Alternative style | When you want less visual weight |
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 | bodySmall | Compact forms, dense layouts |
30
- | `md` | 56px | bodyLarge | Default, most use cases |
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 | Type | Default | Description |
35
- |------|------|---------|-------------|
36
- | `label` | `string` | - | Label text (highly recommended for accessibility) |
37
- | `helperText` | `string` | - | Helper text displayed below input |
38
- | `errorText` | `string` | - | Error message (also sets error state) |
39
- | `variant` | `'outlined' \| 'filled'` | `'outlined'` | Visual style variant |
40
- | `size` | `'sm' \| 'md'` | `'md'` | Input size |
41
- | `state` | `'error'` | - | Visual state (auto-set if errorText provided) |
42
- | `disabled` | `boolean` | `false` | Disable input |
43
- | `value` | `string` | - | Controlled value |
44
- | `defaultValue` | `string` | - | Uncontrolled default value |
45
- | `onChange` | `(event: ChangeEvent) => void` | - | Change handler |
46
- | `placeholder` | `string` | - | Placeholder text |
47
- | `type` | `string` | `'text'` | HTML input type (text, email, password, etc.) |
48
- | `required` | `boolean` | `false` | Mark as required field |
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 | Recommended Variant | Reasoning |
418
- |----------|-------------------|-----------|
419
- | Standard forms | `outlined` | Clear boundaries, default choice |
420
- | Dense forms | `outlined` + `size="sm"` | Compact while maintaining clarity |
421
- | Minimal UI | `filled` | Lighter visual weight |
422
- | Search bars | `outlined` or `filled` | Either works, depends on design |
423
- | Settings forms | `outlined` | Clear separation of fields |
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 | Visual Change | Behavior |
428
- |-------|---------------|----------|
429
- | **Default** | Normal border/background | Ready for input |
430
- | **Hover** | Border darkens or background changes | Visual feedback |
431
- | **Focus** | 2px border, primary color | Active input state |
432
- | **Error** | Error color border, error message shown | Validation failed |
433
- | **Disabled** | 38% opacity, no interaction | Cannot be edited |
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