@scalably/ui 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,326 @@
1
+ # Scalably UI Component Library
2
+
3
+ A modern, accessible, and fully isolated React component library built with TypeScript and Tailwind CSS. Designed to work seamlessly across multiple projects without style conflicts.
4
+
5
+ ## ๐Ÿš€ Features
6
+
7
+ - **Style Isolation**: All components use prefixed Tailwind classes (`sui-*`) to prevent conflicts
8
+ - **TypeScript First**: Full type safety with comprehensive prop interfaces
9
+ - **Accessible**: Built with accessibility best practices and WCAG compliance
10
+ - **Modern**: Uses latest React patterns and modern build tools (tsup, Vite, Storybook)
11
+ - **Customizable**: Flexible variant system with class-variance-authority
12
+ - **Comprehensive**: 20+ production-ready components with full documentation
13
+ - **Production Ready**: Complete build pipeline with CommonJS and ES modules
14
+
15
+ ## ๐Ÿ“ฆ Installation
16
+
17
+ ```bash
18
+ npm install @scalably/ui
19
+ ```
20
+
21
+ ## ๐ŸŽจ Usage
22
+
23
+ ### 1. Import the CSS
24
+
25
+ Add the component library styles to your main entry point:
26
+
27
+ ```tsx
28
+ // In your main.tsx, App.tsx, or index.tsx
29
+ import "@scalably/ui/styles";
30
+ ```
31
+
32
+ ### 2. Use Components
33
+
34
+ ```tsx
35
+ import "@scalably/ui/styles";
36
+ import { ScalablyUIProvider, Form, FormField, Input, Button, ToastContainer, Toast } from "@scalably/ui";
37
+
38
+ export default function App() {
39
+ return (
40
+ <ScalablyUIProvider>
41
+ <main>
42
+ <Form onSubmit={(e) => e.preventDefault()}>
43
+ <FormField label="Email" htmlFor="email">
44
+ <Input id="email" type="email" placeholder="Enter your email" />
45
+ </FormField>
46
+ <Button className="sui-mt-4" type="submit">Submit</Button>
47
+ </Form>
48
+
49
+ {/* Toasts */}
50
+ <ToastContainer />
51
+ <Toast status="success" title="Welcome" description="You're all set." />
52
+ </main>
53
+ </ScalablyUIProvider>
54
+ );
55
+ }
56
+ ```
57
+
58
+ ### 3. Add the provider once (recommended)
59
+
60
+ Instead of adding the `sui-scope` class manually, wrap your app with the provider:
61
+
62
+ ```tsx
63
+ import "@scalably/ui/styles";
64
+ import { ScalablyUIProvider } from "@scalably/ui";
65
+
66
+ export default function App() {
67
+ return <ScalablyUIProvider>{/* your app */}</ScalablyUIProvider>;
68
+ }
69
+ ```
70
+
71
+ Optional no extra DOM element:
72
+
73
+ ```tsx
74
+ <ScalablyUIProvider asChild>
75
+ <main>{/* your app */}</main>
76
+ {/* merges the scope onto <main> */}
77
+ </ScalablyUIProvider>
78
+ ```
79
+
80
+ ### 4. React import guidance
81
+
82
+ If you reference the React namespace (e.g., `React.useState`, `React.forwardRef`, `React.SVGProps`) add an explicit import to avoid UMD global errors:
83
+
84
+ ```ts
85
+ import * as React from "react";
86
+ ```
87
+
88
+ Alternatively, import only what you use with the automatic JSX runtime:
89
+
90
+ ```ts
91
+ import { useState, forwardRef } from "react";
92
+ import type { SVGProps } from "react";
93
+ ```
94
+
95
+ ### Helper Functions
96
+ - Date helpers: `addMonths`, `clampDate`, `daysGrid`, `endOfMonth`, `formatDateLocalized`, `isSameDay`, `monthsForLocale`, `startOfMonth`, `toDateKey`, `weekdaysForLocale`
97
+ - Form helpers: `fieldErrorToProps`, `zodErrorsToSummary` and `type FieldErrorLike`
98
+
99
+ ### Example Usage
100
+
101
+ ```tsx
102
+ import {
103
+ Button,
104
+ Input,
105
+ Select,
106
+ CheckboxGroup,
107
+ DatePicker,
108
+ Toast,
109
+ Pagination
110
+ } from '@scalably/ui'
111
+
112
+ // Button with variants
113
+ <Button variant="destructive">Delete</Button>
114
+ <Button variant="outline">Cancel</Button>
115
+ <Button loading>Loading...</Button>
116
+
117
+ // Input with validation
118
+ <Input
119
+ label="Email Address"
120
+ type="email"
121
+ placeholder="Enter your email"
122
+ error="Please enter a valid email"
123
+ />
124
+
125
+ // Date picker
126
+ <DatePicker
127
+ mode="single"
128
+ placeholder="Select a date"
129
+ onChange={(date) => console.log(date)}
130
+ />
131
+
132
+ // Toast notifications
133
+ <Toast
134
+ status="success"
135
+ title="Success!"
136
+ description="Your changes have been saved."
137
+ />
138
+ ```
139
+
140
+ ## ๐ŸŽจ Styling
141
+
142
+ ### Style Isolation
143
+
144
+ All components use prefixed Tailwind classes (`sui-*`) to ensure complete style isolation:
145
+
146
+ ```tsx
147
+ // โœ… Correct - components are properly isolated
148
+ <div className="sui-scope">
149
+ <Button>Isolated Button</Button>
150
+ </div>
151
+
152
+ // โŒ Avoid - mixing prefixed and non-prefixed classes
153
+ <div className="p-4"> {/* This won't conflict */}
154
+ <Button>Button with ui-* classes</Button>
155
+ </div>
156
+ ```
157
+
158
+ ### Custom Styling
159
+
160
+ You can still customize components using the `className` prop:
161
+
162
+ ```tsx
163
+ <Button className="sui-w-full sui-mt-4">Full Width Button</Button>
164
+ <Card className="sui-max-w-md sui-mx-auto">Centered Card</Card>
165
+ ```
166
+
167
+ ## ๐Ÿ›  Development
168
+
169
+ ### Prerequisites
170
+
171
+ - Node.js 18+
172
+ - npm or pnpm
173
+
174
+ ### Setup
175
+
176
+ ```bash
177
+ # Clone the repository
178
+ git clone git@github.com:quangnle/scalably-components.git
179
+ cd scalably-components
180
+
181
+ # Install dependencies
182
+ npm install
183
+
184
+ # Start Storybook for development
185
+ npm run storybook
186
+
187
+ # Build the library
188
+ npm run build
189
+
190
+ # Run tests
191
+ npm test
192
+ ```
193
+
194
+ ### Available Scripts
195
+
196
+ - `npm run dev` - Start development build with watch mode
197
+ - `npm run build` - Build the library for production
198
+ - `npm run build:css` - Build CSS styles separately
199
+ - `npm run storybook` - Start Storybook development server
200
+ - `npm run build-storybook` - Build Storybook for production
201
+ - `npm run lint` - Run ESLint
202
+ - `npm run lint:fix` - Run ESLint with auto-fix
203
+ - `npm run type-check` - Run TypeScript type checking
204
+ - `npm test` - Run tests
205
+ - `npm run test:watch` - Run tests in watch mode
206
+ - `npm run test:ci` - Run tests with coverage
207
+ - `npm run verify` - Run verification script
208
+ - `npm run clean` - Clean build artifacts
209
+
210
+ ## ๐Ÿ“š Documentation
211
+
212
+ Visit our Storybook documentation for:
213
+
214
+ - Interactive component playground
215
+ - Comprehensive prop documentation
216
+ - Usage examples and best practices
217
+ - Design system guidelines
218
+ - Accessibility testing with axe-core
219
+ - Design tokens and theming
220
+
221
+ ## ๐ŸŽจ Design System
222
+
223
+ ### Colors
224
+
225
+ - **Primary**: `#36499B` - Main brand color for primary actions
226
+ - **Secondary**: `#F2F6FC` - Light background colors with multiple levels
227
+ - **Success**: `#22BC4D` - Green for positive actions and success states
228
+ - **Warning**: `#FF7A00` - Orange for caution and in-progress states
229
+ - **Info**: `#2772F0` - Blue for informational content
230
+ - **Error**: `#EA3540` - Red for destructive actions and errors
231
+ - **Inactive**: `#777E90` - Gray for inactive or completed states
232
+ - **Disabled**: `#B2BBC7` - Light gray for disabled elements
233
+
234
+ ### Typography
235
+
236
+ - **Font Family**: Poppins (primary), Inter (fallback), system-ui
237
+ - **Font Sizes**: 12px, 14px, 16px, 20px, 24px with 150% line-height and -2% letter-spacing
238
+ - **Font Weights**: 400 (normal), 500 (medium), 600 (semibold), 700 (bold)
239
+
240
+ ## ๐Ÿ”ง Configuration
241
+
242
+ ### Tailwind Config
243
+
244
+ The library uses a custom Tailwind configuration with:
245
+
246
+ - **Prefix**: `sui-` for all utility classes
247
+ - **Important**: `.sui-scope` for style isolation
248
+ - **Custom Colors**: Brand-specific color palette
249
+ - **Custom Shadows**: Soft, medium, and strong shadow variants
250
+
251
+ ### Build Configuration
252
+
253
+ - **Bundler**: tsup for fast, modern builds
254
+ - **Formats**: CommonJS and ES modules with proper exports
255
+ - **TypeScript**: Full type definitions included
256
+ - **Tree Shaking**: Optimized for minimal bundle size
257
+ - **CSS**: Separate CSS build with Tailwind compilation
258
+ - **Source Maps**: Generated for debugging
259
+ - **Minification**: Production builds are minified
260
+
261
+ ## ๐Ÿ“ฆ Publishing
262
+
263
+ ### Version Management
264
+
265
+ We use semantic versioning (semver):
266
+
267
+ - **Major** (1.0.0): Breaking changes
268
+ - **Minor** (0.1.0): New features, backward compatible
269
+ - **Patch** (0.0.1): Bug fixes, backward compatible
270
+
271
+ ### Publishing Process
272
+
273
+ ```bash
274
+ # Build the library
275
+ npm run build
276
+
277
+ # Run tests
278
+ npm test
279
+
280
+ # Publish to registry
281
+ npm publish
282
+ ```
283
+
284
+ ### Development Guidelines
285
+
286
+ - Follow TypeScript best practices
287
+ - Write comprehensive Storybook stories
288
+ - Ensure accessibility compliance
289
+ - Add tests for new components
290
+ - Update documentation
291
+
292
+ ## ๐Ÿ“„ License
293
+
294
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
295
+
296
+ ## ๐Ÿ†˜ Support
297
+
298
+ - **Documentation**: Storybook (run `npm run storybook`)
299
+ - **Issues**: GitHub Issues
300
+ - **Discussions**: GitHub Discussions
301
+
302
+ ## ๐Ÿงช Testing
303
+
304
+ The library includes comprehensive testing setup:
305
+
306
+ - **Unit Tests**: Vitest with React Testing Library
307
+ - **Accessibility**: jest-axe for a11y testing
308
+ - **Coverage**: Built-in coverage reporting
309
+ - **CI/CD**: Automated testing pipeline
310
+
311
+ ## ๐Ÿ”ง Dependencies
312
+
313
+ ### Peer Dependencies
314
+ - React 18+
315
+ - React DOM 18+
316
+
317
+ ### Key Dependencies
318
+ - `@floating-ui/react` - Positioning for tooltips and popovers
319
+ - `class-variance-authority` - Component variant management
320
+ - `date-fns` - Date manipulation utilities
321
+ - `clsx` - Conditional class names
322
+ - `tailwind-merge` - Tailwind class merging
323
+
324
+ ---
325
+
326
+ Built with โค๏ธ by the Scalably team