@phsa.tec/design-system-react 0.2.0 → 0.3.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 CHANGED
@@ -1,23 +1,20 @@
1
- # 🎨 PHSA Design System React
1
+ # PHSA Design System React
2
2
 
3
- A modern, **fully isolated** React component library built with TypeScript, Tailwind CSS, and Radix UI. **No Tailwind installation required** in your project!
3
+ A modern, **fully isolated** React component library built with TypeScript, Tailwind CSS, and Radix UI.
4
4
 
5
- ## Features
5
+ ## Features
6
6
 
7
- - 🎯 **Zero Configuration** - Works out of the box, no Tailwind setup needed
8
- - 🔒 **Fully Isolated** - CSS is completely isolated, won't conflict with your project's styles
9
- - 🎨 **Customizable** - Easy theme customization via Provider props
10
- - 📦 **Lightweight** - Only includes the CSS you actually use
11
- - **Accessible** - Built with Radix UI primitives
12
- - 🌙 **Dark Mode** - Built-in dark mode support
7
+ - **Zero Conflicts** - Fully isolated CSS, won't interfere with your project's styles
8
+ - **Customizable** - Via CSS Variables or Tailwind Preset
9
+ - **Accessible** - Built with Radix UI primitives
10
+ - **Dark Mode** - Native dark theme support
11
+ - **TypeScript** - Full type support
13
12
 
14
- ## 📚 Documentation
13
+ ## Documentation
15
14
 
16
- 🌐 **[View Live Documentation](https://henriques4nti4go.github.io/phsa-design-system/)**
15
+ [View Full Documentation](https://henriques4nti4go.github.io/phsa-design-system/)
17
16
 
18
- ## 🚀 Quick Start
19
-
20
- ### 1. Install
17
+ ## Installation
21
18
 
22
19
  ```bash
23
20
  npm install @phsa.tec/design-system-react
@@ -27,9 +24,13 @@ yarn add @phsa.tec/design-system-react
27
24
  pnpm add @phsa.tec/design-system-react
28
25
  ```
29
26
 
30
- ### 2. Wrap Your App
27
+ ## Basic Usage
31
28
 
32
29
  ```tsx
30
+ // 1. Import CSS (required)
31
+ import "@phsa.tec/design-system-react/styles.css";
32
+
33
+ // 2. Import components
33
34
  import { DesignSystemProvider, Button, Card } from "@phsa.tec/design-system-react";
34
35
 
35
36
  function App() {
@@ -43,362 +44,150 @@ function App() {
43
44
  }
44
45
  ```
45
46
 
46
- **That's it!** The CSS is automatically injected. No configuration needed.
47
-
48
- ## 🎨 Customization
49
-
50
- You can customize **all Tailwind properties** through the `DesignSystemProvider`:
51
-
52
- ### Complete Theme Customization
53
-
54
- ```tsx
55
- import { DesignSystemProvider } from "@phsa.tec/design-system-react";
56
-
57
- function App() {
58
- return (
59
- <DesignSystemProvider
60
- theme={{
61
- colors: {
62
- primary: "#3b82f6",
63
- secondary: "#10b981",
64
- // ... all color options
65
- },
66
- spacing: {
67
- base: "0.25rem", // 4px
68
- sm: "0.5rem", // 8px
69
- md: "1rem", // 16px
70
- lg: "1.5rem", // 24px
71
- xl: "2rem", // 32px
72
- },
73
- typography: {
74
- fontFamily: "Inter, sans-serif",
75
- fontSize: {
76
- sm: "0.875rem",
77
- base: "1rem",
78
- lg: "1.125rem",
79
- },
80
- },
81
- borderRadius: {
82
- sm: "0.25rem",
83
- md: "0.5rem",
84
- lg: "0.75rem",
85
- },
86
- }}
87
- >
88
- {/* Your app */}
89
- </DesignSystemProvider>
90
- );
91
- }
92
- ```
93
-
94
- ### Simple Color Customization (Legacy)
95
-
96
- For backward compatibility, you can still use the `colors` prop:
97
-
98
- ```tsx
99
- <DesignSystemProvider
100
- colors={{
101
- primary: "#3b82f6",
102
- secondary: "#10b981",
103
- }}
104
- >
105
- {/* Your app */}
106
- </DesignSystemProvider>
107
- ```
108
-
109
- ### Available Theme Properties
47
+ ## Customization
110
48
 
111
- #### Colors (`theme.colors`)
49
+ ### Option 1: CSS Variables (Recommended)
112
50
 
113
- - `primary`, `primaryForeground`
114
- - `secondary`, `secondaryForeground`
115
- - `accent`, `accentForeground`
116
- - `destructive`, `destructiveForeground`
117
- - `success`, `successForeground`
118
- - `warning`
119
- - `muted`, `mutedForeground`
120
- - `background`, `foreground`
121
- - `card`, `cardForeground`
122
- - `popover`, `popoverForeground`
123
- - `border`, `input`, `ring`
124
- - `radius`
51
+ Override CSS variables in your stylesheet:
125
52
 
126
- **Color formats supported:**
127
- - **Hex**: `"#3b82f6"`
128
- - **HSL**: `"217 91% 60%"` (without `hsl()` wrapper)
129
- - **RGB**: Standard RGB values
53
+ ```css
54
+ /* globals.css */
55
+ :root {
56
+ /* Primary colors */
57
+ --primary: 220 90% 50%;
58
+ --primary-foreground: 0 0% 100%;
59
+ --secondary: 210 40% 96%;
60
+ --secondary-foreground: 222 47% 11%;
130
61
 
131
- #### Spacing (`theme.spacing`)
62
+ /* Feedback colors */
63
+ --destructive: 0 84% 60%;
64
+ --success: 142 76% 36%;
65
+ --warning: 38 92% 50%;
132
66
 
133
- Customize spacing scale used by padding, margin, gap utilities:
67
+ /* Neutral colors */
68
+ --background: 0 0% 100%;
69
+ --foreground: 222 84% 5%;
70
+ --muted: 210 40% 96%;
71
+ --muted-foreground: 215 16% 47%;
72
+ --border: 214 32% 91%;
134
73
 
135
- ```tsx
136
- theme={{
137
- spacing: {
138
- base: "0.25rem", // Base unit (default: 4px)
139
- xs: "0.5rem", // Extra small
140
- sm: "0.75rem", // Small
141
- md: "1rem", // Medium
142
- lg: "1.5rem", // Large
143
- xl: "2rem", // Extra large
144
- "2xl": "3rem", // 2x extra large
145
- "3xl": "4rem", // 3x extra large
146
- }
147
- }}
148
- ```
149
-
150
- #### Typography (`theme.typography`)
151
-
152
- ```tsx
153
- theme={{
154
- typography: {
155
- fontFamily: "Inter, sans-serif",
156
- fontSize: {
157
- xs: "0.75rem",
158
- sm: "0.875rem",
159
- base: "1rem",
160
- lg: "1.125rem",
161
- xl: "1.25rem",
162
- "2xl": "1.5rem",
163
- "3xl": "1.875rem",
164
- "4xl": "2.25rem",
165
- "5xl": "3rem",
166
- },
167
- fontWeight: {
168
- light: "300",
169
- normal: "400",
170
- medium: "500",
171
- semibold: "600",
172
- bold: "700",
173
- },
174
- lineHeight: {
175
- none: "1",
176
- tight: "1.25",
177
- snug: "1.375",
178
- normal: "1.5",
179
- relaxed: "1.75",
180
- loose: "2",
181
- },
182
- }
183
- }}
184
- ```
185
-
186
- #### Border Radius (`theme.borderRadius`)
187
-
188
- ```tsx
189
- theme={{
190
- borderRadius: {
191
- none: "0px",
192
- sm: "0.25rem",
193
- md: "0.5rem",
194
- lg: "0.75rem",
195
- xl: "1rem",
196
- "2xl": "1.5rem",
197
- "3xl": "2rem",
198
- full: "9999px",
199
- }
200
- }}
201
- ```
202
-
203
- #### Box Shadow (`theme.boxShadow`)
204
-
205
- ```tsx
206
- theme={{
207
- boxShadow: {
208
- sm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
209
- md: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
210
- lg: "0 10px 15px -3px rgb(0 0 0 / 0.1)",
211
- xl: "0 20px 25px -5px rgb(0 0 0 / 0.1)",
212
- "2xl": "0 25px 50px -12px rgb(0 0 0 / 0.25)",
213
- inner: "inset 0 2px 4px 0 rgb(0 0 0 / 0.05)",
214
- none: "none",
215
- }
216
- }}
217
- ```
218
-
219
- #### Breakpoints (`theme.breakpoints`)
220
-
221
- ```tsx
222
- theme={{
223
- breakpoints: {
224
- sm: "640px",
225
- md: "768px",
226
- lg: "1024px",
227
- xl: "1280px",
228
- "2xl": "1536px",
229
- }
230
- }}
231
- ```
232
-
233
- ## 🎯 Usage Examples
234
-
235
- ### Basic Components
236
-
237
- ```tsx
238
- import {
239
- Button,
240
- Input,
241
- Card,
242
- CardContent,
243
- CardHeader,
244
- CardTitle,
245
- DesignSystemProvider,
246
- } from "@phsa.tec/design-system-react";
74
+ /* Other */
75
+ --radius: 0.5rem;
76
+ --font-family: "Inter", sans-serif;
77
+ }
247
78
 
248
- function App() {
249
- return (
250
- <DesignSystemProvider>
251
- <Card>
252
- <CardHeader>
253
- <CardTitle>Hello World</CardTitle>
254
- </CardHeader>
255
- <CardContent>
256
- <div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
257
- <Input placeholder="Enter text..." />
258
- <Button>Click me</Button>
259
- </div>
260
- </CardContent>
261
- </Card>
262
- </DesignSystemProvider>
263
- );
79
+ /* Dark mode */
80
+ .dark {
81
+ --background: 222 84% 5%;
82
+ --foreground: 210 40% 98%;
83
+ /* ... other variables */
264
84
  }
265
85
  ```
266
86
 
267
- ### With Custom Theme
87
+ ### Option 2: Tailwind Preset (Advanced)
268
88
 
269
- ```tsx
270
- import { DesignSystemProvider, Button } from "@phsa.tec/design-system-react";
89
+ If your project uses Tailwind CSS, you can extend with our preset:
271
90
 
272
- function App() {
273
- return (
274
- <DesignSystemProvider
275
- theme={{
276
- colors: {
277
- primary: "#8b5cf6", // Purple
278
- secondary: "#06b6d4", // Cyan
279
- },
280
- spacing: {
281
- md: "1.25rem", // Custom medium spacing
282
- lg: "2rem", // Custom large spacing
283
- },
284
- typography: {
285
- fontFamily: "Inter, sans-serif",
91
+ ```js
92
+ // tailwind.config.js
93
+ module.exports = {
94
+ presets: [require("@phsa.tec/design-system-react/tailwind-preset")],
95
+ theme: {
96
+ extend: {
97
+ // Your customizations
98
+ colors: {
99
+ primary: {
100
+ DEFAULT: "#your-color",
286
101
  },
287
- }}
288
- >
289
- <Button variant="default">Primary Button</Button>
290
- <Button variant="secondary">Secondary Button</Button>
291
- </DesignSystemProvider>
292
- );
293
- }
294
- ```
102
+ },
103
+ },
104
+ },
105
+ };
106
+ ```
107
+
108
+ ## Available CSS Variables
109
+
110
+ ### Colors
111
+
112
+ | Variable | Description |
113
+ |----------|-------------|
114
+ | `--primary` | Primary color |
115
+ | `--primary-foreground` | Text on primary color |
116
+ | `--secondary` | Secondary color |
117
+ | `--secondary-foreground` | Text on secondary color |
118
+ | `--destructive` | Error/danger color |
119
+ | `--success` | Success color |
120
+ | `--warning` | Warning color |
121
+ | `--muted` | Muted color |
122
+ | `--muted-foreground` | Muted text |
123
+ | `--background` | Page background |
124
+ | `--foreground` | Main text |
125
+ | `--border` | Border color |
126
+ | `--input` | Input color |
127
+ | `--ring` | Focus ring color |
295
128
 
296
- ### Advanced Customization Example
129
+ ### Layout
297
130
 
298
- ```tsx
299
- import { DesignSystemProvider, Card, Button } from "@phsa.tec/design-system-react";
131
+ | Variable | Description | Default |
132
+ |----------|-------------|---------|
133
+ | `--radius` | Base border radius | `0.5rem` |
134
+ | `--font-family` | Font family | `"Roboto"` |
300
135
 
301
- function App() {
302
- return (
303
- <DesignSystemProvider
304
- theme={{
305
- colors: {
306
- primary: "#6366f1",
307
- secondary: "#8b5cf6",
308
- },
309
- spacing: {
310
- base: "0.5rem", // 8px base (instead of 4px)
311
- md: "1.5rem", // 24px medium
312
- lg: "3rem", // 48px large
313
- },
314
- typography: {
315
- fontFamily: "'Inter', 'Roboto', sans-serif",
316
- fontSize: {
317
- base: "16px",
318
- lg: "18px",
319
- xl: "20px",
320
- },
321
- fontWeight: {
322
- normal: "400",
323
- semibold: "600",
324
- bold: "700",
325
- },
326
- },
327
- borderRadius: {
328
- md: "0.75rem",
329
- lg: "1rem",
330
- },
331
- boxShadow: {
332
- md: "0 8px 16px -4px rgb(0 0 0 / 0.15)",
333
- lg: "0 16px 32px -8px rgb(0 0 0 / 0.2)",
334
- },
335
- }}
336
- >
337
- <Card>
338
- <Button>Customized Button</Button>
339
- </Card>
340
- </DesignSystemProvider>
341
- );
342
- }
343
- ```
136
+ ### Spacing
137
+
138
+ | Variable | Description |
139
+ |----------|-------------|
140
+ | `--spacing-xs` | Extra small |
141
+ | `--spacing-sm` | Small |
142
+ | `--spacing-md` | Medium |
143
+ | `--spacing-lg` | Large |
144
+ | `--spacing-xl` | Extra large |
344
145
 
345
- ## 🧩 Available Components
146
+ ## Available Components
346
147
 
347
148
  ### Layout
348
- - **Card** - Container component with header, content, and footer
349
- - **Sheet** - Slide-over panel
350
- - **Tabs** - Tab navigation
351
- - **Separator** - Visual divider
352
- - **PageLayout** - Full page layout wrapper
149
+ - `Card`, `CardHeader`, `CardContent`, `CardFooter`
150
+ - `Sheet`, `SheetContent`, `SheetHeader`
151
+ - `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`
152
+ - `Separator`
353
153
 
354
154
  ### Forms
355
- - **Input** - Text input with validation support
356
- - **Button** - Button with multiple variants
357
- - **Select** - Dropdown selection
358
- - **Checkbox** - Checkbox input
359
- - **Switch** - Toggle switch
360
- - **Form** - Form wrapper with React Hook Form integration
155
+ - `Button`
156
+ - `Input`
157
+ - `Select`, `SelectTrigger`, `SelectContent`, `SelectItem`
158
+ - `Checkbox`
159
+ - `Switch`
160
+ - `Label`
361
161
 
362
162
  ### Data Display
363
- - **DataTable** - Advanced table with sorting, filtering, pagination
364
- - **Badge** - Status badge
365
- - **Avatar** - User avatar
366
- - **Text** - Typography component
163
+ - `DataTable`
164
+ - `Badge`
165
+ - `Avatar`
367
166
 
368
167
  ### Feedback
369
- - **Dialog** - Modal dialog
370
- - **AlertDialog** - Confirmation dialog
371
- - **Toast** - Notification toast
372
- - **Alert** - Alert message
373
- - **Spinner** - Loading spinner
168
+ - `Dialog`, `DialogContent`, `DialogHeader`
169
+ - `AlertDialog`
170
+ - `Toast`, `Toaster`
171
+ - `Alert`
172
+ - `Spinner`
374
173
 
375
174
  ### Navigation
376
- - **DropdownMenu** - Dropdown menu
377
- - **Breadcrumbs** - Breadcrumb navigation
378
- - **Command** - Command palette
175
+ - `DropdownMenu`
176
+ - `Command`
177
+ - `Popover`
379
178
 
380
- ## 🌙 Dark Mode
179
+ ## Dark Mode
381
180
 
382
- The design system supports dark mode automatically. Add the `dark` class to your root element:
383
-
384
- ```tsx
385
- // Toggle dark mode
386
- document.documentElement.classList.toggle('dark');
387
- ```
388
-
389
- Or use `next-themes` for React:
390
-
391
- ```bash
392
- npm install next-themes
393
- ```
181
+ Add the `dark` class to the root element:
394
182
 
395
183
  ```tsx
184
+ // With next-themes
396
185
  import { ThemeProvider } from "next-themes";
397
186
  import { DesignSystemProvider } from "@phsa.tec/design-system-react";
398
187
 
399
188
  function App() {
400
189
  return (
401
- <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
190
+ <ThemeProvider attribute="class" defaultTheme="system">
402
191
  <DesignSystemProvider>
403
192
  {/* Your app */}
404
193
  </DesignSystemProvider>
@@ -407,44 +196,34 @@ function App() {
407
196
  }
408
197
  ```
409
198
 
410
- ## 🔒 Isolation & Compatibility
411
-
412
- ### ✅ Works With
413
-
414
- - ✅ Projects **without** Tailwind CSS
415
- - ✅ Projects **with** Tailwind CSS (no conflicts!)
416
- - ✅ Next.js, Vite, Create React App, etc.
417
- - ✅ Any React framework
418
-
419
- ### How It Works
199
+ ## Compatibility
420
200
 
421
- The design system:
422
- 1. **Compiles CSS at build time** - All Tailwind classes are pre-compiled
423
- 2. **Uses unique class prefixes** - Classes are prefixed with `phsa-` to avoid conflicts
424
- 3. **Scopes CSS with `.ds`** - All styles are scoped to prevent interference
425
- 4. **Auto-injects CSS** - CSS is automatically loaded when you use `DesignSystemProvider`
201
+ - Projects **without** Tailwind CSS
202
+ - Projects **with** Tailwind CSS (no conflicts)
203
+ - Next.js, Vite, Create React App
204
+ - React 18+
426
205
 
427
- ## 📦 Package Exports
206
+ ## Package Exports
428
207
 
429
208
  ```typescript
430
209
  // Components
431
210
  import { Button, Card } from "@phsa.tec/design-system-react";
432
211
 
433
- // Styles (if you need manual import)
434
- import "@phsa.tec/design-system-react/styles";
435
- // or
436
- import styles from "@phsa.tec/design-system-react/styles";
437
- ```
212
+ // CSS (required)
213
+ import "@phsa.tec/design-system-react/styles.css";
438
214
 
439
- ## 🛠️ Development
215
+ // Tailwind Preset (optional)
216
+ // In tailwind.config.js:
217
+ // presets: [require("@phsa.tec/design-system-react/tailwind-preset")]
218
+ ```
440
219
 
441
- For local development and contributing:
220
+ ## Development
442
221
 
443
222
  ```bash
444
223
  # Install dependencies
445
224
  yarn install
446
225
 
447
- # Run Storybook
226
+ # Storybook
448
227
  yarn storybook
449
228
 
450
229
  # Build library
@@ -453,24 +232,14 @@ yarn build:lib
453
232
  # Watch mode
454
233
  yarn build:lib:watch
455
234
 
456
- # Run tests
235
+ # Tests
457
236
  yarn test
458
237
  ```
459
238
 
460
- ## 📄 License
461
-
462
- MIT License - see [LICENSE](LICENSE) file for details.
463
-
464
- ## 🤝 Contributing
465
-
466
- Contributions are welcome! Please read our contributing guidelines before submitting PRs.
467
-
468
- ## 📞 Support
239
+ ## License
469
240
 
470
- - **Documentation**: [View Live Docs](https://henriques4nti4go.github.io/phsa-design-system/)
471
- - **Issues**: [GitHub Issues](https://github.com/henriques4nti4go/phsa-design-system/issues)
472
- - **Package**: [npm](https://www.npmjs.com/package/@phsa.tec/design-system-react)
241
+ MIT
473
242
 
474
243
  ---
475
244
 
476
- Built with ❤️ by the PHSA team
245
+ Built by the PHSA team