@discourser/design-system 0.3.0 → 0.4.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.
@@ -0,0 +1,204 @@
1
+ # Components Overview
2
+
3
+ Always prefer components from `@discourser/design-system` if available. Do not use native HTML elements when a design system component exists.
4
+
5
+ ## Available Components
6
+
7
+ ### Interactive Elements
8
+
9
+ | Component | Purpose | Guidelines |
10
+ | ---------- | -------------------------------------------------- | ------------------------------------------- |
11
+ | Button | Primary interactive element for actions | [button.md](components/button.md) |
12
+ | IconButton | Icon-only interactive element | [icon-button.md](components/icon-button.md) |
13
+ | Switch | Toggle control for binary on/off states | [switch.md](components/switch.md) |
14
+ | Checkbox | Binary selection control for toggling options | [checkbox.md](components/checkbox.md) |
15
+ | RadioGroup | Mutually exclusive selection from multiple options | [radio-group.md](components/radio-group.md) |
16
+
17
+ ### Form Elements
18
+
19
+ | Component | Purpose | Guidelines |
20
+ | --------- | ------------------------------------------------ | ------------------------------------- |
21
+ | Input | Single-line text input with label and validation | [input.md](components/input.md) |
22
+ | Textarea | Multi-line text input for longer content | [textarea.md](components/textarea.md) |
23
+ | Select | Dropdown selection from list of options | [select.md](components/select.md) |
24
+
25
+ ### Layout & Container Elements
26
+
27
+ | Component | Purpose | Guidelines |
28
+ | --------- | -------------------------------------------------- | --------------------------------------- |
29
+ | Card | Container for related content with elevation | [card.md](components/card.md) |
30
+ | Accordion | Collapsible sections for organizing content | [accordion.md](components/accordion.md) |
31
+ | Tabs | Tabbed navigation for switching between views | [tabs.md](components/tabs.md) |
32
+ | Drawer | Side panel for navigation or supplementary content | [drawer.md](components/drawer.md) |
33
+
34
+ ### Overlay Elements
35
+
36
+ | Component | Purpose | Guidelines |
37
+ | --------- | ------------------------------------------------ | ----------------------------------- |
38
+ | Dialog | Modal overlay for focused tasks or confirmations | [dialog.md](components/dialog.md) |
39
+ | Popover | Floating panel for contextual content | [popover.md](components/popover.md) |
40
+ | Tooltip | Brief contextual help text on hover | [tooltip.md](components/tooltip.md) |
41
+
42
+ ### Feedback & Status Elements
43
+
44
+ | Component | Purpose | Guidelines |
45
+ | --------- | --------------------------------------------- | ------------------------------------- |
46
+ | Badge | Compact visual indicator for status or labels | [badge.md](components/badge.md) |
47
+ | Avatar | User profile image with fallback initials | [avatar.md](components/avatar.md) |
48
+ | Toast | Temporary notification messages | [toast.md](components/toast.md) |
49
+ | Progress | Visual indicator for task completion | [progress.md](components/progress.md) |
50
+ | Skeleton | Loading placeholder for content | [skeleton.md](components/skeleton.md) |
51
+
52
+ ### Typography Elements
53
+
54
+ | Component | Purpose | Guidelines |
55
+ | --------- | -------------------------------------- | ----------------------------------- |
56
+ | Heading | Semantic heading for content hierarchy | [heading.md](components/heading.md) |
57
+
58
+ ## Common Props
59
+
60
+ Most components accept these standard props:
61
+
62
+ - `variant` - Visual style variant (e.g., filled, outlined, text)
63
+ - `size` - Size variant (sm, md, lg)
64
+ - `disabled` - Disable interaction
65
+ - `className` - Additional CSS classes (use sparingly)
66
+ - `ref` - React ref for DOM access (all components use forwardRef)
67
+
68
+ ## Styling Guidelines
69
+
70
+ ### ✅ DO:
71
+
72
+ ```typescript
73
+ // Use design system components with variants
74
+ <Button variant="filled" size="md">Submit</Button>
75
+ <Card variant="elevated">Content</Card>
76
+ <Input variant="outlined" label="Email" />
77
+
78
+ // Use semantic color tokens when custom styling is needed
79
+ import { css } from '@discourser/design-system/styled-system/css';
80
+ const customStyle = css({ bg: 'primary', color: 'onPrimary' });
81
+
82
+ // Compose multiple components together
83
+ <Card variant="elevated">
84
+ <Input label="Username" />
85
+ <Button variant="filled">Submit</Button>
86
+ </Card>
87
+ ```
88
+
89
+ ### ❌ DO NOT:
90
+
91
+ ```typescript
92
+ // Don't use raw HTML when components exist
93
+ <button className="...">Submit</button> // Use <Button> instead
94
+ <input type="text" /> // Use <Input> instead
95
+ <div className="card">...</div> // Use <Card> instead
96
+
97
+ // Don't override styles with inline styles
98
+ <Button style={{ backgroundColor: 'blue' }}>Submit</Button>
99
+
100
+ // Don't use raw color values
101
+ <div style={{ backgroundColor: '#4C662B' }}>...</div>
102
+ const style = css({ bg: '#4C662B' }); // Use semantic tokens instead
103
+
104
+ // Don't skip required props like labels
105
+ <Input placeholder="Email" /> // Missing label (accessibility issue)
106
+ ```
107
+
108
+ ## Component Categories
109
+
110
+ ### Interactive Elements
111
+
112
+ - **Button** - For user actions (submit, cancel, etc.)
113
+ - **IconButton** - For icon-only actions (close, menu, etc.)
114
+ - **Switch** - For toggle states (enable/disable features)
115
+
116
+ ### Input Elements
117
+
118
+ - **Input** - For text input fields with built-in label and validation
119
+
120
+ ### Layout Elements
121
+
122
+ - **Card** - For grouping related content with visual hierarchy
123
+
124
+ ### Overlay Elements
125
+
126
+ - **Dialog** - For modal dialogs and confirmations
127
+
128
+ ## Controlled vs Uncontrolled
129
+
130
+ ### Controlled Components
131
+
132
+ Component receives `value` and `onChange` props from parent:
133
+
134
+ ```typescript
135
+ const [email, setEmail] = useState('');
136
+ <Input
137
+ label="Email"
138
+ value={email}
139
+ onChange={(e) => setEmail(e.target.value)}
140
+ />
141
+ ```
142
+
143
+ ### Uncontrolled Components
144
+
145
+ Component manages own state, use `defaultValue`:
146
+
147
+ ```typescript
148
+ <Input label="Email" defaultValue="user@example.com" />
149
+ ```
150
+
151
+ **Recommendation**: Prefer controlled components for form inputs to maintain single source of truth.
152
+
153
+ ## Accessibility
154
+
155
+ All components follow WCAG 2.1 Level AA standards:
156
+
157
+ - Keyboard navigation is built-in
158
+ - Focus management is automatic
159
+ - ARIA attributes are applied correctly
160
+ - Color contrast meets accessibility requirements
161
+ - Screen reader support is included
162
+
163
+ **Important**: Always provide labels for form inputs:
164
+
165
+ ```typescript
166
+ // ✅ Correct
167
+ <Input label="Email" />
168
+
169
+ // ❌ Wrong - Missing label
170
+ <Input placeholder="Enter email" />
171
+ ```
172
+
173
+ ## Responsive Design
174
+
175
+ Components are designed to work on all screen sizes. Use the `size` prop to control component sizing:
176
+
177
+ ```typescript
178
+ // Mobile-friendly larger touch targets
179
+ <Button size="lg">Submit</Button>
180
+
181
+ // Desktop compact layouts
182
+ <Button size="sm">Save</Button>
183
+
184
+ // Default for most use cases
185
+ <Button size="md">Submit</Button>
186
+ ```
187
+
188
+ ## Theme Integration
189
+
190
+ All components automatically respond to theme changes via `data-theme` attribute:
191
+
192
+ ```typescript
193
+ // Light theme
194
+ <html data-theme="light">
195
+ <Button variant="filled">Submit</Button> // Uses light theme colors
196
+ </html>
197
+
198
+ // Dark theme
199
+ <html data-theme="dark">
200
+ <Button variant="filled">Submit</Button> // Uses dark theme colors
201
+ </html>
202
+ ```
203
+
204
+ No additional code is needed for theme support - it works automatically.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discourser/design-system",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Aesthetic-agnostic design system with Panda CSS and Ark UI",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -48,7 +48,8 @@
48
48
  },
49
49
  "files": [
50
50
  "dist",
51
- "styled-system"
51
+ "styled-system",
52
+ "guidelines"
52
53
  ],
53
54
  "scripts": {
54
55
  "dev": "pnpm docs:generate && storybook dev -p 6006",