@sehgaltech/psui 1.0.0
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 +343 -0
- package/dist/index.cjs +391 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +365 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/theme.css +145 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
# PSUI
|
|
2
|
+
|
|
3
|
+
A scalable and customizable UI library built with Tailwind CSS v4, TypeScript, and React.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ๐จ **Tailwind CSS v4** - Modern CSS-first configuration with `@theme` blocks
|
|
8
|
+
- ๐ฆ **TypeScript** - Full type safety and excellent developer experience
|
|
9
|
+
- โก **tsup** - Fast and efficient builds with ESM/CJS dual output
|
|
10
|
+
- ๐ **Storybook** - Interactive component documentation and playground
|
|
11
|
+
- ๐งช **Vitest** - Fast unit testing with React Testing Library
|
|
12
|
+
- ๐ฏ **Tree-shakeable** - Optimized bundle size with side-effect free exports
|
|
13
|
+
- ๐จ **Customizable** - Easy theme customization via CSS variables
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install psui
|
|
19
|
+
# or
|
|
20
|
+
yarn add psui
|
|
21
|
+
# or
|
|
22
|
+
pnpm add psui
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Basic Setup
|
|
28
|
+
|
|
29
|
+
1. Import the library styles in your application's main CSS file or entry point:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// In your main CSS file (e.g., index.css or app.css)
|
|
33
|
+
@import 'psui/styles';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or in your JavaScript/TypeScript entry file:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// In your main entry file (e.g., main.tsx or index.tsx)
|
|
40
|
+
import 'psui/styles';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Note:** Make sure your build tool supports Tailwind CSS v4. If you're using Vite, install `@tailwindcss/vite` plugin:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -D @tailwindcss/vite
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then add it to your `vite.config.ts`:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
plugins: [tailwindcss()],
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
1. Use components in your React application:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { Button } from 'psui';
|
|
63
|
+
|
|
64
|
+
function App() {
|
|
65
|
+
return (
|
|
66
|
+
<div>
|
|
67
|
+
<Button variant="primary" size="md">
|
|
68
|
+
Click me
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Button Component
|
|
76
|
+
|
|
77
|
+
The Button component supports multiple variants, sizes, and states:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Button } from 'psui';
|
|
81
|
+
|
|
82
|
+
// Variants
|
|
83
|
+
<Button variant="primary">Primary</Button>
|
|
84
|
+
<Button variant="secondary">Secondary</Button>
|
|
85
|
+
<Button variant="success">Success</Button>
|
|
86
|
+
<Button variant="danger">Danger</Button>
|
|
87
|
+
<Button variant="warning">Warning</Button>
|
|
88
|
+
<Button variant="ghost">Ghost</Button>
|
|
89
|
+
|
|
90
|
+
// Sizes
|
|
91
|
+
<Button size="sm">Small</Button>
|
|
92
|
+
<Button size="md">Medium</Button>
|
|
93
|
+
<Button size="lg">Large</Button>
|
|
94
|
+
|
|
95
|
+
// States
|
|
96
|
+
<Button loading>Loading...</Button>
|
|
97
|
+
<Button disabled>Disabled</Button>
|
|
98
|
+
<Button fullWidth>Full Width</Button>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Themes
|
|
102
|
+
|
|
103
|
+
PSUI ships with two themes: **Winter** (light) and **Starlight** (dark). Both use OKLCH colors and semantic tokens (base, primary, secondary, accent, neutral, info, success, warning, error).
|
|
104
|
+
|
|
105
|
+
### Switching themes
|
|
106
|
+
|
|
107
|
+
Set `data-theme` on a root element (e.g. `<html>` or a wrapper):
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
// Light (default)
|
|
111
|
+
<html data-theme="winter">
|
|
112
|
+
|
|
113
|
+
// Dark
|
|
114
|
+
<html data-theme="starlight">
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
You can switch at runtime:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
document.documentElement.setAttribute('data-theme', 'starlight');
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Theme tokens
|
|
124
|
+
|
|
125
|
+
- **Colors**: `base-100`, `base-200`, `base-300`, `base-content`, `primary`, `primary-content`, `secondary`, `secondary-content`, `accent`, `accent-content`, `neutral`, `neutral-content`, `info`, `info-content`, `success`, `success-content`, `warning`, `warning-content`, `error`, `error-content`
|
|
126
|
+
- **Radius**: `--radius-selector`, `--radius-field`, `--radius-box`
|
|
127
|
+
- **Sizes**: `--size-selector`, `--size-field`
|
|
128
|
+
- **Border**: `--border-width`
|
|
129
|
+
|
|
130
|
+
### Customization
|
|
131
|
+
|
|
132
|
+
Override theme variables for a given theme:
|
|
133
|
+
|
|
134
|
+
```css
|
|
135
|
+
[data-theme="winter"] {
|
|
136
|
+
--theme-primary: oklch(70% 0.12 260);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
### Prerequisites
|
|
143
|
+
|
|
144
|
+
- Node.js 18+
|
|
145
|
+
- npm, yarn, or pnpm
|
|
146
|
+
|
|
147
|
+
### Setup
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Install dependencies
|
|
151
|
+
npm install
|
|
152
|
+
|
|
153
|
+
# Start development build in watch mode
|
|
154
|
+
npm run dev
|
|
155
|
+
|
|
156
|
+
# Run Storybook
|
|
157
|
+
npm run storybook
|
|
158
|
+
|
|
159
|
+
# Run tests
|
|
160
|
+
npm test
|
|
161
|
+
|
|
162
|
+
# Type check
|
|
163
|
+
npm run type-check
|
|
164
|
+
|
|
165
|
+
# Build library
|
|
166
|
+
npm run build
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Project Structure
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
psui/
|
|
173
|
+
โโโ src/
|
|
174
|
+
โ โโโ components/ # React components
|
|
175
|
+
โ โ โโโ Button/
|
|
176
|
+
โ โ โโโ index.ts
|
|
177
|
+
โ โโโ styles/ # Tailwind CSS styles
|
|
178
|
+
โ โ โโโ base.css # Tailwind import
|
|
179
|
+
โ โ โโโ theme.css # Theme tokens
|
|
180
|
+
โ โโโ types/ # TypeScript types
|
|
181
|
+
โ โโโ index.ts # Main entry point
|
|
182
|
+
โโโ stories/ # Storybook stories
|
|
183
|
+
โโโ .storybook/ # Storybook config
|
|
184
|
+
โโโ dist/ # Build output
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Adding New Components
|
|
188
|
+
|
|
189
|
+
1. Create component directory in `src/components/`:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
mkdir src/components/MyComponent
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
1. Create component file:
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
// src/components/MyComponent/MyComponent.tsx
|
|
199
|
+
import { forwardRef } from 'react';
|
|
200
|
+
import type { ComponentProps } from '../../types';
|
|
201
|
+
|
|
202
|
+
export interface MyComponentProps extends ComponentProps<'div'> {
|
|
203
|
+
// Your props
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const MyComponent = forwardRef<HTMLDivElement, MyComponentProps>(
|
|
207
|
+
({ className, ...props }, ref) => {
|
|
208
|
+
return <div ref={ref} className={className} {...props} />;
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
MyComponent.displayName = 'MyComponent';
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
1. Export from component index:
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
// src/components/MyComponent/index.ts
|
|
219
|
+
export { MyComponent } from './MyComponent';
|
|
220
|
+
export type { MyComponentProps } from './MyComponent';
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
1. Export from main components index:
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
// src/components/index.ts
|
|
227
|
+
export { MyComponent } from './MyComponent';
|
|
228
|
+
export type { MyComponentProps } from './MyComponent';
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
1. Export from main library entry:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
// src/index.ts
|
|
235
|
+
export { MyComponent } from './components';
|
|
236
|
+
export type { MyComponentProps } from './components';
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
1. Create Storybook story:
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
// stories/MyComponent.stories.tsx
|
|
243
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
244
|
+
import { MyComponent } from '../src/components/MyComponent';
|
|
245
|
+
|
|
246
|
+
const meta: Meta<typeof MyComponent> = {
|
|
247
|
+
title: 'Components/MyComponent',
|
|
248
|
+
component: MyComponent,
|
|
249
|
+
tags: ['autodocs'],
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export default meta;
|
|
253
|
+
type Story = StoryObj<typeof MyComponent>;
|
|
254
|
+
|
|
255
|
+
export const Default: Story = {
|
|
256
|
+
args: {
|
|
257
|
+
// Your args
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Building and Publishing
|
|
263
|
+
|
|
264
|
+
### Build
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npm run build
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
This generates:
|
|
271
|
+
|
|
272
|
+
- `dist/index.js` - CommonJS bundle
|
|
273
|
+
- `dist/index.mjs` - ES Module bundle
|
|
274
|
+
- `dist/index.d.ts` - TypeScript declarations
|
|
275
|
+
- `dist/styles.css` - Compiled CSS
|
|
276
|
+
|
|
277
|
+
### Publishing
|
|
278
|
+
|
|
279
|
+
1. Update version in `package.json`
|
|
280
|
+
2. Build the library: `npm run build`
|
|
281
|
+
3. Publish to npm: `npm publish`
|
|
282
|
+
|
|
283
|
+
## Deployment (Storybook to Vercel)
|
|
284
|
+
|
|
285
|
+
Deploy the component documentation (Storybook) to Vercel so others can browse the library online.
|
|
286
|
+
|
|
287
|
+
### Prerequisites
|
|
288
|
+
|
|
289
|
+
- Project pushed to GitHub, GitLab, or Bitbucket
|
|
290
|
+
- [Vercel](https://vercel.com) account
|
|
291
|
+
|
|
292
|
+
### Steps
|
|
293
|
+
|
|
294
|
+
1. **Build Storybook locally (optional check)**
|
|
295
|
+
From the project root:
|
|
296
|
+
Output is written to the `storybook-static` directory.
|
|
297
|
+
2. **Deploy via Vercel**
|
|
298
|
+
- In [Vercel](https://vercel.com): **Add New Project** โ import your repository.
|
|
299
|
+
- Configure the project:
|
|
300
|
+
- **Build Command:** `npm run build-storybook`
|
|
301
|
+
- **Output Directory:** `storybook-static`
|
|
302
|
+
- **Install Command:** `npm install` (default)
|
|
303
|
+
- Deploy. The published URL will serve your Storybook (e.g. Winter/Starlight theme and all stories).
|
|
304
|
+
|
|
305
|
+
### Optional: `vercel.json`
|
|
306
|
+
|
|
307
|
+
To fix build settings in the repo, add a `vercel.json` in the project root:
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"buildCommand": "npm run build-storybook",
|
|
312
|
+
"outputDirectory": "storybook-static",
|
|
313
|
+
"installCommand": "npm install"
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Then deploying from Git or the Vercel CLI will use these values automatically.
|
|
318
|
+
|
|
319
|
+
## TypeScript Support
|
|
320
|
+
|
|
321
|
+
PSUI is written in TypeScript and provides full type definitions. All components export their prop types for use in your applications:
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
import type { ButtonProps } from 'psui';
|
|
325
|
+
|
|
326
|
+
const MyButton: React.FC<ButtonProps> = (props) => {
|
|
327
|
+
// Type-safe component
|
|
328
|
+
};
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Browser Support
|
|
332
|
+
|
|
333
|
+
- Safari 16.4+
|
|
334
|
+
- Chrome 111+
|
|
335
|
+
- Firefox 128+
|
|
336
|
+
|
|
337
|
+
## License
|
|
338
|
+
|
|
339
|
+
MIT
|
|
340
|
+
|
|
341
|
+
## Contributing
|
|
342
|
+
|
|
343
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|