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 +46 -208
- package/dist/index.d.mts +2353 -877
- package/dist/index.d.ts +2353 -877
- package/dist/index.js +9466 -6604
- package/dist/index.mjs +9364 -6324
- package/dist/styles.css +56 -0
- package/package.json +18 -82
- package/scripts/check-metadata-props.js +324 -0
- package/scripts/check.js +267 -0
- package/scripts/copy-styles.js +20 -0
- package/scripts/copy-tokens.js +37 -0
- package/scripts/generate-metadata-stubs.js +183 -0
- package/scripts/init.js +26 -301
- package/scripts/split-component-metadata.js +128 -0
- package/scripts/tailwind.preset.cjs +121 -0
- package/scripts/themeConfig.js +24 -0
- package/scripts/tokens/base.json +7 -0
- package/scripts/tokens/palettes.json +78 -0
- package/scripts/tokens/themes/color/dark.json +8 -2
- package/scripts/tokens/themes/color/forest.json +31 -0
- package/scripts/tokens/themes/color/midnight.json +31 -0
- package/scripts/tokens/themes/color/ocean.json +31 -0
- package/scripts/tokens/themes/color/rose.json +31 -0
- package/scripts/tokens/themes/color/white.json +8 -2
- package/scripts/tokens/themes/custom/brand.json +26 -2
- package/scripts/tokens/themes/custom/minimal.json +41 -3
- package/scripts/tokens/themes/density/comfortable.json +13 -1
- package/scripts/tokens/themes/density/compact.json +13 -1
package/README.md
CHANGED
|
@@ -1,224 +1,62 @@
|
|
|
1
1
|
# shru-design-system
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
+
## Documentation
|
|
200
17
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
56
|
+
npm run dev
|
|
224
57
|
```
|
|
58
|
+
|
|
59
|
+
| Route | Purpose |
|
|
60
|
+
|-------|---------|
|
|
61
|
+
| `/gallery` | Component catalog + props panel |
|
|
62
|
+
| `/showcase` | Mini admin app (composed patterns) |
|