@constructive-io/ui 0.1.0 → 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 +236 -0
- package/dist/components/card.d.ts +1 -1
- package/package.json +13 -12
package/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# @constructive-io/ui
|
|
2
|
+
|
|
3
|
+
A modern React component library built on [Base UI](https://base-ui.com/) primitives and [Tailwind CSS v4](https://tailwindcss.com/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @constructive-io/ui
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @constructive-io/ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer Dependencies
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @base-ui/react lucide-react react react-dom
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Optional peer dependencies (required for specific components):
|
|
20
|
+
|
|
21
|
+
| Package | Components |
|
|
22
|
+
|---------|------------|
|
|
23
|
+
| `motion` | Stack, animations |
|
|
24
|
+
| `@use-gesture/react` | Stack gestures |
|
|
25
|
+
| `sonner` | Toast |
|
|
26
|
+
| `vaul` | Drawer |
|
|
27
|
+
| `cmdk` | Command |
|
|
28
|
+
| `react-hook-form` | Form |
|
|
29
|
+
| `react-aria-components` | Calendar |
|
|
30
|
+
| `react-resizable-panels` | Resizable |
|
|
31
|
+
|
|
32
|
+
## Setup
|
|
33
|
+
|
|
34
|
+
### 1. Configure Tailwind CSS v4
|
|
35
|
+
|
|
36
|
+
Add the `@source` directive to scan the package for Tailwind classes:
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
/* app.css or globals.css */
|
|
40
|
+
@import "tailwindcss";
|
|
41
|
+
|
|
42
|
+
/* Required: Tell Tailwind to scan the UI package */
|
|
43
|
+
@source "../node_modules/@constructive-io";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Add CSS Variables
|
|
47
|
+
|
|
48
|
+
Add the design tokens to your CSS. You can import the full theme or define your own:
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
@import "tailwindcss";
|
|
52
|
+
@source "../node_modules/@constructive-io";
|
|
53
|
+
|
|
54
|
+
@custom-variant dark (&:is(.dark *));
|
|
55
|
+
|
|
56
|
+
:root {
|
|
57
|
+
--background: oklch(1 0 0);
|
|
58
|
+
--foreground: oklch(0.3211 0 0);
|
|
59
|
+
--card: oklch(1 0 0);
|
|
60
|
+
--card-foreground: oklch(0.3211 0 0);
|
|
61
|
+
--popover: oklch(1 0 0);
|
|
62
|
+
--popover-foreground: oklch(0.3211 0 0);
|
|
63
|
+
--primary: oklch(0.688 0.1754 245.6151);
|
|
64
|
+
--primary-foreground: oklch(0.979 0.021 166.113);
|
|
65
|
+
--secondary: oklch(0.967 0.001 286.375);
|
|
66
|
+
--secondary-foreground: oklch(0.21 0.006 285.885);
|
|
67
|
+
--muted: oklch(0.967 0.001 286.375);
|
|
68
|
+
--muted-foreground: oklch(0.552 0.016 285.938);
|
|
69
|
+
--accent: oklch(0.967 0.001 286.375);
|
|
70
|
+
--accent-foreground: oklch(0.21 0.006 285.885);
|
|
71
|
+
--destructive: oklch(0.55 0.2 25);
|
|
72
|
+
--destructive-foreground: oklch(0.985 0 0);
|
|
73
|
+
--border: oklch(0.92 0.004 286.32);
|
|
74
|
+
--input: oklch(0.871 0.006 286.286);
|
|
75
|
+
--ring: oklch(0.871 0.006 286.286);
|
|
76
|
+
--radius: 0.5rem;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@theme inline {
|
|
80
|
+
--color-background: var(--background);
|
|
81
|
+
--color-foreground: var(--foreground);
|
|
82
|
+
--color-card: var(--card);
|
|
83
|
+
--color-card-foreground: var(--card-foreground);
|
|
84
|
+
--color-popover: var(--popover);
|
|
85
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
86
|
+
--color-primary: var(--primary);
|
|
87
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
88
|
+
--color-secondary: var(--secondary);
|
|
89
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
90
|
+
--color-muted: var(--muted);
|
|
91
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
92
|
+
--color-accent: var(--accent);
|
|
93
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
94
|
+
--color-destructive: var(--destructive);
|
|
95
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
96
|
+
--color-border: var(--border);
|
|
97
|
+
--color-input: var(--input);
|
|
98
|
+
--color-ring: var(--ring);
|
|
99
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
100
|
+
--radius-md: var(--radius);
|
|
101
|
+
--radius-lg: calc(var(--radius) + 2px);
|
|
102
|
+
--radius-xl: calc(var(--radius) + 6px);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@layer base {
|
|
106
|
+
* {
|
|
107
|
+
@apply border-border/60 outline-ring/50;
|
|
108
|
+
}
|
|
109
|
+
body {
|
|
110
|
+
@apply bg-background text-foreground;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Usage
|
|
116
|
+
|
|
117
|
+
Import components individually for tree-shaking:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { Button } from '@constructive-io/ui/button';
|
|
121
|
+
import { Card, CardHeader, CardTitle, CardContent } from '@constructive-io/ui/card';
|
|
122
|
+
import { Input } from '@constructive-io/ui/input';
|
|
123
|
+
|
|
124
|
+
function App() {
|
|
125
|
+
return (
|
|
126
|
+
<Card>
|
|
127
|
+
<CardHeader>
|
|
128
|
+
<CardTitle>Sign In</CardTitle>
|
|
129
|
+
</CardHeader>
|
|
130
|
+
<CardContent className="space-y-4">
|
|
131
|
+
<Input placeholder="Email" type="email" />
|
|
132
|
+
<Button>Continue</Button>
|
|
133
|
+
</CardContent>
|
|
134
|
+
</Card>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Components
|
|
140
|
+
|
|
141
|
+
### Layout
|
|
142
|
+
- Card, Separator, Tabs, Collapsible, ScrollArea, Resizable
|
|
143
|
+
|
|
144
|
+
### Forms
|
|
145
|
+
- Button, Input, Textarea, Checkbox, Switch, Select, RadioGroup, Label, Progress
|
|
146
|
+
|
|
147
|
+
### Feedback
|
|
148
|
+
- Alert, Badge, Skeleton, Toast
|
|
149
|
+
|
|
150
|
+
### Overlay
|
|
151
|
+
- Dialog, AlertDialog, Sheet, Drawer, Popover, Tooltip, DropdownMenu
|
|
152
|
+
|
|
153
|
+
### Data
|
|
154
|
+
- Table, Pagination, Avatar, Breadcrumb
|
|
155
|
+
|
|
156
|
+
### Advanced
|
|
157
|
+
- Command, Combobox, Autocomplete, MultiSelect, Stack, Calendar
|
|
158
|
+
|
|
159
|
+
## Variants
|
|
160
|
+
|
|
161
|
+
Components use [CVA](https://cva.style/) for variant management:
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
// Button variants
|
|
165
|
+
<Button variant="default">Default</Button>
|
|
166
|
+
<Button variant="secondary">Secondary</Button>
|
|
167
|
+
<Button variant="outline">Outline</Button>
|
|
168
|
+
<Button variant="ghost">Ghost</Button>
|
|
169
|
+
<Button variant="destructive">Destructive</Button>
|
|
170
|
+
|
|
171
|
+
// Button sizes
|
|
172
|
+
<Button size="sm">Small</Button>
|
|
173
|
+
<Button size="default">Default</Button>
|
|
174
|
+
<Button size="lg">Large</Button>
|
|
175
|
+
|
|
176
|
+
// Card variants
|
|
177
|
+
<Card variant="default">Default shadow</Card>
|
|
178
|
+
<Card variant="elevated">Prominent shadow</Card>
|
|
179
|
+
<Card variant="flat">No shadow</Card>
|
|
180
|
+
<Card variant="interactive">Hover lift effect</Card>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Dark Mode
|
|
184
|
+
|
|
185
|
+
Add the `dark` class to enable dark mode:
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
<html className="dark">
|
|
189
|
+
{/* Components automatically use dark theme */}
|
|
190
|
+
</html>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## TypeScript
|
|
194
|
+
|
|
195
|
+
Full TypeScript support with exported types:
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import type { ButtonProps } from '@constructive-io/ui/button';
|
|
199
|
+
|
|
200
|
+
const MyButton = (props: ButtonProps) => <Button {...props} />;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Styling
|
|
204
|
+
|
|
205
|
+
All components use `data-slot` attributes for styling hooks:
|
|
206
|
+
|
|
207
|
+
```css
|
|
208
|
+
/* Target specific component parts */
|
|
209
|
+
[data-slot="card-header"] {
|
|
210
|
+
/* custom styles */
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
[data-slot="button"] {
|
|
214
|
+
/* custom styles */
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Development
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Install dependencies
|
|
222
|
+
pnpm install
|
|
223
|
+
|
|
224
|
+
# Run Storybook
|
|
225
|
+
pnpm sb
|
|
226
|
+
|
|
227
|
+
# Build package
|
|
228
|
+
pnpm build
|
|
229
|
+
|
|
230
|
+
# Type check
|
|
231
|
+
pnpm lint:types
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
MIT
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
|
|
6
6
|
declare const cardVariants: (props?: ({
|
|
7
|
-
variant?: "
|
|
7
|
+
variant?: "default" | "flat" | "elevated" | "ghost" | "interactive" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface CardProps extends React.ComponentProps<'div'>, VariantProps<typeof cardVariants> {
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Shared UI component library built on Base UI and Tailwind CSS v4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -375,6 +375,16 @@
|
|
|
375
375
|
"dist",
|
|
376
376
|
"src/styles"
|
|
377
377
|
],
|
|
378
|
+
"scripts": {
|
|
379
|
+
"build": "tsup",
|
|
380
|
+
"build:registry": "node scripts/build-registry.mjs",
|
|
381
|
+
"build:all": "pnpm build && pnpm build:registry",
|
|
382
|
+
"dev": "tsup --watch",
|
|
383
|
+
"lint:types": "tsc --noEmit",
|
|
384
|
+
"clean": "rm -rf dist registry/constructive",
|
|
385
|
+
"sb": "storybook dev -p 6007",
|
|
386
|
+
"build-sb": "storybook build"
|
|
387
|
+
},
|
|
378
388
|
"dependencies": {
|
|
379
389
|
"class-variance-authority": "^0.7.1",
|
|
380
390
|
"clsx": "^2.1.1",
|
|
@@ -477,14 +487,5 @@
|
|
|
477
487
|
"engines": {
|
|
478
488
|
"node": ">=18.0.0"
|
|
479
489
|
},
|
|
480
|
-
"
|
|
481
|
-
|
|
482
|
-
"build:registry": "node scripts/build-registry.mjs",
|
|
483
|
-
"build:all": "pnpm build && pnpm build:registry",
|
|
484
|
-
"dev": "tsup --watch",
|
|
485
|
-
"lint:types": "tsc --noEmit",
|
|
486
|
-
"clean": "rm -rf dist registry/constructive",
|
|
487
|
-
"sb": "storybook dev -p 6007",
|
|
488
|
-
"build-sb": "storybook build"
|
|
489
|
-
}
|
|
490
|
-
}
|
|
490
|
+
"gitHead": "cde90817364113dfe1db101f58f0853575b9a5e3"
|
|
491
|
+
}
|