@codapet/design-system 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,362 @@
1
+ # CodaPet Design System
2
+
3
+ A comprehensive React component library built with Shadcn UI, Radix UI, Tailwind CSS, and TypeScript.
4
+
5
+ ## Features
6
+
7
+ - 🎨 50+ accessible UI components
8
+ - 🎯 Built with Radix UI primitives
9
+ - 🎨 Tailwind CSS styling
10
+ - 📱 Mobile-first responsive design
11
+ - 🔧 TypeScript support
12
+ - ⚡️ Optimized for performance
13
+ - 🎭 Dark mode support
14
+ - ♿️ WCAG compliant
15
+
16
+ ## Installation
17
+
18
+ ### As an NPM Package
19
+
20
+ ```bash
21
+ npm install @codapet/design-system
22
+ ```
23
+
24
+ ### Peer Dependencies
25
+
26
+ The library requires React and React DOM as peer dependencies. Make sure you have them installed:
27
+
28
+ ```bash
29
+ npm install react react-dom
30
+ ```
31
+
32
+ Note for CI/builders (e.g., Vercel, GitHub Actions): since this package is public on npm, no extra auth or `.npmrc` is required. Just run your normal install command.
33
+
34
+ **Note**: The library supports React 18.0.0 and above. For best compatibility, use React 18.2.0 or later.
35
+
36
+ ---
37
+
38
+ ## Quickstart: Next.js 15 + Tailwind v4
39
+
40
+ Follow these steps to integrate the design system in a brand-new Next.js app.
41
+
42
+ 1) Create a Next.js app (TypeScript recommended):
43
+
44
+ ```bash
45
+ npx create-next-app@latest my-app
46
+ cd my-app
47
+ ```
48
+
49
+ 2) Add Tailwind v4 PostCSS plugin (required for Tailwind v4):
50
+
51
+ ```bash
52
+ npm install -D @tailwindcss/postcss
53
+ ```
54
+
55
+ Create `postcss.config.mjs` (if you don't have one):
56
+
57
+ ```js
58
+ /** @type {import('postcss-load-config').Config} */
59
+ const config = {
60
+ plugins: {
61
+ '@tailwindcss/postcss': {},
62
+ },
63
+ }
64
+ export default config
65
+ ```
66
+
67
+ 3) Install the design system:
68
+
69
+ ```bash
70
+ npm install codapet-design-system
71
+ ```
72
+
73
+ 4) Configure global CSS for Tailwind v4 scanning and import the design system styles.
74
+
75
+ Edit `app/globals.css`:
76
+
77
+ ```css
78
+ @import "tailwindcss";
79
+
80
+ /* Tell Tailwind where to scan for class usage */
81
+ @source "../**/*.{js,ts,jsx,tsx,mdx}";
82
+ @source "../../node_modules/@codapet/design-system/dist/**/*.{js,mjs,ts,tsx}";
83
+
84
+ /* Import the design system tokens and base styles (after Tailwind) */
85
+ @import "@codapet/design-system/styles";
86
+ ```
87
+
88
+ 5) Ensure your Next.js root layout includes the globals:
89
+
90
+ ```tsx
91
+ // app/layout.tsx
92
+ import type { Metadata } from 'next'
93
+ import './globals.css'
94
+
95
+ export const metadata: Metadata = { title: 'My App' }
96
+
97
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
98
+ return (
99
+ <html lang="en">
100
+ <body>{children}</body>
101
+ </html>
102
+ )
103
+ }
104
+ ```
105
+
106
+ 6) Use components:
107
+
108
+ ```tsx
109
+ // app/page.tsx
110
+ import { Button, Card, CardContent, CardHeader, CardTitle } from '@codapet/design-system'
111
+
112
+ export default function Page() {
113
+ return (
114
+ <main className="p-8">
115
+ <Card>
116
+ <CardHeader>
117
+ <CardTitle>Hello</CardTitle>
118
+ </CardHeader>
119
+ <CardContent>
120
+ <Button>Works!</Button>
121
+ </CardContent>
122
+ </Card>
123
+ </main>
124
+ )
125
+ }
126
+ ```
127
+
128
+ 7) Run the app:
129
+
130
+ ```bash
131
+ npm run dev
132
+ ```
133
+
134
+ ### Tailwind v3 (legacy)
135
+
136
+ If you are on Tailwind v3, use a config-based content scan instead of `@source` (see below in Styling).
137
+
138
+ ---
139
+
140
+ ## Usage
141
+
142
+ ### Basic Setup
143
+
144
+ ```tsx
145
+ import { Button, Card, Input } from '@codapet/design-system'
146
+
147
+ function App() {
148
+ return (
149
+ <div>
150
+ <Card>
151
+ <Input placeholder="Enter your name" />
152
+ <Button>Click me</Button>
153
+ </Card>
154
+ </div>
155
+ )
156
+ }
157
+ ```
158
+
159
+ ### Available Components
160
+
161
+ The library exports all UI components from the `components/ui` directory:
162
+
163
+ ```tsx
164
+ import {
165
+ Accordion,
166
+ Alert,
167
+ AlertDialog,
168
+ AspectRatio,
169
+ Avatar,
170
+ Badge,
171
+ Breadcrumb,
172
+ Button,
173
+ Calendar,
174
+ Card,
175
+ Carousel,
176
+ Chart,
177
+ Checkbox,
178
+ Collapsible,
179
+ Command,
180
+ ContextMenu,
181
+ Dialog,
182
+ Drawer,
183
+ DropdownMenu,
184
+ Form,
185
+ HoverCard,
186
+ Input,
187
+ InputOTP,
188
+ Label,
189
+ Menubar,
190
+ NavigationMenu,
191
+ Pagination,
192
+ Popover,
193
+ Progress,
194
+ RadioGroup,
195
+ Resizable,
196
+ ScrollArea,
197
+ Select,
198
+ Separator,
199
+ Sheet,
200
+ Sidebar,
201
+ Skeleton,
202
+ Slider,
203
+ Sonner,
204
+ Switch,
205
+ Table,
206
+ Tabs,
207
+ Textarea,
208
+ Toggle,
209
+ ToggleGroup,
210
+ Tooltip,
211
+ } from '@codapet/design-system'
212
+ ```
213
+
214
+ ### Utilities
215
+
216
+ ```tsx
217
+ import { cn } from '@codapet/design-system'
218
+
219
+ // Utility function for merging class names
220
+ const className = cn('base-class', 'conditional-class')
221
+ ```
222
+
223
+ ### Hooks
224
+
225
+ ```tsx
226
+ import { useIsMobile } from '@codapet/design-system'
227
+
228
+ function MyComponent() {
229
+ const isMobile = useIsMobile()
230
+ // ...
231
+ }
232
+ ```
233
+
234
+ ## Development
235
+
236
+ ### Prerequisites
237
+
238
+ - Node.js 18+
239
+ - npm or yarn
240
+
241
+ ### Setup
242
+
243
+ 1. Clone the repository
244
+ 2. Install dependencies:
245
+ ```bash
246
+ npm install
247
+ ```
248
+
249
+ ### Development Commands
250
+
251
+ - `npm run dev` - Start the development server
252
+ - `npm run build:lib` - Build the library for distribution
253
+ - `npm run build:all` - Build both the library and the demo app
254
+ - `npm run lint` - Run ESLint
255
+ - `npm run test:lib` - Test the library build
256
+ - `npm run check:deps` - Check dependency tree
257
+ - `npm run clean:deps` - Clean and reinstall dependencies
258
+
259
+ ### Building for Distribution
260
+
261
+ To build the library as an npm package:
262
+
263
+ ```bash
264
+ npm run build:lib
265
+ ```
266
+
267
+ This will generate:
268
+ - `dist/index.mjs` - ES Module bundle
269
+ - `dist/index.d.mts` - TypeScript declarations
270
+
271
+ ### Publishing
272
+
273
+ Releases are automated via GitHub Actions on semver tags.
274
+
275
+ Setup once:
276
+ - In GitHub → Settings → Secrets and variables → Actions, add `NPM_TOKEN` with publish access to the `@codapet` org.
277
+
278
+ Release steps:
279
+ ```bash
280
+ # update version in package.json
281
+ git commit -am "chore(release): v1.2.3"
282
+ git tag v1.2.3
283
+ git push --follow-tags
284
+ ```
285
+ The workflow builds, tests, and runs `npm publish --access public`.
286
+
287
+ ## Styling
288
+
289
+ The design system uses Tailwind CSS for styling. Make sure to include Tailwind CSS in your project and configure Tailwind to scan this package so utilities used inside it are generated.
290
+
291
+ ### Tailwind v4 (recommended)
292
+
293
+ 1) In your global CSS (e.g. `app/globals.css`), add `@source` to include the design system and import its stylesheet after Tailwind:
294
+
295
+ ```css
296
+ @import "tailwindcss";
297
+
298
+ /* Tell Tailwind to scan the design system in node_modules */
299
+ @source "../**/*.{js,ts,jsx,tsx,mdx}";
300
+ @source "../../node_modules/@codapet/design-system/dist/**/*.{js,mjs,ts,tsx}";
301
+
302
+ /* Import the design system CSS tokens and base layers */
303
+ @import "@codapet/design-system/styles";
304
+ ```
305
+
306
+ 2) Ensure your layout imports your globals (Next.js):
307
+
308
+ ```tsx
309
+ // app/layout.tsx
310
+ import "./globals.css";
311
+ ```
312
+
313
+ ### Tailwind v3
314
+
315
+ If you are still on Tailwind v3, use the content globs instead of `@source`:
316
+
317
+ ```js
318
+ // tailwind.config.js
319
+ /** @type {import('tailwindcss').Config} */
320
+ module.exports = {
321
+ content: [
322
+ './app/**/*.{js,ts,jsx,tsx}',
323
+ './components/**/*.{js,ts,jsx,tsx}',
324
+ './node_modules/@codapet/design-system/dist/**/*.{js,mjs,ts,tsx}',
325
+ ],
326
+ theme: { extend: {} },
327
+ plugins: [],
328
+ }
329
+ ```
330
+
331
+ ## Troubleshooting
332
+
333
+ - Components render unstyled:
334
+ - Ensure your `globals.css` contains `@source` that points to the design system in `node_modules` (Tailwind must see class usage to emit utilities).
335
+ - Restart the dev server after changing `@source` or Tailwind config.
336
+ - Verify `@import "codapet-design-system/styles";` comes after `@import "tailwindcss";`.
337
+ - If you use Tailwind v3, configure `content` globs as shown above.
338
+ - PostCSS cannot resolve an import:
339
+ - Ensure `@tailwindcss/postcss` is installed and present in `postcss.config.*`.
340
+ - If you see an error resolving `tw-animate-css`, install it in the app: `npm i -D tw-animate-css`.
341
+ - Still stuck? Clear caches and rebuild: `rm -rf .next` then `npm run dev`.
342
+
343
+ ## Dependency Management
344
+
345
+ For detailed information about how dependencies are organized and managed, see [DEPENDENCIES.md](./DEPENDENCIES.md).
346
+
347
+ ### Key Points:
348
+ - **Peer Dependencies**: React and React DOM (provided by consuming app)
349
+ - **Dependencies**: UI libraries and utilities (bundled with library)
350
+ - **Dev Dependencies**: Build tools and development utilities (not included in package)
351
+
352
+ ## Contributing
353
+
354
+ 1. Fork the repository
355
+ 2. Create a feature branch
356
+ 3. Make your changes
357
+ 4. Add tests if applicable
358
+ 5. Submit a pull request
359
+
360
+ ## License
361
+
362
+ MIT License - see LICENSE file for details.