@hyddenlabs/hydn-ui 0.0.1-alpha.34

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 ADDED
@@ -0,0 +1,569 @@
1
+ # HYDN UI
2
+
3
+ A modern React component library built with TypeScript, Tailwind CSS, and optimized with tsup.
4
+
5
+ ## Overview
6
+
7
+ HYDN UI is a comprehensive design system and component library that provides a collection of reusable, accessible, and customizable React components. The library includes everything from basic form elements to complex data visualization components.
8
+
9
+ ## Features
10
+
11
+ - ๐ŸŽจ **Modern Design System** - Clean, consistent, and professional UI components
12
+ - โšก **Built with tsup** - Fast builds and optimal bundle size
13
+ - ๐ŸŽฏ **TypeScript** - Full type safety and excellent developer experience
14
+ - ๐ŸŽจ **Tailwind CSS** - Utility-first CSS framework for rapid styling
15
+ - โ™ฟ **Accessible** - Components built with accessibility in mind
16
+ - ๐Ÿงช **Well Tested** - Comprehensive test suite with Vitest
17
+ - ๐Ÿ“ฑ **Responsive** - Mobile-first responsive design
18
+ - ๐ŸŒฒ **Tree-Shakeable** - Only bundle what you use
19
+
20
+ ## Table of Contents
21
+
22
+ - [Installation](#installation)
23
+ - [Quick Start](#quick-start)
24
+ - [Usage Examples](#usage-examples)
25
+ - [Component Categories](#component-categories)
26
+ - [Tree-Shaking](#tree-shaking)
27
+ - [Development](#development)
28
+ - [Publishing](#publishing)
29
+ - [Tech Stack](#tech-stack)
30
+ - [Contributing](#contributing)
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install @hyddenlabs/hydn-ui
36
+ # or
37
+ yarn add @hyddenlabs/hydn-ui
38
+ # or
39
+ pnpm add @hyddenlabs/hydn-ui
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ### Basic Setup
45
+
46
+ ```tsx
47
+ import { ThemeProvider } from '@hyddenlabs/hydn-ui';
48
+ import '@hyddenlabs/hydn-ui/styles';
49
+
50
+ function App() {
51
+ return (
52
+ <ThemeProvider>
53
+ <Card>
54
+ <h1>Hello World</h1>
55
+ <Input placeholder="Enter your name" />
56
+ <Button>Submit</Button>
57
+ </Card>
58
+ </ThemeProvider>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ### Import Styles
64
+
65
+ The library styles are built with Tailwind CSS. Import the stylesheet in your main entry file:
66
+
67
+ ```tsx
68
+ // In your main entry file (e.g., main.tsx or App.tsx)
69
+ import '@hyddenlabs/hydn-ui/styles';
70
+ ```
71
+
72
+ Alternatively, if you're using Tailwind in your project, you can configure it to include the library's components in your own Tailwind build.
73
+
74
+ ## Usage Examples
75
+
76
+ ### Forms
77
+
78
+ ```tsx
79
+ import { Button, Input, FormField, Card } from '@hyddenlabs/hydn-ui';
80
+
81
+ function LoginForm() {
82
+ return (
83
+ <Card>
84
+ <FormField label="Email" required>
85
+ <Input type="email" placeholder="Enter your email" />
86
+ </FormField>
87
+
88
+ <FormField label="Password" required>
89
+ <Input type="password" placeholder="Enter your password" />
90
+ </FormField>
91
+
92
+ <Button variant="primary" fullWidth>
93
+ Sign In
94
+ </Button>
95
+ </Card>
96
+ );
97
+ }
98
+ ```
99
+
100
+ ### Data Tables
101
+
102
+ ```tsx
103
+ import { DataTable } from '@hyddenlabs/hydn-ui';
104
+
105
+ const columns = [
106
+ { accessorKey: 'name', header: 'Name' },
107
+ { accessorKey: 'email', header: 'Email' },
108
+ { accessorKey: 'status', header: 'Status' }
109
+ ];
110
+
111
+ const data = [
112
+ { name: 'John Doe', email: 'john@example.com', status: 'active' },
113
+ { name: 'Jane Smith', email: 'jane@example.com', status: 'inactive' }
114
+ ];
115
+
116
+ function UserTable() {
117
+ return <DataTable columns={columns} data={data} />;
118
+ }
119
+ ```
120
+
121
+ ### Layouts
122
+
123
+ ```tsx
124
+ import { Container, Grid, Card, Heading } from '@hyddenlabs/hydn-ui';
125
+
126
+ function Dashboard() {
127
+ return (
128
+ <Container>
129
+ <Heading level={1}>Dashboard</Heading>
130
+
131
+ <Grid cols={3} gap="lg">
132
+ <Card>
133
+ <Heading level={3}>Total Users</Heading>
134
+ <p>1,234</p>
135
+ </Card>
136
+
137
+ <Card>
138
+ <Heading level={3}>Revenue</Heading>
139
+ <p>$45,678</p>
140
+ </Card>
141
+
142
+ <Card>
143
+ <Heading level={3}>Orders</Heading>
144
+ <p>890</p>
145
+ </Card>
146
+ </Grid>
147
+ </Container>
148
+ );
149
+ }
150
+ ```
151
+
152
+ ### Theme Customization
153
+
154
+ ```tsx
155
+ import { ThemeProvider, ColorModeToggle } from '@hyddenlabs/hydn-ui';
156
+
157
+ function App() {
158
+ return (
159
+ <ThemeProvider defaultTheme="dark">
160
+ <header>
161
+ <ColorModeToggle />
162
+ </header>
163
+ {/* Your app content */}
164
+ </ThemeProvider>
165
+ );
166
+ }
167
+ ```
168
+
169
+ ### TypeScript Support
170
+
171
+ All components are fully typed. Import types directly:
172
+
173
+ ```tsx
174
+ import type { ButtonProps, InputProps, CardProps } from '@hyddenlabs/hydn-ui';
175
+
176
+ const customButton: ButtonProps = {
177
+ variant: 'primary',
178
+ size: 'lg',
179
+ onClick: () => console.log('clicked')
180
+ };
181
+ ```
182
+
183
+ ## Component Categories
184
+
185
+ ### Forms & Inputs
186
+
187
+ - Button, Button Group
188
+ - Input, Input Group, Textarea
189
+ - Select, Radio, Radio Group, Checkbox
190
+ - Slider, Switch, Calendar
191
+ - Form, Form Field, Fieldset
192
+
193
+ ### Data Display
194
+
195
+ - Avatar, Badge, Chip
196
+ - Table, Data Table, List
197
+ - Timeline, Code Block
198
+ - Price Display, Pricing
199
+ - Empty State
200
+
201
+ ### Layout
202
+
203
+ - Card, Container, Grid
204
+ - Accordion, Drawer, Divider
205
+ - Page, Page Header, Section
206
+ - Hero, Feature Section, Footer
207
+ - Stack
208
+
209
+ ### Navigation
210
+
211
+ - Navbar, Nav, Sidebar
212
+ - Breadcrumbs, Dropdown
213
+ - Pagination, Stepper, Tabs
214
+
215
+ ### Feedback
216
+
217
+ - Alert, Dialog, Modal
218
+ - Toast, Tooltip, Popover
219
+ - Progress Bar, Spinner, Skeleton
220
+
221
+ ### Typography
222
+
223
+ - Heading, Text, Link, Code
224
+
225
+ ### System
226
+
227
+ - Theme Provider, Color Mode Toggle
228
+
229
+ ## Tree-Shaking
230
+
231
+ The library is built with full tree-shaking support. Modern bundlers (Vite, Webpack 5, Rollup) will automatically eliminate unused components:
232
+
233
+ ```tsx
234
+ // Only Button and its dependencies are bundled (~6KB)
235
+ import { Button } from '@hyddenlabs/hydn-ui';
236
+
237
+ // Multiple imports are also tree-shaken
238
+ import { Button, Input, Card } from '@hyddenlabs/hydn-ui';
239
+ ```
240
+
241
+ ### Benefits
242
+
243
+ - โœ… Only pay for what you use
244
+ - โœ… Automatic dead code elimination with ESM
245
+ - โœ… Unminified source for better bundler optimization
246
+ - โœ… Modern tooling compatible
247
+
248
+ ### How It Works
249
+
250
+ The library is optimized for tree-shaking:
251
+
252
+ - **ESM format** - Modern bundlers can analyze and eliminate dead code
253
+ - **Unminified** - Preserves original code structure for better analysis
254
+ - **sideEffects field** - Tells bundlers what's safe to remove (CSS only)
255
+ - **Named exports** - Each component is individually importable
256
+ - **No global side effects** - Components don't execute code on import
257
+
258
+ ### Verification
259
+
260
+ To verify tree-shaking works:
261
+
262
+ 1. Create a test project with Vite:
263
+
264
+ ```bash
265
+ npm create vite@latest my-test -- --template react-ts
266
+ cd my-test
267
+ npm install @hyddenlabs/hydn-ui
268
+ ```
269
+
270
+ 2. Import a single component:
271
+
272
+ ```tsx
273
+ import { Button } from '@hyddenlabs/hydn-ui';
274
+ ```
275
+
276
+ 3. Build and check bundle size:
277
+
278
+ ```bash
279
+ npm run build
280
+ ```
281
+
282
+ You should see only ~6-8KB for Button, not the entire 118KB library.
283
+
284
+ ## Development
285
+
286
+ This repository contains both the component library and a showcase/documentation SPA.
287
+
288
+ ### Prerequisites
289
+
290
+ - Node.js (v18 or higher)
291
+ - npm, yarn, or pnpm
292
+
293
+ ### Local Development Setup
294
+
295
+ ```bash
296
+ # Clone the repository
297
+ git clone https://github.com/hydn-co/hydn-ui.git
298
+ cd hydn-ui
299
+
300
+ # Install dependencies
301
+ npm install
302
+
303
+ # Start the development server (runs the showcase SPA)
304
+ npm run dev
305
+
306
+ # Run tests
307
+ npm test
308
+
309
+ # Build the library for publishing
310
+ npm run build
311
+
312
+ # Lint code
313
+ npm run lint
314
+
315
+ # Format code
316
+ npm run format
317
+ ```
318
+
319
+ ### Project Structure
320
+
321
+ ```
322
+ src/
323
+ โ”œโ”€โ”€ components/ # Reusable UI components
324
+ โ”‚ โ”œโ”€โ”€ data-display/ # Data visualization components
325
+ โ”‚ โ”œโ”€โ”€ feedback/ # User feedback components
326
+ โ”‚ โ”œโ”€โ”€ forms/ # Form-related components
327
+ โ”‚ โ”œโ”€โ”€ layout/ # Layout and structural components
328
+ โ”‚ โ”œโ”€โ”€ navigation/ # Navigation components
329
+ โ”‚ โ”œโ”€โ”€ system/ # System-level components
330
+ โ”‚ โ””โ”€โ”€ typography/ # Text and typography components
331
+ โ”œโ”€โ”€ pages/ # Demo and application pages
332
+ โ”œโ”€โ”€ theme/ # Theme configuration and tokens
333
+ โ””โ”€โ”€ index.ts # Main library export
334
+ ```
335
+
336
+ ## Publishing
337
+
338
+ ### Build the Library
339
+
340
+ ```bash
341
+ npm run build
342
+ ```
343
+
344
+ This generates:
345
+
346
+ - `dist/index.js` - ESM bundle (tree-shakeable)
347
+ - `dist/index.cjs` - CommonJS bundle
348
+ - `dist/index.d.ts` - TypeScript declarations (ESM)
349
+ - `dist/index.d.cts` - TypeScript declarations (CJS)
350
+ - `dist/style.css` - Compiled Tailwind CSS styles
351
+ - Source maps for debugging
352
+
353
+ ### Publishing Process
354
+
355
+ 1. **Update Version**
356
+
357
+ ```bash
358
+ # Using npm version command (recommended)
359
+ npm version patch # 1.0.0 -> 1.0.1
360
+ npm version minor # 1.0.0 -> 1.1.0
361
+ npm version major # 1.0.0 -> 2.0.0
362
+ ```
363
+
364
+ 2. **Verify Build Output**
365
+
366
+ Check the `dist/` folder contains all required files.
367
+
368
+ 3. **Test Locally (Optional)**
369
+
370
+ ```bash
371
+ # In hydn-ui directory
372
+ npm link
373
+
374
+ # In your test project
375
+ npm link @hyddenlabs/hydn-ui
376
+ ```
377
+
378
+ Or create a tarball:
379
+
380
+ ```bash
381
+ npm pack
382
+ # This creates hyddenlabs-hydn-ui-x.x.x.tgz
383
+ ```
384
+
385
+ 4. **Publish to npm**
386
+
387
+ ```bash
388
+ # Dry run (recommended first)
389
+ npm publish --dry-run
390
+
391
+ # Publish (public package)
392
+ npm publish --access public
393
+
394
+ # Or publish with a specific tag
395
+ npm publish --tag beta --access public
396
+ ```
397
+
398
+ 5. **Verify Publication**
399
+
400
+ - Check the package page: https://www.npmjs.com/package/@hyddenlabs/hydn-ui
401
+ - Test installation: `npm install @hyddenlabs/hydn-ui`
402
+
403
+ ### Automated Publishing (CI/CD)
404
+
405
+ The repository has a GitHub Actions workflow (`.github/workflows/publish.yml`) that handles:
406
+
407
+ 1. Running tests
408
+ 2. Building the library
409
+ 3. Versioning with GitVersion
410
+ 4. Publishing to npm
411
+ 5. Tagging releases
412
+
413
+ To trigger automated publishing, use the GitHub UI: **Actions โ†’ Publish โ†’ Run workflow**
414
+
415
+ ### Troubleshooting
416
+
417
+ **Build Fails:**
418
+
419
+ ```bash
420
+ rm -rf dist node_modules
421
+ npm install
422
+ npm run build
423
+ ```
424
+
425
+ **Permission Denied:**
426
+
427
+ ```bash
428
+ npm whoami
429
+ npm access ls-packages @hyddenlabs
430
+ ```
431
+
432
+ ### Post-Publish Checklist
433
+
434
+ - [ ] Verify package appears on npm
435
+ - [ ] Test installation in a fresh project
436
+ - [ ] Update CHANGELOG.md
437
+ - [ ] Create GitHub release with notes
438
+ - [ ] Announce release (if applicable)
439
+
440
+ ## CSS Class Validation
441
+
442
+ HYDN UI includes comprehensive CSS validation tools to ensure all Tailwind classes used in components are properly generated in the output CSS.
443
+
444
+ ### Why This Matters
445
+
446
+ When building a component library with Tailwind CSS, it's critical to ensure that:
447
+ - All classes used in components are actually generated in the final CSS
448
+ - No classes are accidentally misspelled or reference non-existent theme tokens
449
+ - The generated CSS file contains everything consumers need
450
+
451
+ ### Validation Methods
452
+
453
+ #### 1. Automated Audit Script (Recommended)
454
+
455
+ Run the comprehensive audit to check all components:
456
+
457
+ ```bash
458
+ npm run audit:css
459
+ ```
460
+
461
+ This script:
462
+ - โœ… Extracts all className usages from your components
463
+ - โœ… Validates them against the generated `dist/style.css`
464
+ - โœ… Reports missing classes with file locations
465
+ - โœ… Identifies dynamic/computed classes (like `z-[999]`)
466
+ - โœ… Filters out template literals and conditional logic
467
+
468
+ **Example Output:**
469
+ ```
470
+ ๐Ÿ” Auditing CSS classes...
471
+
472
+ ๐Ÿ“ Found 90 component files
473
+ ๐Ÿ“„ CSS file size: 69.41 KB
474
+
475
+ ๐ŸŽจ Total unique classes found: 177
476
+
477
+ โš ๏ธ Dynamic/computed classes (2):
478
+ - z-[999]
479
+ - min-w-[180px]
480
+
481
+ โœ… All classes found in generated CSS!
482
+ โœ… 176 classes validated successfully
483
+ ```
484
+
485
+ #### 2. CSS Validation Tests
486
+
487
+ Run the test suite that validates critical classes:
488
+
489
+ ```bash
490
+ npm run test:css
491
+ ```
492
+
493
+ This runs `tests/css-validation.test.ts` which:
494
+ - โœ… Checks for critical component classes
495
+ - โœ… Validates theme tokens (CSS custom properties)
496
+ - โœ… Ensures CSS file is not empty
497
+ - โœ… Integrates with CI/CD pipelines
498
+
499
+ #### 3. Full Test Suite
500
+
501
+ All component tests also implicitly validate CSS classes:
502
+
503
+ ```bash
504
+ npm test
505
+ ```
506
+
507
+ Since tests check for specific classes (e.g., `expect(button).toHaveClass('rounded-lg')`), they will fail if classes aren't generated.
508
+
509
+ ### Best Practices
510
+
511
+ **Run audit before publishing:**
512
+
513
+ ```bash
514
+ npm run audit:css && npm run build && npm test
515
+ ```
516
+
517
+ **Avoid dynamic class construction:**
518
+
519
+ ```tsx
520
+ // โŒ Bad - class might not be generated
521
+ const sizeClass = `w-${size}`;
522
+ <div className={sizeClass} />
523
+
524
+ // โœ… Good - explicit mapping
525
+ const sizeClasses = {
526
+ sm: 'w-4',
527
+ md: 'w-6',
528
+ lg: 'w-8'
529
+ };
530
+ <div className={sizeClasses[size]} />
531
+ ```
532
+
533
+ **CI/CD integration** - The GitHub Actions workflows automatically run CSS validation on every push and before publishing.
534
+
535
+ ### Validation Commands Summary
536
+
537
+ | Command | Purpose |
538
+ |---------|---------|
539
+ | `npm run audit:css` | Comprehensive class validation |
540
+ | `npm run test:css` | Quick CSS validation tests |
541
+ | `npm test` | Full test suite (includes CSS checks) |
542
+
543
+ ## Tech Stack
544
+
545
+ - **React 19** - UI library
546
+ - **TypeScript** - Type safety
547
+ - **tsup** - Library bundler
548
+ - **Vite** - Development server
549
+ - **Tailwind CSS** - Styling
550
+ - **React Router** - Client-side routing (showcase only)
551
+ - **Vitest** - Testing framework
552
+ - **Testing Library** - Component testing utilities
553
+ - **Tabler Icons** - Icon library
554
+
555
+ ## Contributing
556
+
557
+ 1. Fork the repository
558
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
559
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
560
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
561
+ 5. Open a Pull Request
562
+
563
+ ## License
564
+
565
+ This project is private and proprietary to HYDN Co.
566
+
567
+ ## Support
568
+
569
+ For questions and support, please contact the HYDN development team.