@popgrids/ui 0.0.2 → 0.0.5

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 CHANGED
@@ -1,79 +1,259 @@
1
1
  # @popgrids/ui
2
2
 
3
- A modern, reusable UI component library built with Lit for Popgrids applications.
3
+ A modern, production-ready React UI component library based on shadcn/ui principles, built with Base UI primitives and optimized for tree-shaking.
4
4
 
5
5
  ## Installation
6
6
 
7
+ ```bash
8
+ pnpm add @popgrids/ui
9
+ ```
10
+
11
+ Or with npm:
12
+
7
13
  ```bash
8
14
  npm install @popgrids/ui
9
15
  ```
10
16
 
17
+ ## Peer Dependencies
18
+
19
+ This library requires the following peer dependencies:
20
+
21
+ - `react` ^19.0.0
22
+ - `react-dom` ^19.0.0
23
+ - `@base-ui/react` ^1.0.0
24
+ - `tailwindcss` ^4.0.0
25
+
26
+ ## Requirements
27
+
28
+ - React 19+
29
+ - Tailwind CSS v4 configured in your project
30
+ - TypeScript (recommended)
31
+
11
32
  ## Usage
12
33
 
13
- Import the package to register all components:
34
+ ### Step 1: Import the Theme CSS
35
+
36
+ **Import the library's theme CSS file in your main CSS file** (not in JavaScript). This file includes theme variables and tells Tailwind to scan the library's component files.
37
+
38
+ ```css
39
+ /* Your main CSS file (e.g., app.css, index.css, globals.css) */
40
+ @import "tailwindcss";
41
+ /* Import the library's theme and source definitions */
42
+ @import "@popgrids/ui/theme.css";
43
+ ```
44
+
45
+ ### Step 2: Import and Use Components
46
+
47
+ ```tsx
48
+ import { Button } from "@popgrids/ui";
49
+
50
+ function App() {
51
+ return <Button>Click me</Button>;
52
+ }
53
+ ```
54
+
55
+ That's it! The `@import "@popgrids/ui/theme.css"` line:
56
+ - Defines the library's theme variables
57
+ - Tells Tailwind to scan `@popgrids/ui/dist/**/*.{js,cjs}` for class names
58
+ - Automatically generates CSS for all classes used in the components
59
+
60
+ ### Variants
61
+
62
+ ```tsx
63
+ import { Button } from "@popgrids/ui";
64
+
65
+ function App() {
66
+ return (
67
+ <>
68
+ <Button variant="default">Default</Button>
69
+ <Button variant="outline">Outline</Button>
70
+ <Button variant="secondary">Secondary</Button>
71
+ <Button variant="ghost">Ghost</Button>
72
+ <Button variant="destructive">Destructive</Button>
73
+ <Button variant="link">Link</Button>
74
+ </>
75
+ );
76
+ }
77
+ ```
78
+
79
+ ### Sizes
80
+
81
+ ```tsx
82
+ import { Button } from "@popgrids/ui";
83
+
84
+ function App() {
85
+ return (
86
+ <>
87
+ <Button size="xs">Extra Small</Button>
88
+ <Button size="sm">Small</Button>
89
+ <Button size="default">Default</Button>
90
+ <Button size="lg">Large</Button>
91
+ <Button size="icon">Icon</Button>
92
+ </>
93
+ );
94
+ }
95
+ ```
96
+
97
+ ### Using buttonVariants
98
+
99
+ You can also use the `buttonVariants` function directly for custom styling:
100
+
101
+ ```tsx
102
+ import { buttonVariants } from "@popgrids/ui";
103
+ import { cn } from "./lib/utils";
104
+
105
+ function CustomButton({ className, ...props }) {
106
+ return (
107
+ <button
108
+ className={cn(buttonVariants({ variant: "outline", size: "lg" }), className)}
109
+ {...props}
110
+ />
111
+ );
112
+ }
113
+ ```
114
+
115
+ ## Theming
116
+
117
+ The library's theme is included when you import `@popgrids/ui/theme.css`. This file defines:
118
+
119
+ 1. **Theme variables** using Tailwind v4's `@theme` directive
120
+ 2. **CSS variables** for backward compatibility
121
+ 3. **Source directives** that tell Tailwind to scan the library's component files
14
122
 
15
- ```typescript
16
- import "@popgrids/ui";
123
+ ### Default Theme
124
+
125
+ The theme CSS file includes default design tokens. You can customize them by overriding the variables in your own CSS:
126
+
127
+ ```css
128
+ :root {
129
+ --background: 0 0% 100%;
130
+ --foreground: 222.2 84% 4.9%;
131
+ --card: 0 0% 100%;
132
+ --card-foreground: 222.2 84% 4.9%;
133
+ --popover: 0 0% 100%;
134
+ --popover-foreground: 222.2 84% 4.9%;
135
+ --primary: 221.2 83.2% 53.3%;
136
+ --primary-foreground: 210 40% 98%;
137
+ --secondary: 210 40% 96.1%;
138
+ --secondary-foreground: 222.2 47.4% 11.2%;
139
+ --muted: 210 40% 96.1%;
140
+ --muted-foreground: 215.4 16.3% 46.9%;
141
+ --accent: 210 40% 96.1%;
142
+ --accent-foreground: 222.2 47.4% 11.2%;
143
+ --destructive: 0 84.2% 60.2%;
144
+ --destructive-foreground: 210 40% 98%;
145
+ --border: 214.3 31.8% 91.4%;
146
+ --input: 214.3 31.8% 91.4%;
147
+ --ring: 221.2 83.2% 53.3%;
148
+ --radius: 0.5rem;
149
+ }
150
+
151
+ .dark {
152
+ --background: 222.2 84% 4.9%;
153
+ --foreground: 210 40% 98%;
154
+ --card: 222.2 84% 4.9%;
155
+ --card-foreground: 210 40% 98%;
156
+ --popover: 222.2 84% 4.9%;
157
+ --popover-foreground: 210 40% 98%;
158
+ --primary: 217.2 91.2% 59.8%;
159
+ --primary-foreground: 222.2 47.4% 11.2%;
160
+ --secondary: 217.2 32.6% 17.5%;
161
+ --secondary-foreground: 210 40% 98%;
162
+ --muted: 217.2 32.6% 17.5%;
163
+ --muted-foreground: 215 20.2% 65.1%;
164
+ --accent: 217.2 32.6% 17.5%;
165
+ --accent-foreground: 210 40% 98%;
166
+ --destructive: 0 62.8% 30.6%;
167
+ --destructive-foreground: 210 40% 98%;
168
+ --border: 217.2 32.6% 17.5%;
169
+ --input: 217.2 32.6% 17.5%;
170
+ --ring: 224.3 76.3% 48%;
171
+ }
17
172
  ```
18
173
 
19
- Then use the components in your HTML:
174
+ ### Customizing Theme Variables
175
+
176
+ You can customize any variable to match your design system. Simply override the values in your CSS:
20
177
 
21
- ```html
22
- <pop-button>Click me</pop-button>
23
- <pop-icon name="star"></pop-icon>
24
- <pop-toast message="Hello!"></pop-toast>
178
+ ```css
179
+ :root {
180
+ --primary: 221.2 83.2% 53.3%; /* Your primary color */
181
+ --radius: 0.5rem; /* Your border radius */
182
+ /* Customize other variables as needed */
183
+ }
25
184
  ```
26
185
 
27
- ## Available Components
186
+ ### Dark Mode
187
+
188
+ Apply the `.dark` class to your root element to enable dark mode:
189
+
190
+ ```tsx
191
+ <html className="dark">
192
+ {/* Your app */}
193
+ </html>
194
+ ```
195
+
196
+ ## Tree-Shaking
197
+
198
+ This library is fully tree-shakeable. When you import only the components you need:
199
+
200
+ ```tsx
201
+ import { Button } from "@popgrids/ui";
202
+ ```
28
203
 
29
- The library includes the following components:
204
+ Your bundler will only include the Button component and its dependencies, not unused exports.
30
205
 
31
- - `<pop-button>` - Standard button component
32
- - `<pop-button-vertical>` - Vertical button variant
33
- - `<pop-button-link>` - Button that acts as a link
34
- - `<pop-code-input-field>` - Input field for code entry
35
- - `<pop-comment-avatar>` - Avatar component for comments
36
- - `<pop-comment-icon>` - Icon component for comments
37
- - `<pop-element>` - Base element component
38
- - `<pop-focus-indicator>` - Focus indicator component
39
- - `<pop-form-input-simple>` - Simple form input component
40
- - `<pop-icon>` - Icon component
41
- - `<pop-loader>` - Loading indicator component
42
- - `<pop-logo>` - Logo component
43
- - `<pop-sum>` - Sum display component
44
- - `<pop-timestamp-countdown>` - Countdown timer component
45
- - `<pop-toast>` - Toast notification component
206
+ ## How It Works
46
207
 
47
- ## Development
208
+ When you import `@popgrids/ui/theme.css` in your main CSS file:
48
209
 
49
- ### Prerequisites
210
+ 1. **Theme variables are defined** using Tailwind v4's `@theme` directive
211
+ 2. **CSS variables are set** for backward compatibility (used in component classes like `hsl(var(--primary))`)
212
+ 3. **`@source` directive tells Tailwind** to scan `@popgrids/ui/dist/**/*.{js,cjs}` for class names
213
+ 4. **Tailwind generates CSS** for all classes found in the library's components
214
+ 5. **No manual configuration needed** - the `@source` directive handles everything!
50
215
 
51
- - Node.js
52
- - npm
216
+ ### Requirements
53
217
 
54
- ### Scripts
218
+ - **Tailwind CSS v4** (required for `@theme` and `@source` directives)
219
+ - Import `@popgrids/ui/theme.css` in your main CSS file (not in JavaScript)
55
220
 
56
- - `npm run build` - Build the package
57
- - `npm run dev` - Watch mode for development
58
- - `npm run clean` - Clean build artifacts
59
- - `npm run lint` - Run ESLint
60
- - `npm run test` - Run tests
61
- - `npm run generate:component` - Generate a new component
62
- - `npm run check-types` - Check TypeScript types
221
+ ## TypeScript
63
222
 
64
- ### Adding New Components
223
+ Full TypeScript support is included. All components are typed and exported with their proper types.
65
224
 
66
- To add a new component, use the generator:
225
+ ## Changesets
226
+
227
+ This library uses Changesets to manage versions. To create a new version, run:
228
+
229
+ ```bash
230
+ pnpm changeset
231
+ ```
232
+
233
+ This will open an interactive prompt to help you create a changeset.
234
+
235
+ Once you've created a changeset, run:
236
+
237
+ ```bash
238
+ pnpm changeset version
239
+ ```
240
+
241
+ This will update the version in the package.json file and create a new git tag.
242
+
243
+ Then push the changes to the repository:
67
244
 
68
245
  ```bash
69
- npm run generate:component
246
+ git push origin main
70
247
  ```
71
248
 
72
- ## Dependencies
249
+ And finally, publish the package:
250
+
251
+ ```bash
252
+ pnpm changeset publish
253
+ ```
73
254
 
74
- - [Lit](https://lit.dev/) - Web Components library
75
- - [@popgrids/theme](https://github.com/popgrids/popgrids-turborepo) - Theme package
255
+ This will publish the package to the npm registry.
76
256
 
77
257
  ## License
78
258
 
79
- Private - All rights reserved
259
+ MIT