@popgrids/ui 0.0.1 → 0.0.4

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,227 @@
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.
14
37
 
15
- ```typescript
16
- import "@popgrids/ui";
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";
17
43
  ```
18
44
 
19
- Then use the components in your HTML:
45
+ ### Step 2: Import and Use Components
20
46
 
21
- ```html
22
- <pop-button>Click me</pop-button>
23
- <pop-icon name="star"></pop-icon>
24
- <pop-toast message="Hello!"></pop-toast>
47
+ ```tsx
48
+ import { Button } from "@popgrids/ui";
49
+
50
+ function App() {
51
+ return <Button>Click me</Button>;
52
+ }
25
53
  ```
26
54
 
27
- ## Available Components
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
+ ```
28
78
 
29
- The library includes the following components:
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
+ ```
30
96
 
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
97
+ ### Using buttonVariants
46
98
 
47
- ## Development
99
+ You can also use the `buttonVariants` function directly for custom styling:
48
100
 
49
- ### Prerequisites
101
+ ```tsx
102
+ import { buttonVariants } from "@popgrids/ui";
103
+ import { cn } from "./lib/utils";
50
104
 
51
- - Node.js
52
- - npm
105
+ function CustomButton({ className, ...props }) {
106
+ return (
107
+ <button
108
+ className={cn(buttonVariants({ variant: "outline", size: "lg" }), className)}
109
+ {...props}
110
+ />
111
+ );
112
+ }
113
+ ```
53
114
 
54
- ### Scripts
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
122
+
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
+ }
172
+ ```
55
173
 
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
174
+ ### Customizing Theme Variables
63
175
 
64
- ### Adding New Components
176
+ You can customize any variable to match your design system. Simply override the values in your CSS:
65
177
 
66
- To add a new component, use the generator:
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
+ }
184
+ ```
67
185
 
68
- ```bash
69
- npm run generate:component
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";
70
202
  ```
71
203
 
72
- ## Dependencies
204
+ Your bundler will only include the Button component and its dependencies, not unused exports.
205
+
206
+ ## How It Works
207
+
208
+ When you import `@popgrids/ui/theme.css` in your main CSS file:
209
+
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!
215
+
216
+ ### Requirements
217
+
218
+ - **Tailwind CSS v4** (required for `@theme` and `@source` directives)
219
+ - Import `@popgrids/ui/theme.css` in your main CSS file (not in JavaScript)
220
+
221
+ ## TypeScript
73
222
 
74
- - [Lit](https://lit.dev/) - Web Components library
75
- - [@popgrids/theme](https://github.com/popgrids/popgrids-turborepo) - Theme package
223
+ Full TypeScript support is included. All components are typed and exported with their proper types.
76
224
 
77
225
  ## License
78
226
 
79
- Private - All rights reserved
227
+ MIT