shru-design-system 0.0.9 → 0.1.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 +149 -96
- package/dist/index.d.mts +55 -0
- package/dist/index.d.ts +34 -1028
- package/dist/index.js +241 -7839
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +364 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +40 -78
- package/scripts/init.js +305 -0
- package/apps/design-system/styles/globals.css +0 -640
- package/dist/index.cjs +0 -8452
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1049
- package/scripts/build-css.js +0 -231
- package/scripts/copy-globals.js +0 -106
- package/scripts/copy-tokens.js +0 -62
- package/src/tokens/base.json +0 -161
- package/src/tokens/palettes.json +0 -294
- package/src/tokens/themes/animation/brisk.json +0 -14
- package/src/tokens/themes/animation/gentle.json +0 -14
- package/src/tokens/themes/color/dark.json +0 -38
- package/src/tokens/themes/color/white.json +0 -38
- package/src/tokens/themes/custom/brand.json +0 -13
- package/src/tokens/themes/custom/minimal.json +0 -16
- package/src/tokens/themes/density/comfortable.json +0 -19
- package/src/tokens/themes/density/compact.json +0 -19
- package/src/tokens/themes/shape/sharp.json +0 -11
- package/src/tokens/themes/shape/smooth.json +0 -11
- package/src/tokens/themes/typography/sans.json +0 -25
- package/src/tokens/themes/typography/serif.json +0 -25
package/README.md
CHANGED
|
@@ -1,130 +1,183 @@
|
|
|
1
|
-
#
|
|
1
|
+
# shru-design-system
|
|
2
2
|
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
A design system with 72+ reusable components and a theme management library. Includes both a Next.js showcase application and publishable npm libraries.
|
|
8
|
-
|
|
9
|
-
## Key Features
|
|
10
|
-
|
|
11
|
-
### Design System Components
|
|
12
|
-
- **72+ Components** organized by category (atoms, molecules, layout, primitives)
|
|
13
|
-
- **Radix UI Based** - Accessible, unstyled primitives with custom styling
|
|
14
|
-
- **Tailwind CSS** - Utility-first styling with CSS variables
|
|
15
|
-
- **TypeScript** - Full type definitions for all components
|
|
16
|
-
- **Component Showcases** - Live, interactive examples for every component
|
|
17
|
-
|
|
18
|
-
### Theme System
|
|
19
|
-
- **Token-based Theming** with multi-category support (color, typography, shape, density, animation)
|
|
20
|
-
- **Reusable Library** - Theme toggle component and utilities published as `shru-design-system`
|
|
21
|
-
- **Zero CSS Imports** - CSS variables generated and injected automatically
|
|
22
|
-
- **Dynamic Theme Switching** - Runtime theme composition and application
|
|
23
|
-
- **Modular Architecture** - Clean separation of UI, hooks, config, and utilities
|
|
24
|
-
|
|
25
|
-
### Architecture
|
|
26
|
-
- **Module-based Structure** - Clean separation of UI, hooks, config, and utils
|
|
27
|
-
- **Centralized Exports** - Clean import paths with `index.ts` files
|
|
28
|
-
- **Atomic Design** - Components organized by complexity and purpose
|
|
3
|
+
A React component library with atoms and molecules built on Radix UI and Tailwind CSS.
|
|
29
4
|
|
|
30
5
|
## Installation
|
|
31
6
|
|
|
32
7
|
```bash
|
|
33
8
|
npm install shru-design-system
|
|
34
|
-
# or
|
|
35
|
-
pnpm add shru-design-system
|
|
36
9
|
```
|
|
37
10
|
|
|
38
|
-
## Quick
|
|
11
|
+
## Quick Setup
|
|
39
12
|
|
|
40
|
-
|
|
41
|
-
// 1. Import CSS (required)
|
|
42
|
-
import '@shru/design-system/styles'
|
|
13
|
+
After installation, run the setup script to configure Tailwind CSS:
|
|
43
14
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function App() {
|
|
48
|
-
return <ThemeToggle position="bottom-right" />
|
|
49
|
-
}
|
|
15
|
+
```bash
|
|
16
|
+
npx shru-design-system-init
|
|
50
17
|
```
|
|
51
18
|
|
|
52
|
-
|
|
19
|
+
Or it will run automatically after `npm install` (you can skip this step if it already ran).
|
|
53
20
|
|
|
54
|
-
|
|
21
|
+
## Manual Setup
|
|
55
22
|
|
|
56
|
-
|
|
23
|
+
If you prefer to set up manually or the automatic setup didn't work:
|
|
57
24
|
|
|
58
|
-
|
|
59
|
-
# Build the library
|
|
60
|
-
npm run build:lib
|
|
61
|
-
# Generates: dist/index.js (ESM), dist/index.cjs (CJS), dist/index.d.ts (types)
|
|
25
|
+
### 1. Install Tailwind CSS
|
|
62
26
|
|
|
63
|
-
|
|
64
|
-
npm
|
|
65
|
-
|
|
27
|
+
```bash
|
|
28
|
+
npm install -D tailwindcss postcss autoprefixer
|
|
29
|
+
npx tailwindcss init -p
|
|
66
30
|
```
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
32
|
+
### 2. Configure Tailwind
|
|
33
|
+
|
|
34
|
+
Update `tailwind.config.js`:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
export default {
|
|
38
|
+
content: [
|
|
39
|
+
"./index.html",
|
|
40
|
+
"./src/**/*.{js,ts,jsx,tsx}",
|
|
41
|
+
"./node_modules/shru-design-system/dist/**/*.{js,mjs}",
|
|
42
|
+
],
|
|
43
|
+
theme: {
|
|
44
|
+
extend: {
|
|
45
|
+
colors: {
|
|
46
|
+
background: "hsl(var(--background))",
|
|
47
|
+
foreground: "hsl(var(--foreground))",
|
|
48
|
+
primary: {
|
|
49
|
+
DEFAULT: "hsl(var(--primary))",
|
|
50
|
+
foreground: "hsl(var(--primary-foreground))",
|
|
51
|
+
},
|
|
52
|
+
secondary: {
|
|
53
|
+
DEFAULT: "hsl(var(--secondary))",
|
|
54
|
+
foreground: "hsl(var(--secondary-foreground))",
|
|
55
|
+
},
|
|
56
|
+
destructive: {
|
|
57
|
+
DEFAULT: "hsl(var(--destructive))",
|
|
58
|
+
foreground: "hsl(var(--destructive-foreground))",
|
|
59
|
+
},
|
|
60
|
+
muted: {
|
|
61
|
+
DEFAULT: "hsl(var(--muted))",
|
|
62
|
+
foreground: "hsl(var(--muted-foreground))",
|
|
63
|
+
},
|
|
64
|
+
accent: {
|
|
65
|
+
DEFAULT: "hsl(var(--accent))",
|
|
66
|
+
foreground: "hsl(var(--accent-foreground))",
|
|
67
|
+
},
|
|
68
|
+
popover: {
|
|
69
|
+
DEFAULT: "hsl(var(--popover))",
|
|
70
|
+
foreground: "hsl(var(--popover-foreground))",
|
|
71
|
+
},
|
|
72
|
+
border: "hsl(var(--border))",
|
|
73
|
+
input: "hsl(var(--input))",
|
|
74
|
+
ring: "hsl(var(--ring))",
|
|
75
|
+
},
|
|
76
|
+
borderRadius: {
|
|
77
|
+
lg: "var(--radius)",
|
|
78
|
+
md: "calc(var(--radius) - 2px)",
|
|
79
|
+
sm: "calc(var(--radius) - 4px)",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
plugins: [],
|
|
84
|
+
}
|
|
70
85
|
```
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
|
|
87
|
+
### 3. Add CSS Variables
|
|
88
|
+
|
|
89
|
+
Create or update `src/index.css`:
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
@tailwind base;
|
|
93
|
+
@tailwind components;
|
|
94
|
+
@tailwind utilities;
|
|
95
|
+
|
|
96
|
+
@layer base {
|
|
97
|
+
:root {
|
|
98
|
+
--background: 0 0% 100%;
|
|
99
|
+
--foreground: 222.2 84% 4.9%;
|
|
100
|
+
--primary: 222.2 47.4% 11.2%;
|
|
101
|
+
--primary-foreground: 210 40% 98%;
|
|
102
|
+
--secondary: 210 40% 96.1%;
|
|
103
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
104
|
+
--destructive: 0 84.2% 60.2%;
|
|
105
|
+
--destructive-foreground: 210 40% 98%;
|
|
106
|
+
--muted: 210 40% 96.1%;
|
|
107
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
108
|
+
--accent: 210 40% 96.1%;
|
|
109
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
110
|
+
--popover: 0 0% 100%;
|
|
111
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
112
|
+
--border: 214.3 31.8% 91.4%;
|
|
113
|
+
--input: 214.3 31.8% 91.4%;
|
|
114
|
+
--ring: 222.2 84% 4.9%;
|
|
115
|
+
--radius: 0.5rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
* {
|
|
119
|
+
border-color: hsl(var(--border));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
body {
|
|
123
|
+
background-color: hsl(var(--background));
|
|
124
|
+
color: hsl(var(--foreground));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
85
127
|
```
|
|
86
128
|
|
|
87
|
-
|
|
129
|
+
### 4. Import CSS
|
|
88
130
|
|
|
89
|
-
|
|
90
|
-
- **[USAGE.md](./USAGE.md)** - Complete usage guide: setup, theme toggle, components, how it works
|
|
91
|
-
- **[CURSOR_PROMPT.md](./CURSOR_PROMPT.md)** - Ready-to-use Cursor prompt for integrating the library
|
|
131
|
+
Import the CSS file in your entry point (e.g., `src/main.tsx`):
|
|
92
132
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
133
|
+
```tsx
|
|
134
|
+
import './index.css'
|
|
135
|
+
```
|
|
96
136
|
|
|
97
|
-
|
|
98
|
-
- **[CONTRIBUTING.md](./CONTRIBUTING.md)** - Contribution guidelines and development workflow
|
|
99
|
-
- **[apps/design-system/ARCHITECTURE.md](./apps/design-system/ARCHITECTURE.md)** - Architecture overview
|
|
100
|
-
- **[apps/design-system/src/design-system/components/README.md](./apps/design-system/src/design-system/components/README.md)** - Adding components
|
|
101
|
-
- **[apps/design-system/src/design-system/themes/README.md](./apps/design-system/src/design-system/themes/README.md)** - Theme system internals
|
|
137
|
+
## Usage
|
|
102
138
|
|
|
103
|
-
|
|
139
|
+
```tsx
|
|
140
|
+
import { Button, Badge, Modal, Select } from 'shru-design-system'
|
|
104
141
|
|
|
105
|
-
|
|
142
|
+
function App() {
|
|
143
|
+
return (
|
|
144
|
+
<div>
|
|
145
|
+
<Button variant="default">Click me</Button>
|
|
146
|
+
<Badge>New</Badge>
|
|
147
|
+
|
|
148
|
+
<Modal>
|
|
149
|
+
<ModalTrigger asChild>
|
|
150
|
+
<Button>Open Modal</Button>
|
|
151
|
+
</ModalTrigger>
|
|
152
|
+
<ModalContent>
|
|
153
|
+
<ModalHeader>
|
|
154
|
+
<ModalTitle>Hello</ModalTitle>
|
|
155
|
+
<ModalDescription>This is a modal</ModalDescription>
|
|
156
|
+
</ModalHeader>
|
|
157
|
+
</ModalContent>
|
|
158
|
+
</Modal>
|
|
159
|
+
</div>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
```
|
|
106
163
|
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
git clone <repo-url>
|
|
110
|
-
npm install
|
|
111
|
-
```
|
|
164
|
+
## Components
|
|
112
165
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```
|
|
166
|
+
### Atoms
|
|
167
|
+
- **Button** - Versatile button with multiple variants and sizes
|
|
168
|
+
- **Badge** - Small status indicators
|
|
117
169
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
- **Library changes**: Edit `src/`, then run `npm run build:lib`
|
|
170
|
+
### Molecules
|
|
171
|
+
- **Modal** - Dialog component with overlay
|
|
172
|
+
- **Select** - Dropdown select component
|
|
122
173
|
|
|
123
|
-
|
|
174
|
+
## Peer Dependencies
|
|
124
175
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
176
|
+
Make sure to install these peer dependencies:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm install @radix-ui/react-slot @radix-ui/react-dialog @radix-ui/react-select class-variance-authority clsx tailwind-merge lucide-react
|
|
180
|
+
```
|
|
128
181
|
|
|
129
182
|
## License
|
|
130
183
|
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
6
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
7
|
+
|
|
8
|
+
declare const buttonVariants: (props?: ({
|
|
9
|
+
readonly variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
10
|
+
readonly size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
11
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
12
|
+
declare const Button: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<(props?: ({
|
|
13
|
+
readonly variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
14
|
+
readonly size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
15
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
16
|
+
asChild?: boolean;
|
|
17
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
|
|
19
|
+
declare const badgeVariants: (props?: ({
|
|
20
|
+
readonly variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
|
|
21
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
22
|
+
declare const Badge: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLSpanElement> & React.HTMLAttributes<HTMLSpanElement> & VariantProps<(props?: ({
|
|
23
|
+
readonly variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
|
|
24
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
}, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
27
|
+
|
|
28
|
+
declare function Modal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
29
|
+
declare function ModalTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
|
|
30
|
+
declare function ModalPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): react_jsx_runtime.JSX.Element;
|
|
31
|
+
declare function ModalClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime.JSX.Element;
|
|
32
|
+
declare function ModalOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): react_jsx_runtime.JSX.Element;
|
|
33
|
+
declare function ModalContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
34
|
+
showCloseButton?: boolean;
|
|
35
|
+
}): react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare function ModalHeader({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
37
|
+
declare function ModalFooter({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
38
|
+
declare function ModalTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare function ModalDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
40
|
+
|
|
41
|
+
declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
42
|
+
declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): react_jsx_runtime.JSX.Element;
|
|
43
|
+
declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): react_jsx_runtime.JSX.Element;
|
|
44
|
+
declare const selectTriggerSizes: readonly ["sm", "default"];
|
|
45
|
+
declare function SelectTrigger({ className, size, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
46
|
+
size?: typeof selectTriggerSizes[number];
|
|
47
|
+
}): react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare function SelectContent({ className, children, position, align, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
49
|
+
declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): react_jsx_runtime.JSX.Element;
|
|
50
|
+
declare function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>): react_jsx_runtime.JSX.Element;
|
|
51
|
+
declare function SelectSeparator({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Separator>): react_jsx_runtime.JSX.Element;
|
|
52
|
+
declare function SelectScrollUpButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>): react_jsx_runtime.JSX.Element;
|
|
53
|
+
declare function SelectScrollDownButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>): react_jsx_runtime.JSX.Element;
|
|
54
|
+
|
|
55
|
+
export { Badge, Button, Modal, ModalClose, ModalContent, ModalDescription, ModalFooter, ModalHeader, ModalOverlay, ModalPortal, ModalTitle, ModalTrigger, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, badgeVariants, buttonVariants };
|