shru-design-system 0.5.4 → 0.6.1

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,224 +1,62 @@
1
1
  # shru-design-system
2
2
 
3
- A React component library with atoms and molecules built on Radix UI and Tailwind CSS, featuring a dynamic theme system.
4
-
5
- ## Project Structure
6
-
7
- ### Root Files
8
-
9
- - **`package.json`** - Package configuration, dependencies, and scripts
10
- - **`tsconfig.json`** - TypeScript configuration
11
- - **`tsup.config.ts`** - Build configuration for bundling (ESM/CJS)
12
- - **`tailwind.config.js`** - Tailwind CSS configuration (for library development)
13
- - **`postcss.config.js`** - PostCSS configuration (for library development)
14
- - **`.gitignore`** - Git ignore rules
15
-
16
- ### Source Code (`src/`)
17
-
18
- - **`src/index.ts`** - Main entry point, exports all components and utilities
19
- - **`src/utils.ts`** - Utility functions (cn helper for class merging)
20
-
21
- #### Atoms (`src/atoms/`)
22
- Basic UI building blocks:
23
- - **`Alert.tsx`** - Alert component for notifications
24
- - **`Avatar.tsx`** - Avatar component with image and fallback
25
- - **`Badge.tsx`** - Badge component for labels and tags
26
- - **`Button.tsx`** - Button component with variants and sizes
27
- - **`Checkbox.tsx`** - Checkbox input component
28
- - **`Empty.tsx`** - Empty state component
29
- - **`ErrorBoundary.tsx`** - Error boundary component
30
- - **`Image.tsx`** - Image component with loading states
31
- - **`InputOTP.tsx`** - OTP input component
32
- - **`Kbd.tsx`** - Keyboard key display component
33
- - **`Label.tsx`** - Form label component
34
- - **`Progress.tsx`** - Progress bar component
35
- - **`Radio.tsx`** - Radio button group component
36
- - **`Separator.tsx`** - Horizontal/vertical divider component
37
- - **`Skeleton.tsx`** - Skeleton loading component
38
- - **`SkeletonGrid.tsx`** - Grid layout skeleton component
39
- - **`SkeletonText.tsx`** - Text lines skeleton component
40
- - **`Slider.tsx`** - Slider input component
41
- - **`Spinner.tsx`** - Loading spinner component
42
- - **`Switch.tsx`** - Toggle switch component
43
- - **`Text.tsx`** - Typography text component
44
- - **`TextInput.tsx`** - Text input field component
45
- - **`Textarea.tsx`** - Multi-line text input component
46
- - **`Toggle.tsx`** - Toggle button component
47
- - **`Upload.tsx`** - File upload component
48
-
49
- #### Molecules (`src/molecules/`)
50
- Composite components:
51
- - **`Accordion.tsx`** - Collapsible accordion component
52
- - **`AlertDialog.tsx`** - Alert dialog component
53
- - **`Breadcrumb.tsx`** - Breadcrumb navigation component
54
- - **`Calendar.tsx`** - Calendar date picker component
55
- - **`Carousel.tsx`** - Image/content carousel component
56
- - **`Chart.tsx`** - Chart component (Recharts wrapper)
57
- - **`Collapsible.tsx`** - Collapsible content component
58
- - **`Command.tsx`** - Command palette component
59
- - **`ConfirmModal.tsx`** - Confirmation modal component
60
- - **`ContextMenu.tsx`** - Right-click context menu
61
- - **`CopyButton.tsx`** - Copy to clipboard button
62
- - **`Drawer.tsx`** - Drawer/side panel component
63
- - **`DropdownMenu.tsx`** - Dropdown menu component
64
- - **`Field.tsx`** - Form field wrapper component
65
- - **`Form.tsx`** - Form component (react-hook-form)
66
- - **`FormInput.tsx`** - Form input with label and error
67
- - **`FormModal.tsx`** - Modal with form integration
68
- - **`HistoryControlButtons.tsx`** - Browser history controls
69
- - **`HoverCard.tsx`** - Hover card component
70
- - **`InfoBanner.tsx`** - Information banner component
71
- - **`InlineEdit.tsx`** - Inline editing component
72
- - **`InputGroup.tsx`** - Input with addons/buttons
73
- - **`SearchInput.tsx`** - Search input with debounce and clearable
74
- - **`Menubar.tsx`** - Menu bar component
75
- - **`Modal.tsx`** - Modal dialog component
76
- - **`NavigationMenu.tsx`** - Navigation menu component
77
- - **`Pagination.tsx`** - Pagination component
78
- - **`Popover.tsx`** - Popover component
79
- - **`Select.tsx`** - Dropdown select component
80
- - **`Sheet.tsx`** - Sheet/side panel component
81
- - **`Snackbar.tsx`** - Snackbar notification component
82
- - **`StatusText.tsx`** - Status text with icons
83
- - **`Stepper.tsx`** - Step indicator component
84
- - **`Tabs.tsx`** - Tabs component
85
- - **`Toast.tsx`** - Toast notification component
86
- - **`Toaster.tsx`** - Toast provider component
87
- - **`ToggleGroup.tsx`** - Toggle group component
88
- - **`Tooltip.tsx`** - Tooltip component
89
- - **`TriggerModal.tsx`** - Modal with trigger component
90
-
91
- #### Layout (`src/layout/`)
92
- Layout and container components:
93
- - **`AspectRatio.tsx`** - Aspect ratio container
94
- - **`Box.tsx`** - Generic box container
95
- - **`Card.tsx`** - Card container component
96
- - **`CollapsiblePanel.tsx`** - Collapsible panel component
97
- - **`Container.tsx`** - Responsive container component
98
- - **`EmptyScreen.tsx`** - Empty screen component
99
- - **`Footer.tsx`** - Footer component
100
- - **`Grid.tsx`** - Grid layout component
101
- - **`Header.tsx`** - Header component
102
- - **`List.tsx`** - Enhanced list component with search, grid/list views, empty/loading states
103
- - **`Resizable.tsx`** - Resizable panels component
104
- - **`ResizeContainer.tsx`** - Resizable container wrapper
105
- - **`ScrollArea.tsx`** - Scrollable area component
106
- - **`Sidebar.tsx`** - Sidebar navigation component
107
- - **`Stack.tsx`** - Stack layout component
108
- - **`Table.tsx`** - Table component
109
-
110
- #### Theme System (`src/themes/`)
111
- - **`themeConfig.ts`** - Theme configuration and category definitions
112
- - **`themeUtils.ts`** - Theme utility functions (loading, merging, flattening)
113
- - **`applyThemeSync.ts`** - Synchronous theme application (prevents FOUC)
114
- - **`useTheme.tsx`** - React hook for theme management
115
- - **`ui/ThemeToggle/`** - Theme toggle UI component and related files
116
- - **`ThemeToggle.tsx`** - Main theme toggle component
117
- - **`useThemeToggle.ts`** - Hook for theme toggle UI state
118
- - **`themeToggleConfig.ts`** - Theme toggle configuration
119
- - **`themeToggleUtils.ts`** - Theme toggle utility functions
120
- - **`index.ts`** - Theme toggle exports
121
-
122
- ### Build Output (`dist/`)
123
-
124
- - **`index.js`** - CommonJS bundle
125
- - **`index.mjs`** - ESM bundle
126
- - **`index.d.ts`** - TypeScript declarations (CJS)
127
- - **`index.d.mts`** - TypeScript declarations (ESM)
128
-
129
- ### Scripts (`scripts/`)
130
-
131
- Setup and runtime scripts:
132
- - **`init.js`** - Postinstall script that sets up Tailwind, PostCSS, and token files in consuming apps
133
- - **`apply-theme-sync.js`** - Standalone synchronous theme script (injected into HTML)
134
- - **`applyThemeSync.js`** - Synchronous theme application module
135
- - **`themeConfig.js`** - Theme configuration (JavaScript version)
136
- - **`themeUtils.js`** - Theme utilities (JavaScript version)
137
- - **`tokens/`** - Default token files (copied to consuming apps)
138
- - **`base.json`** - Base design tokens
139
- - **`palettes.json`** - Color palette definitions
140
- - **`themes/`** - Theme category files
141
- - **`color/`** - Color theme variants (white, dark)
142
- - **`typography/`** - Typography themes (sans, serif)
143
- - **`shape/`** - Shape themes (smooth, sharp)
144
- - **`density/`** - Density themes (comfortable, compact)
145
- - **`animation/`** - Animation themes (gentle, brisk)
146
- - **`custom/`** - Custom theme examples (brand, minimal)
147
-
148
- ### Test Application (`test/`)
149
-
150
- Local test environment for developing and testing the library:
151
- - **`package.json`** - Test app dependencies
152
- - **`vite.config.ts`** - Vite configuration for test app
153
- - **`index.html`** - Test app HTML entry point
154
- - **`src/App.tsx`** - Test app component showcasing all library components
155
- - **`src/main.tsx`** - Test app entry point
156
- - **`src/index.css`** - Test app global styles
157
- - **`tailwind.config.js`** - Tailwind config for test app
158
- - **`postcss.config.js`** - PostCSS config for test app
159
- - **`public/tokens/`** - Token files for testing (generated by init script)
160
- - **`dist/`** - Vite build output (ignored in git)
161
-
162
- ## Usage
163
-
164
- Install:
3
+ React component library **98 components**, multi-axis token themes, Tailwind + CVA.
4
+
165
5
  ```bash
166
6
  npm install shru-design-system
7
+ npx shru-design-system-init
167
8
  ```
168
9
 
169
- ### Theme setup (new flow)
170
- - Tokens are embedded in the bundle, so the theme system works out-of-the-box (no `/public/tokens` required).
171
- - If you want to self-host tokens (for custom themes or CDN):
172
- - Set `window.__THEME_TOKENS_BASE__ = "/tokens"` (or your URL) before the app renders, or set `DESIGN_SYSTEM_TOKENS_BASE` env at build/runtime.
173
- - Serve token JSONs at `<base>/base.json`, `<base>/palettes.json`, `<base>/themes/<category>/<theme>.json`.
174
- - Blocking HTML injection is removed; the runtime/applyThemeSync appends `#dynamic-theme` at the end of `<head>` so its CSS vars override compiled CSS.
10
+ Published: `dist/` components, `styles.css`, Tailwind preset.
175
11
 
176
- Optional token copy:
177
- ```bash
178
- npx shru-design-system-init # copies tokens into public/tokens if you want static hosting
179
- ```
12
+ **Prop-level API:** TypeScript `XxxProps` · local dev: `npm run dev` → `/gallery`
180
13
 
181
- Import components:
182
- ```tsx
183
- import {
184
- Button,
185
- Modal,
186
- ThemeToggle,
187
- Alert,
188
- Avatar,
189
- Accordion,
190
- Calendar,
191
- Carousel,
192
- Form,
193
- Field,
194
- // ... and many more
195
- registerThemeFromFile
196
- } from 'shru-design-system'
197
- ```
14
+ ---
198
15
 
199
- ### Available Components
16
+ ## Documentation
200
17
 
201
- The library includes 67+ components organized into:
202
- - **Atoms** (23): Basic UI elements like Button, Input, Badge, etc.
203
- - **Molecules** (35): Composite components like Modal, Form, Calendar, etc.
204
- - **Layout** (16): Layout components like Grid, Stack, Sidebar, etc.
18
+ | Audience | Start here |
19
+ |----------|------------|
20
+ | **Consumer** install & use in your app | [docs/use/INSTALL.md](./docs/use/INSTALL.md) |
21
+ | **Contributor** change this repo | [docs/build/CONTRIBUTING.md](./docs/build/CONTRIBUTING.md) |
22
+ | **Architecture** — system structure | [docs/reference/ARCHITECTURE.md](./docs/reference/ARCHITECTURE.md) |
205
23
 
206
- Registering themes:
207
- - Add a custom theme file at your token base, e.g. `/tokens/themes/custom/my-brand.json`.
208
- - Call at runtime (after page load):
209
- ```ts
210
- registerThemeFromFile('custom', 'my-brand', '/tokens/themes/custom/my-brand.json')
211
- ```
212
- The theme toggle will pick it up automatically.
24
+ ### Consumers — `docs/use/`
213
25
 
214
- ## Development
26
+ | Doc | Covers |
27
+ |-----|--------|
28
+ | [Install](./docs/use/INSTALL.md) | Peers, init, styles, Tailwind, first component |
29
+ | [Theming](./docs/use/THEMING.md) | Presets, `useTheme`, `applyPreset`, ThemeToggle |
30
+ | [Recipes](./docs/use/RECIPES.md) | App shell, TreeView, forms, modals |
31
+ | [Features](./docs/use/FEATURES.md) | Overlays, toasts, forms, input API contracts |
215
32
 
216
- Build the library:
217
- ```bash
218
- npm run build
219
- ```
33
+ ### Contributors — `docs/build/`
34
+
35
+ | Doc | Covers |
36
+ |-----|--------|
37
+ | [Contributing](./docs/build/CONTRIBUTING.md) | Layout, conventions, tokens, checks |
38
+ | [Components](./docs/build/COMPONENTS.md) | Add / update component checklist |
39
+ | [Gallery](./docs/build/GALLERY.md) | Metadata pipeline, wrappers |
40
+ | [Release](./docs/build/RELEASE.md) | `npm run check`, build, publish |
41
+
42
+ ### Architecture — `docs/reference/`
43
+
44
+ | Doc | Covers |
45
+ |-----|--------|
46
+ | [Architecture](./docs/reference/ARCHITECTURE.md) | Repo map, build pipeline, check gates |
47
+ | [Components](./docs/reference/COMPONENTS.md) | 98 shipped spec |
48
+ | [Component graph](./docs/reference/COMPONENT_GRAPH.md) | Composition flowcharts |
49
+ | [Tokens](./docs/reference/TOKENS.md) | Token JSON layout, pipeline |
50
+
51
+ ---
52
+
53
+ ## Local preview
220
54
 
221
- Test locally:
222
55
  ```bash
223
- cd test && npm run dev
56
+ npm run dev
224
57
  ```
58
+
59
+ | Route | Purpose |
60
+ |-------|---------|
61
+ | `/gallery` | Component catalog + props panel |
62
+ | `/showcase` | Mini admin app (composed patterns) |