infinity-ui-elements 1.0.1
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 +311 -0
- package/dist/components/Button/Button.d.ts +11 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.stories.d.ts +10 -0
- package/dist/components/Button/Button.stories.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +14 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
- package/src/components/Button/Button.stories.tsx +62 -0
- package/src/components/Button/Button.tsx +35 -0
- package/src/components/Button/index.ts +1 -0
- package/src/index.css +54 -0
- package/src/index.ts +2 -0
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# infinity-ui-elements
|
|
2
|
+
|
|
3
|
+
A React TypeScript component library with Tailwind CSS design system for Infinity products.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Design System**: Consistent styling with custom Tailwind CSS tokens
|
|
8
|
+
- 📦 **Tree-shakable**: ESM + CJS builds with Rollup
|
|
9
|
+
- 📚 **Storybook**: Isolated development and documentation
|
|
10
|
+
- 🔧 **TypeScript**: Full type safety and IntelliSense support
|
|
11
|
+
- âš¡ **Hot Reload**: Fast development with Vite-powered Storybook
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add infinity-ui-elements
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Basic Usage
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Button } from 'infinity-ui-elements';
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<Button variant="primary" onClick={() => console.log('Clicked!')}>
|
|
30
|
+
Click me
|
|
31
|
+
</Button>
|
|
32
|
+
<Button variant="secondary">
|
|
33
|
+
Secondary Button
|
|
34
|
+
</Button>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Tailwind CSS Setup
|
|
41
|
+
|
|
42
|
+
To use the design system in your project, you need to extend your Tailwind configuration:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
// tailwind.config.js
|
|
46
|
+
module.exports = {
|
|
47
|
+
content: [
|
|
48
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
49
|
+
'./node_modules/infinity-ui-elements/dist/**/*.{js,ts,jsx,tsx}',
|
|
50
|
+
],
|
|
51
|
+
theme: {
|
|
52
|
+
extend: {
|
|
53
|
+
colors: {
|
|
54
|
+
primary: 'var(--color-primary)',
|
|
55
|
+
secondary: 'var(--color-secondary)',
|
|
56
|
+
success: 'var(--color-success)',
|
|
57
|
+
danger: 'var(--color-danger)',
|
|
58
|
+
warning: 'var(--color-warning)',
|
|
59
|
+
info: 'var(--color-info)',
|
|
60
|
+
light: 'var(--color-light)',
|
|
61
|
+
dark: 'var(--color-dark)',
|
|
62
|
+
},
|
|
63
|
+
spacing: {
|
|
64
|
+
18: 'var(--spacing-18)',
|
|
65
|
+
88: 'var(--spacing-88)',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
plugins: [],
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Important**: Make sure to import the design system's CSS file in your application:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
// In your main App.tsx or index.tsx
|
|
77
|
+
import 'infinity-ui-elements/dist/index.css';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
### Prerequisites
|
|
83
|
+
|
|
84
|
+
- Node.js 18+
|
|
85
|
+
- Yarn 4.5.2 (managed via Corepack)
|
|
86
|
+
|
|
87
|
+
### Setup
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Install dependencies
|
|
91
|
+
yarn install
|
|
92
|
+
|
|
93
|
+
# Start Storybook for development
|
|
94
|
+
yarn storybook
|
|
95
|
+
|
|
96
|
+
# Build the library
|
|
97
|
+
yarn build
|
|
98
|
+
|
|
99
|
+
# Type checking
|
|
100
|
+
yarn type-check
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Project Structure
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
src/
|
|
107
|
+
├── components/
|
|
108
|
+
│ └── Button/
|
|
109
|
+
│ ├── Button.tsx # Component implementation
|
|
110
|
+
│ ├── Button.stories.tsx # Storybook stories
|
|
111
|
+
│ └── index.ts # Component exports
|
|
112
|
+
├── index.css # Tailwind CSS + CSS variables
|
|
113
|
+
└── index.ts # Main barrel export
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Components
|
|
117
|
+
|
|
118
|
+
### Button
|
|
119
|
+
|
|
120
|
+
A versatile button component with multiple variants.
|
|
121
|
+
|
|
122
|
+
#### Props
|
|
123
|
+
|
|
124
|
+
| Prop | Type | Default | Description |
|
|
125
|
+
|------|------|---------|-------------|
|
|
126
|
+
| `variant` | `'primary' \| 'secondary'` | `'primary'` | Button style variant |
|
|
127
|
+
| `children` | `React.ReactNode` | - | Button content |
|
|
128
|
+
| `onClick` | `() => void` | - | Click handler |
|
|
129
|
+
| `disabled` | `boolean` | `false` | Disabled state |
|
|
130
|
+
| `className` | `string` | `''` | Additional CSS classes |
|
|
131
|
+
|
|
132
|
+
#### Examples
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
// Primary button
|
|
136
|
+
<Button variant="primary" onClick={handleClick}>
|
|
137
|
+
Save Changes
|
|
138
|
+
</Button>
|
|
139
|
+
|
|
140
|
+
// Secondary button
|
|
141
|
+
<Button variant="secondary">
|
|
142
|
+
Cancel
|
|
143
|
+
</Button>
|
|
144
|
+
|
|
145
|
+
// Disabled button
|
|
146
|
+
<Button disabled>
|
|
147
|
+
Processing...
|
|
148
|
+
</Button>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Publishing
|
|
152
|
+
|
|
153
|
+
### Automated Publishing Commands
|
|
154
|
+
|
|
155
|
+
The package includes automated scripts for versioning and publishing:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# For bug fixes (1.0.0 -> 1.0.1)
|
|
159
|
+
yarn publish:patch
|
|
160
|
+
|
|
161
|
+
# For new features (1.0.0 -> 1.1.0)
|
|
162
|
+
yarn publish:minor
|
|
163
|
+
|
|
164
|
+
# For breaking changes (1.0.0 -> 2.0.0)
|
|
165
|
+
yarn publish:major
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Manual Publishing Steps
|
|
169
|
+
|
|
170
|
+
If you prefer manual control:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# 1. Login to npm (if not already logged in)
|
|
174
|
+
npm login
|
|
175
|
+
|
|
176
|
+
# 2. Update version and build
|
|
177
|
+
yarn version:patch # or version:minor, version:major
|
|
178
|
+
|
|
179
|
+
# 3. Publish to npm
|
|
180
|
+
npm publish
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### What Happens During Publishing
|
|
184
|
+
|
|
185
|
+
1. **Version Update**: Updates `package.json` version
|
|
186
|
+
2. **CSS Build**: Generates `dist/index.css` from Tailwind
|
|
187
|
+
3. **JS Build**: Creates `dist/index.js` and `dist/index.esm.js`
|
|
188
|
+
4. **Type Definitions**: Generates TypeScript declarations
|
|
189
|
+
5. **Publish**: Uploads to npm registry
|
|
190
|
+
|
|
191
|
+
### Pre-publish Hook
|
|
192
|
+
|
|
193
|
+
The `prepublishOnly` script ensures the package is always built before publishing, so you never publish outdated code.
|
|
194
|
+
|
|
195
|
+
### Internal Registry Setup
|
|
196
|
+
|
|
197
|
+
If using a private registry:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Configure npm registry
|
|
201
|
+
npm config set registry https://your-internal-registry.com
|
|
202
|
+
|
|
203
|
+
# Then use normal publish commands
|
|
204
|
+
yarn publish:patch
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Consumer Setup
|
|
208
|
+
|
|
209
|
+
After publishing, consumers can install and use the library:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Install the package
|
|
213
|
+
yarn add infinity-ui-elements
|
|
214
|
+
|
|
215
|
+
# Import components
|
|
216
|
+
import { Button } from 'infinity-ui-elements';
|
|
217
|
+
|
|
218
|
+
# Import CSS (required for styling)
|
|
219
|
+
import 'infinity-ui-elements/dist/index.css';
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Tailwind CSS Setup for Consumers
|
|
223
|
+
|
|
224
|
+
Consumers need to extend their Tailwind configuration to use the CSS variables:
|
|
225
|
+
|
|
226
|
+
```js
|
|
227
|
+
// tailwind.config.js
|
|
228
|
+
module.exports = {
|
|
229
|
+
content: [
|
|
230
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
231
|
+
'./node_modules/infinity-ui-elements/dist/**/*.{js,ts,jsx,tsx}',
|
|
232
|
+
],
|
|
233
|
+
theme: {
|
|
234
|
+
extend: {
|
|
235
|
+
colors: {
|
|
236
|
+
primary: 'var(--color-primary)',
|
|
237
|
+
secondary: 'var(--color-secondary)',
|
|
238
|
+
success: 'var(--color-success)',
|
|
239
|
+
danger: 'var(--color-danger)',
|
|
240
|
+
warning: 'var(--color-warning)',
|
|
241
|
+
info: 'var(--color-info)',
|
|
242
|
+
light: 'var(--color-light)',
|
|
243
|
+
dark: 'var(--color-dark)',
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
plugins: [],
|
|
248
|
+
};
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Important**: Make sure to import the design system's CSS file in your application:
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
// In your main App.tsx or index.tsx
|
|
255
|
+
import 'infinity-ui-elements/dist/index.css';
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Design Tokens
|
|
259
|
+
|
|
260
|
+
The design system uses CSS custom properties (variables) defined in the CSS file:
|
|
261
|
+
|
|
262
|
+
**Colors:**
|
|
263
|
+
- `--color-primary`: #007bff (Blue)
|
|
264
|
+
- `--color-secondary`: #6c757d (Gray)
|
|
265
|
+
- `--color-success`: #28a745 (Green)
|
|
266
|
+
- `--color-danger`: #dc3545 (Red)
|
|
267
|
+
- `--color-warning`: #ffc107 (Yellow)
|
|
268
|
+
- `--color-info`: #17a2b8 (Cyan)
|
|
269
|
+
- `--color-light`: #f8f9fa (Light Gray)
|
|
270
|
+
- `--color-dark`: #343a40 (Dark Gray)
|
|
271
|
+
|
|
272
|
+
**Spacing:**
|
|
273
|
+
- `--spacing-18`: 4.5rem
|
|
274
|
+
- `--spacing-88`: 22rem
|
|
275
|
+
|
|
276
|
+
These variables are automatically mapped to Tailwind classes (e.g., `bg-primary`, `text-secondary`) and can be customized by overriding the CSS variables in your application.
|
|
277
|
+
|
|
278
|
+
## Contributing
|
|
279
|
+
|
|
280
|
+
1. **Add new components**:
|
|
281
|
+
- Create component folder in `src/components/`
|
|
282
|
+
- Implement component with TypeScript
|
|
283
|
+
- Add Storybook stories
|
|
284
|
+
- Export from main index
|
|
285
|
+
|
|
286
|
+
2. **Component guidelines**:
|
|
287
|
+
- Use Tailwind CSS for styling
|
|
288
|
+
- Follow TypeScript strict mode
|
|
289
|
+
- Include proper prop types
|
|
290
|
+
- Add Storybook stories with controls
|
|
291
|
+
- Export from barrel files
|
|
292
|
+
|
|
293
|
+
3. **Example component structure**:
|
|
294
|
+
```
|
|
295
|
+
src/components/Input/
|
|
296
|
+
├── Input.tsx
|
|
297
|
+
├── Input.stories.tsx
|
|
298
|
+
└── index.ts
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Scripts
|
|
302
|
+
|
|
303
|
+
- `yarn build` - Build the library for production
|
|
304
|
+
- `yarn storybook` - Start Storybook development server
|
|
305
|
+
- `yarn build-storybook` - Build static Storybook
|
|
306
|
+
- `yarn type-check` - Run TypeScript type checking
|
|
307
|
+
- `yarn clean` - Remove build artifacts
|
|
308
|
+
|
|
309
|
+
## License
|
|
310
|
+
|
|
311
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ButtonProps {
|
|
3
|
+
variant?: "primary" | "secondary";
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const Button: React.FC<ButtonProps>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwBxC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Button } from "./Button";
|
|
3
|
+
declare const meta: Meta<typeof Button>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
|
8
|
+
export declare const Disabled: Story;
|
|
9
|
+
export declare const AllVariants: Story;
|
|
10
|
+
//# sourceMappingURL=Button.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAoB7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAKvB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAMtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAUzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! tailwindcss v4.1.15 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial;--tw-duration:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-blue-600:oklch(54.6% .245 262.881);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-600:oklch(44.6% .03 256.802);--color-white:#fff;--spacing:.25rem;--font-weight-semibold:600;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.static{position:static}.flex{display:flex}.gap-4{gap:calc(var(--spacing)*4)}.rounded{border-radius:.25rem}.bg-primary{background-color:var(--color-primary)}.bg-secondary{background-color:var(--color-secondary)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-2{padding-block:calc(var(--spacing)*2)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-secondary{color:var(--color-secondary)}.text-white{color:var(--color-white)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}@media (hover:hover){.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-gray-600:hover{background-color:var(--color-gray-600)}}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-primary:focus{--tw-ring-color:var(--color-primary)}.focus\:ring-secondary:focus{--tw-ring-color:var(--color-secondary)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-gray-400:disabled{background-color:var(--color-gray-400)}}:root{--color-primary:#007bff;--color-secondary:#6c757d;--color-success:#28a745;--color-danger:#dc3545;--color-warning:#ffc107;--color-info:#17a2b8;--color-light:#f8f9fa;--color-dark:#343a40;--spacing-18:4.5rem;--spacing-88:22rem}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const Button = ({ variant = "primary", children, onClick, disabled = false, className = "", }) => {
|
|
4
|
+
const baseClasses = "px-4 py-2 rounded font-semibold transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2";
|
|
5
|
+
const variantClasses = {
|
|
6
|
+
primary: "bg-primary text-white hover:bg-blue-600 focus:ring-primary disabled:bg-gray-400 disabled:cursor-not-allowed",
|
|
7
|
+
secondary: "bg-secondary text-white hover:bg-gray-600 focus:ring-secondary disabled:bg-gray-400 disabled:cursor-not-allowed",
|
|
8
|
+
};
|
|
9
|
+
const combinedClasses = `${baseClasses} ${variantClasses[variant]} ${className}`;
|
|
10
|
+
return (jsx("button", { className: combinedClasses, onClick: onClick, disabled: disabled, children: children }));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { Button };
|
|
14
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/Button/Button.tsx"],"sourcesContent":["import React from \"react\";\n\ninterface ButtonProps {\n variant?: \"primary\" | \"secondary\";\n children: React.ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n className?: string;\n}\n\nexport const Button: React.FC<ButtonProps> = ({\n variant = \"primary\",\n children,\n onClick,\n disabled = false,\n className = \"\",\n}) => {\n const baseClasses =\n \"px-4 py-2 rounded font-semibold transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2\";\n\n const variantClasses = {\n primary:\n \"bg-primary text-white hover:bg-blue-600 focus:ring-primary disabled:bg-gray-400 disabled:cursor-not-allowed\",\n secondary:\n \"bg-secondary text-white hover:bg-gray-600 focus:ring-secondary disabled:bg-gray-400 disabled:cursor-not-allowed\",\n };\n\n const combinedClasses = `${baseClasses} ${variantClasses[variant]} ${className}`;\n\n return (\n <button className={combinedClasses} onClick={onClick} disabled={disabled}>\n {children}\n </button>\n );\n};\n"],"names":["_jsx"],"mappings":";;MAUa,MAAM,GAA0B,CAAC,EAC5C,OAAO,GAAG,SAAS,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,EAAE,GACf,KAAI;IACH,MAAM,WAAW,GACf,oHAAoH;AAEtH,IAAA,MAAM,cAAc,GAAG;AACrB,QAAA,OAAO,EACL,6GAA6G;AAC/G,QAAA,SAAS,EACP,iHAAiH;KACpH;AAED,IAAA,MAAM,eAAe,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,cAAc,CAAC,OAAO,CAAC,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE;AAEhF,IAAA,QACEA,GAAA,CAAA,QAAA,EAAA,EAAQ,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,YACrE,QAAQ,EAAA,CACF;AAEb;;;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
const Button = ({ variant = "primary", children, onClick, disabled = false, className = "", }) => {
|
|
6
|
+
const baseClasses = "px-4 py-2 rounded font-semibold transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2";
|
|
7
|
+
const variantClasses = {
|
|
8
|
+
primary: "bg-primary text-white hover:bg-blue-600 focus:ring-primary disabled:bg-gray-400 disabled:cursor-not-allowed",
|
|
9
|
+
secondary: "bg-secondary text-white hover:bg-gray-600 focus:ring-secondary disabled:bg-gray-400 disabled:cursor-not-allowed",
|
|
10
|
+
};
|
|
11
|
+
const combinedClasses = `${baseClasses} ${variantClasses[variant]} ${className}`;
|
|
12
|
+
return (jsxRuntime.jsx("button", { className: combinedClasses, onClick: onClick, disabled: disabled, children: children }));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.Button = Button;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/components/Button/Button.tsx"],"sourcesContent":["import React from \"react\";\n\ninterface ButtonProps {\n variant?: \"primary\" | \"secondary\";\n children: React.ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n className?: string;\n}\n\nexport const Button: React.FC<ButtonProps> = ({\n variant = \"primary\",\n children,\n onClick,\n disabled = false,\n className = \"\",\n}) => {\n const baseClasses =\n \"px-4 py-2 rounded font-semibold transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2\";\n\n const variantClasses = {\n primary:\n \"bg-primary text-white hover:bg-blue-600 focus:ring-primary disabled:bg-gray-400 disabled:cursor-not-allowed\",\n secondary:\n \"bg-secondary text-white hover:bg-gray-600 focus:ring-secondary disabled:bg-gray-400 disabled:cursor-not-allowed\",\n };\n\n const combinedClasses = `${baseClasses} ${variantClasses[variant]} ${className}`;\n\n return (\n <button className={combinedClasses} onClick={onClick} disabled={disabled}>\n {children}\n </button>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;MAUa,MAAM,GAA0B,CAAC,EAC5C,OAAO,GAAG,SAAS,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,EAAE,GACf,KAAI;IACH,MAAM,WAAW,GACf,oHAAoH;AAEtH,IAAA,MAAM,cAAc,GAAG;AACrB,QAAA,OAAO,EACL,6GAA6G;AAC/G,QAAA,SAAS,EACP,iHAAiH;KACpH;AAED,IAAA,MAAM,eAAe,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,cAAc,CAAC,OAAO,CAAC,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE;AAEhF,IAAA,QACEA,cAAA,CAAA,QAAA,EAAA,EAAQ,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,YACrE,QAAQ,EAAA,CACF;AAEb;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "infinity-ui-elements",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A React TypeScript component library with Tailwind CSS design system",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "yarn build:css && rollup -c",
|
|
14
|
+
"build:css": "tailwindcss -i src/index.css -o dist/index.css --minify",
|
|
15
|
+
"storybook": "storybook dev -p 6006",
|
|
16
|
+
"build-storybook": "storybook build",
|
|
17
|
+
"type-check": "tsc --noEmit",
|
|
18
|
+
"clean": "rm -rf dist",
|
|
19
|
+
"prepublishOnly": "yarn build",
|
|
20
|
+
"version:patch": "yarn version patch && yarn build",
|
|
21
|
+
"version:minor": "yarn version minor && yarn build",
|
|
22
|
+
"version:major": "yarn version major && yarn build",
|
|
23
|
+
"publish:patch": "yarn version:patch && npm publish",
|
|
24
|
+
"publish:minor": "yarn version:minor && npm publish",
|
|
25
|
+
"publish:major": "yarn version:major && npm publish"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"react",
|
|
29
|
+
"typescript",
|
|
30
|
+
"tailwind",
|
|
31
|
+
"design-system",
|
|
32
|
+
"components",
|
|
33
|
+
"ui",
|
|
34
|
+
"ui-elements",
|
|
35
|
+
"infinityapp"
|
|
36
|
+
],
|
|
37
|
+
"author": "Himanshu Barmola",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^18.0.0",
|
|
44
|
+
"react-dom": "^18.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
48
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
49
|
+
"@storybook/addon-essentials": "^8.6.14",
|
|
50
|
+
"@storybook/addon-interactions": "^8.6.14",
|
|
51
|
+
"@storybook/react": "^8.6.14",
|
|
52
|
+
"@storybook/react-vite": "^8.6.14",
|
|
53
|
+
"@storybook/test": "^8.6.14",
|
|
54
|
+
"@tailwindcss/cli": "^4.1.15",
|
|
55
|
+
"@tailwindcss/postcss": "^4.0.0",
|
|
56
|
+
"@types/react": "^18.3.26",
|
|
57
|
+
"@types/react-dom": "^18.3.7",
|
|
58
|
+
"autoprefixer": "^10.4.21",
|
|
59
|
+
"postcss": "^8.5.6",
|
|
60
|
+
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
|
+
"rollup": "^4.52.5",
|
|
63
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
64
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
65
|
+
"storybook": "^8.6.14",
|
|
66
|
+
"tailwindcss": "^4.0.0",
|
|
67
|
+
"typescript": "^5.9.3",
|
|
68
|
+
"vite": "^5.4.21"
|
|
69
|
+
},
|
|
70
|
+
"packageManager": "yarn@4.5.2"
|
|
71
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { fn } from "@storybook/test";
|
|
3
|
+
import { Button } from "./Button";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
title: "Components/Button",
|
|
7
|
+
component: Button,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
},
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
control: { type: "select" },
|
|
15
|
+
options: ["primary", "secondary"],
|
|
16
|
+
},
|
|
17
|
+
disabled: {
|
|
18
|
+
control: { type: "boolean" },
|
|
19
|
+
},
|
|
20
|
+
children: {
|
|
21
|
+
control: { type: "text" },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
args: { onClick: fn() },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
type Story = StoryObj<typeof meta>;
|
|
29
|
+
|
|
30
|
+
export const Primary: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
variant: "primary",
|
|
33
|
+
children: "Primary Button",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Secondary: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
variant: "secondary",
|
|
40
|
+
children: "Secondary Button",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Disabled: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
variant: "primary",
|
|
47
|
+
children: "Disabled Button",
|
|
48
|
+
disabled: true,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const AllVariants: Story = {
|
|
53
|
+
render: () => (
|
|
54
|
+
<div className="flex gap-4">
|
|
55
|
+
<Button variant="primary">Primary</Button>
|
|
56
|
+
<Button variant="secondary">Secondary</Button>
|
|
57
|
+
<Button variant="primary" disabled>
|
|
58
|
+
Disabled
|
|
59
|
+
</Button>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface ButtonProps {
|
|
4
|
+
variant?: "primary" | "secondary";
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Button: React.FC<ButtonProps> = ({
|
|
12
|
+
variant = "primary",
|
|
13
|
+
children,
|
|
14
|
+
onClick,
|
|
15
|
+
disabled = false,
|
|
16
|
+
className = "",
|
|
17
|
+
}) => {
|
|
18
|
+
const baseClasses =
|
|
19
|
+
"px-4 py-2 rounded font-semibold transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2";
|
|
20
|
+
|
|
21
|
+
const variantClasses = {
|
|
22
|
+
primary:
|
|
23
|
+
"bg-primary text-white hover:bg-blue-600 focus:ring-primary disabled:bg-gray-400 disabled:cursor-not-allowed",
|
|
24
|
+
secondary:
|
|
25
|
+
"bg-secondary text-white hover:bg-gray-600 focus:ring-secondary disabled:bg-gray-400 disabled:cursor-not-allowed",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const combinedClasses = `${baseClasses} ${variantClasses[variant]} ${className}`;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<button className={combinedClasses} onClick={onClick} disabled={disabled}>
|
|
32
|
+
{children}
|
|
33
|
+
</button>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from "./Button";
|
package/src/index.css
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
/* Design System Colors */
|
|
5
|
+
--color-primary: #007bff;
|
|
6
|
+
--color-secondary: #6c757d;
|
|
7
|
+
--color-success: #28a745;
|
|
8
|
+
--color-danger: #dc3545;
|
|
9
|
+
--color-warning: #ffc107;
|
|
10
|
+
--color-info: #17a2b8;
|
|
11
|
+
--color-light: #f8f9fa;
|
|
12
|
+
--color-dark: #343a40;
|
|
13
|
+
|
|
14
|
+
/* Design System Spacing */
|
|
15
|
+
--spacing-18: 4.5rem;
|
|
16
|
+
--spacing-88: 22rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Map CSS variables to Tailwind utilities */
|
|
20
|
+
@utility bg-primary { background-color: var(--color-primary); }
|
|
21
|
+
@utility bg-secondary { background-color: var(--color-secondary); }
|
|
22
|
+
@utility bg-success { background-color: var(--color-success); }
|
|
23
|
+
@utility bg-danger { background-color: var(--color-danger); }
|
|
24
|
+
@utility bg-warning { background-color: var(--color-warning); }
|
|
25
|
+
@utility bg-info { background-color: var(--color-info); }
|
|
26
|
+
@utility bg-light { background-color: var(--color-light); }
|
|
27
|
+
@utility bg-dark { background-color: var(--color-dark); }
|
|
28
|
+
|
|
29
|
+
@utility text-primary { color: var(--color-primary); }
|
|
30
|
+
@utility text-secondary { color: var(--color-secondary); }
|
|
31
|
+
@utility text-success { color: var(--color-success); }
|
|
32
|
+
@utility text-danger { color: var(--color-danger); }
|
|
33
|
+
@utility text-warning { color: var(--color-warning); }
|
|
34
|
+
@utility text-info { color: var(--color-info); }
|
|
35
|
+
@utility text-light { color: var(--color-light); }
|
|
36
|
+
@utility text-dark { color: var(--color-dark); }
|
|
37
|
+
|
|
38
|
+
@utility border-primary { border-color: var(--color-primary); }
|
|
39
|
+
@utility border-secondary { border-color: var(--color-secondary); }
|
|
40
|
+
@utility border-success { border-color: var(--color-success); }
|
|
41
|
+
@utility border-danger { border-color: var(--color-danger); }
|
|
42
|
+
@utility border-warning { border-color: var(--color-warning); }
|
|
43
|
+
@utility border-info { border-color: var(--color-info); }
|
|
44
|
+
@utility border-light { border-color: var(--color-light); }
|
|
45
|
+
@utility border-dark { border-color: var(--color-dark); }
|
|
46
|
+
|
|
47
|
+
@utility ring-primary { --tw-ring-color: var(--color-primary); }
|
|
48
|
+
@utility ring-secondary { --tw-ring-color: var(--color-secondary); }
|
|
49
|
+
@utility ring-success { --tw-ring-color: var(--color-success); }
|
|
50
|
+
@utility ring-danger { --tw-ring-color: var(--color-danger); }
|
|
51
|
+
@utility ring-warning { --tw-ring-color: var(--color-warning); }
|
|
52
|
+
@utility ring-info { --tw-ring-color: var(--color-info); }
|
|
53
|
+
@utility ring-light { --tw-ring-color: var(--color-light); }
|
|
54
|
+
@utility ring-dark { --tw-ring-color: var(--color-dark); }
|
package/src/index.ts
ADDED