@okshaun/components 0.1.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 ADDED
@@ -0,0 +1,397 @@
1
+ # Okshaun Components
2
+
3
+ A comprehensive React component library built with **Panda CSS** for styling. Provides a complete design system with themed components, light/dark mode support, and TypeScript-first development.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Panda CSS** - Build-time CSS-in-JS with type-safe tokens
8
+ - 🌗 **Light/Dark Mode** - Built-in theme switching with system preference detection
9
+ - 📦 **Polymorphic Components** - All components accept `as` prop for flexible rendering
10
+ - 🔤 **TypeScript** - Full type safety and autocomplete
11
+ - ♿ **Accessible** - ARIA-compliant components
12
+ - 🎯 **Tree-shakeable** - Import only what you need
13
+ - 📐 **Customizable** - Extend tokens, recipes, and components
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @okshaun/components @pandacss/dev
19
+ # or
20
+ yarn add @okshaun/components @pandacss/dev
21
+ # or
22
+ pnpm add @okshaun/components @pandacss/dev
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ### 1. Configure Panda CSS
28
+
29
+ Create `panda.config.ts` in your project root:
30
+
31
+ ```typescript
32
+ import { defineConfig } from '@pandacss/dev'
33
+ import { okshaunPreset } from '@okshaun/components/preset'
34
+
35
+ export default defineConfig({
36
+ // Include your app's files AND the component library
37
+ include: [
38
+ './src/**/*.{js,jsx,ts,tsx}',
39
+ './node_modules/@okshaun/components/dist/**/*.js'
40
+ ],
41
+
42
+ exclude: [],
43
+
44
+ // Use the okshaun preset
45
+ presets: [
46
+ '@pandacss/preset-base',
47
+ okshaunPreset
48
+ ],
49
+
50
+ // Optional: customize the preset
51
+ theme: {
52
+ extend: {
53
+ tokens: {
54
+ // Add your custom tokens here
55
+ }
56
+ }
57
+ },
58
+
59
+ // Configure output
60
+ outdir: 'styled-system',
61
+ jsxFramework: 'react',
62
+
63
+ // Recommended settings
64
+ strictTokens: true, // Enforce token usage
65
+ importMap: '@styled-system',
66
+ })
67
+ ```
68
+
69
+ ### 2. Configure PostCSS
70
+
71
+ Create `postcss.config.js`:
72
+
73
+ ```javascript
74
+ export default {
75
+ plugins: {
76
+ '@pandacss/dev/postcss': {},
77
+ },
78
+ }
79
+ ```
80
+
81
+ ### 3. Add Panda CSS to Your Styles
82
+
83
+ In your main CSS file (e.g., `src/index.css`):
84
+
85
+ ```css
86
+ @layer reset, base, tokens, recipes, utilities;
87
+ ```
88
+
89
+ ### 4. Set Up Your Application
90
+
91
+ In your app entry point (e.g., `src/main.tsx`):
92
+
93
+ ```typescript
94
+ import React from 'react'
95
+ import ReactDOM from 'react-dom/client'
96
+ import { ThemeProvider } from '@okshaun/components'
97
+ import App from './App'
98
+
99
+ // Import your app styles and Panda CSS output
100
+ import './index.css'
101
+ import '../styled-system/styles.css'
102
+
103
+ ReactDOM.createRoot(document.getElementById('root')!).render(
104
+ <React.StrictMode>
105
+ <ThemeProvider>
106
+ <App />
107
+ </ThemeProvider>
108
+ </React.StrictMode>,
109
+ )
110
+ ```
111
+
112
+ ### 5. Update package.json Scripts
113
+
114
+ Add Panda CSS generation to your scripts:
115
+
116
+ ```json
117
+ {
118
+ "scripts": {
119
+ "dev": "panda codegen --watch & vite",
120
+ "build": "panda codegen && tsc && vite build",
121
+ "panda": "panda codegen"
122
+ }
123
+ }
124
+ ```
125
+
126
+ ### 6. Configure TypeScript
127
+
128
+ Update `tsconfig.json` to include Panda CSS path aliases:
129
+
130
+ ```json
131
+ {
132
+ "compilerOptions": {
133
+ "baseUrl": ".",
134
+ "paths": {
135
+ "@styled-system/*": ["./styled-system/*"]
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ ### 7. Configure Vite (if using Vite)
142
+
143
+ Update `vite.config.ts`:
144
+
145
+ ```typescript
146
+ import { defineConfig } from 'vite'
147
+ import react from '@vitejs/plugin-react'
148
+ import { resolve } from 'path'
149
+
150
+ export default defineConfig({
151
+ plugins: [react()],
152
+ resolve: {
153
+ alias: {
154
+ '@styled-system': resolve(__dirname, './styled-system'),
155
+ },
156
+ },
157
+ })
158
+ ```
159
+
160
+ ## Usage
161
+
162
+ ### Using Components
163
+
164
+ ```typescript
165
+ import { Button, Box, Text, Icon } from '@okshaun/components'
166
+ import { css } from '../styled-system/css'
167
+
168
+ function App() {
169
+ return (
170
+ <Box p="4">
171
+ <Text size="xl" weight="bold" mb="4">
172
+ Hello from Okshaun Components!
173
+ </Text>
174
+
175
+ <Button variant="primary" size="md">
176
+ Click Me
177
+ </Button>
178
+
179
+ {/* Use Panda CSS directly with preset tokens */}
180
+ <div className={css({
181
+ bg: 'primary.default',
182
+ color: 'primary.contrast',
183
+ p: '4',
184
+ borderRadius: 'md'
185
+ })}>
186
+ Styled with preset tokens
187
+ </div>
188
+ </Box>
189
+ )
190
+ }
191
+ ```
192
+
193
+ ### Theme Switching
194
+
195
+ ```typescript
196
+ import { ThemeSwitcher, useTheme } from '@okshaun/components'
197
+
198
+ function MyApp() {
199
+ const { theme, setTheme } = useTheme()
200
+
201
+ return (
202
+ <div>
203
+ <p>Current theme: {theme}</p>
204
+ <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
205
+ Toggle Theme
206
+ </button>
207
+
208
+ {/* Or use the built-in ThemeSwitcher component */}
209
+ <ThemeSwitcher />
210
+ </div>
211
+ )
212
+ }
213
+ ```
214
+
215
+ ### Using Icons
216
+
217
+ Icons are automatically injected into the DOM when you use the first Icon component:
218
+
219
+ ```typescript
220
+ import { Icon } from '@okshaun/components'
221
+
222
+ function MyComponent() {
223
+ return (
224
+ <>
225
+ <Icon name="check" size="md" fill="success.default" />
226
+ <Icon name="close" size="lg" fill="error.default" />
227
+ </>
228
+ )
229
+ }
230
+ ```
231
+
232
+ All icon names are type-safe - your editor will autocomplete available icons.
233
+
234
+ ### Polymorphic Components
235
+
236
+ All components can render as different HTML elements or React components:
237
+
238
+ ```typescript
239
+ import { Box, Button } from '@okshaun/components'
240
+ import { Link } from 'react-router-dom'
241
+
242
+ function Examples() {
243
+ return (
244
+ <>
245
+ {/* Box as a section */}
246
+ <Box as="section" p="4">
247
+ Content
248
+ </Box>
249
+
250
+ {/* Button as a link */}
251
+ <Button as="a" href="https://example.com" variant="primary">
252
+ External Link
253
+ </Button>
254
+
255
+ {/* Button as React Router Link */}
256
+ <Button as={Link} to="/about" variant="secondary">
257
+ About Page
258
+ </Button>
259
+ </>
260
+ )
261
+ }
262
+ ```
263
+
264
+ ## Available Components
265
+
266
+ - **Layout**: Box
267
+ - **Typography**: Text, Heading
268
+ - **Buttons**: Button, IconButton
269
+ - **Forms**: TextInput, Textarea, Checkbox, CheckboxInput, Radio, RadioInput, Toggle, ToggleInput, Label
270
+ - **Feedback**: Badge, Spinner, Tooltip
271
+ - **Data Display**: Card, Tag, Divider, Icon
272
+ - **Navigation**: Link, Breadcrumbs, Menu
273
+ - **Code**: Pre (code blocks)
274
+ - **Theme**: ThemeProvider, ThemeSwitcher
275
+
276
+ ## Customization
277
+
278
+ ### Extending Tokens
279
+
280
+ You can extend or override preset tokens in your `panda.config.ts`:
281
+
282
+ ```typescript
283
+ export default defineConfig({
284
+ presets: [okshaunPreset],
285
+ theme: {
286
+ extend: {
287
+ tokens: {
288
+ colors: {
289
+ brand: {
290
+ primary: { value: '#your-color' },
291
+ secondary: { value: '#another-color' }
292
+ }
293
+ },
294
+ spacing: {
295
+ huge: { value: '10rem' }
296
+ }
297
+ },
298
+ semanticTokens: {
299
+ colors: {
300
+ 'custom-bg': {
301
+ value: { base: '{colors.gray.100}', _dark: '{colors.gray.800}' }
302
+ }
303
+ }
304
+ }
305
+ }
306
+ }
307
+ })
308
+ ```
309
+
310
+ ### Using Preset Tokens
311
+
312
+ The preset provides comprehensive design tokens:
313
+
314
+ ```typescript
315
+ import { css } from '../styled-system/css'
316
+
317
+ const styles = css({
318
+ // Colors from semantic tokens
319
+ bg: 'surface.default',
320
+ color: 'text.default',
321
+ borderColor: 'border.default',
322
+
323
+ // Spacing (0-280 + container sizes)
324
+ p: '4',
325
+ m: '8',
326
+ gap: '2',
327
+
328
+ // Border radius
329
+ borderRadius: 'md', // xs, sm, md, lg, xl, 2xl, 3xl, full
330
+
331
+ // Shadows
332
+ boxShadow: 'md', // sm, md, lg, xl, 2xl
333
+
334
+ // Typography
335
+ fontSize: 'md',
336
+ fontWeight: 'medium',
337
+ lineHeight: 'normal'
338
+ })
339
+ ```
340
+
341
+ ## Development
342
+
343
+ ### Prerequisites
344
+
345
+ - Node.js 18+
346
+ - npm, yarn, or pnpm
347
+
348
+ ### Local Development
349
+
350
+ ```bash
351
+ # Install dependencies
352
+ npm install
353
+
354
+ # Generate Panda CSS
355
+ npm run panda
356
+
357
+ # Start development server
358
+ npm run dev
359
+
360
+ # Start Storybook
361
+ npm run storybook
362
+
363
+ # Run linter
364
+ npm run lint
365
+
366
+ # Build library
367
+ npm run build
368
+ ```
369
+
370
+ ## Publishing
371
+
372
+ To publish a new version to npm:
373
+
374
+ 1. Update version in `package.json`
375
+ 2. Create a git tag: `git tag v1.0.0`
376
+ 3. Push tag: `git push --tags`
377
+ 4. Create a GitHub release, or use the manual workflow in GitHub Actions
378
+
379
+ The package will be automatically published to npm via GitHub Actions.
380
+
381
+ ## Storybook
382
+
383
+ View all components in Storybook: [https://shaunrfox.github.io/okshaun-components](https://shaunrfox.github.io/okshaun-components)
384
+
385
+ ## License
386
+
387
+ MIT
388
+
389
+ ## Contributing
390
+
391
+ Contributions are welcome! Please open an issue or submit a pull request.
392
+
393
+ ## Links
394
+
395
+ - [GitHub Repository](https://github.com/shaunrfox/okshaun-components)
396
+ - [NPM Package](https://www.npmjs.com/package/@okshaun/components)
397
+ - [Panda CSS Documentation](https://panda-css.com/)