@aurora-ds/theme 1.0.3

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.dev.md ADDED
@@ -0,0 +1,342 @@
1
+ # Aurora Theme - Developer Guide
2
+
3
+ This document is intended for developers who want to contribute to the Aurora Theme library.
4
+
5
+ ## Prerequisites
6
+
7
+ - **Node.js** >= 18.0.0
8
+ - **npm** >= 10.9.0
9
+ - **React** >= 18.0.0 (peer dependency)
10
+
11
+ ## Project Setup
12
+
13
+ ```bash
14
+ # Clone the repository
15
+ git clone https://github.com/LilianMrzt/Aurora.git
16
+ cd Aurora
17
+
18
+ # Install dependencies
19
+ npm install
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Available Scripts
25
+
26
+ | Script | Command | Description |
27
+ |--------|---------|-------------|
28
+ | `dev` | `npm run dev` | Build in watch mode (development) |
29
+ | `build` | `npm run build` | Production build |
30
+ | `test` | `npm test` | Run tests in watch mode |
31
+ | `test:run` | `npm run test:run` | Run tests once |
32
+ | `test:coverage` | `npm run test:coverage` | Tests with coverage report |
33
+ | `lint` | `npm run lint` | ESLint check |
34
+ | `lint:fix` | `npm run lint:fix` | Auto-fix ESLint issues |
35
+ | `typecheck` | `npm run typecheck` | TypeScript check |
36
+ | `size` | `npm run size` | Bundle size check |
37
+ | `audit` | `npm run audit` | Dependency security audit |
38
+ | `audit:fix` | `npm run audit:fix` | Auto-fix vulnerabilities |
39
+ | `validate` | `npm run validate` | Lint + TypeCheck + Tests |
40
+ | `ci` | `npm run ci` | Full CI pipeline |
41
+
42
+ ---
43
+
44
+ ## Project Structure
45
+
46
+ ```
47
+ aurora/
48
+ ├── src/ # Source code
49
+ │ ├── index.ts # Main entry point (exports)
50
+ │ ├── providers/ # React Context providers
51
+ │ │ ├── ThemeProvider.tsx
52
+ │ │ └── index.ts
53
+ │ ├── types/ # TypeScript types
54
+ │ │ ├── colors/ # Color types
55
+ │ │ ├── palettes/ # Palette types
56
+ │ │ └── theme/ # Theme types
57
+ │ └── utils/ # Utilities
58
+ │ ├── styles/ # CSS-in-JS style utilities
59
+ │ └── theme/ # Theme creation utilities
60
+ ├── tests/ # Unit tests
61
+ │ ├── setup.ts # Vitest configuration
62
+ │ ├── providers/ # Provider tests
63
+ │ └── utils/ # Utility tests
64
+ ├── dist/ # Production build (generated)
65
+ ├── coverage/ # Coverage report (generated)
66
+ ├── tsconfig.json # Main TS config
67
+ ├── tsconfig.build.json # Build TS config
68
+ ├── tsconfig.test.json # Test TS config
69
+ ├── tsup.config.ts # Bundler config
70
+ ├── vitest.config.ts # Test config
71
+ └── package.json
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Development
77
+
78
+ ### Start Development Mode
79
+
80
+ ```bash
81
+ npm run dev
82
+ ```
83
+
84
+ This launches `tsup` in watch mode which automatically recompiles on every change.
85
+
86
+ ### Run Tests
87
+
88
+ ```bash
89
+ # Watch mode (development)
90
+ npm test
91
+
92
+ # Single run
93
+ npm run test:run
94
+
95
+ # With coverage
96
+ npm run test:coverage
97
+ ```
98
+
99
+ ### Code Verification
100
+
101
+ ```bash
102
+ # Check everything at once
103
+ npm run validate
104
+
105
+ # Or separately
106
+ npm run lint # ESLint
107
+ npm run typecheck # TypeScript
108
+ npm run test:run # Tests
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Build & Publishing
114
+
115
+ ### Production Build
116
+
117
+ ```bash
118
+ npm run build
119
+ ```
120
+
121
+ The build generates in `dist/`:
122
+ - `index.js` - ESM module
123
+ - `index.cjs` - CommonJS module
124
+ - `index.d.ts` - TypeScript types
125
+ - `index.d.cts` - CommonJS types
126
+
127
+ ### Pre-publish Verification
128
+
129
+ ```bash
130
+ # Full CI pipeline
131
+ npm run ci
132
+ ```
133
+
134
+ This command runs:
135
+ 1. `lint` - Code verification
136
+ 2. `typecheck` - Type checking
137
+ 3. `test:run` - Test execution
138
+ 4. `build` - Production build
139
+ 5. `size` - Size check (< 10 KB gzipped)
140
+ 6. `audit` - Security audit
141
+
142
+ ### Publishing to npm
143
+
144
+ ```bash
145
+ # 1. Update version in package.json
146
+ # 2. Update CHANGELOG.md
147
+ # 3. Commit and tag
148
+
149
+ npm version patch # or minor, major
150
+ git push --follow-tags
151
+
152
+ # 4. Publish
153
+ npm publish --access public
154
+ ```
155
+
156
+ > Note: `prepublishOnly` automatically runs `npm run ci` before publishing.
157
+
158
+ ---
159
+
160
+ ## Updating the Library
161
+
162
+ ### Updating Dependencies
163
+
164
+ ```bash
165
+ # View available updates
166
+ npm outdated
167
+
168
+ # Update dependencies
169
+ npm update
170
+
171
+ # Or to update to latest major versions
172
+ npx npm-check-updates -u
173
+ npm install
174
+ ```
175
+
176
+ ### After an Update
177
+
178
+ 1. **Run full validation:**
179
+ ```bash
180
+ npm run validate
181
+ ```
182
+
183
+ 2. **Check bundle size:**
184
+ ```bash
185
+ npm run size
186
+ ```
187
+
188
+ 3. **Check for vulnerabilities:**
189
+ ```bash
190
+ npm run audit
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Adding a New Feature
196
+
197
+ ### 1. Create Types (if needed)
198
+
199
+ Add in `src/types/`:
200
+
201
+ ```typescript
202
+ // src/types/theme/NewFeature.ts
203
+ export interface NewFeature {
204
+ // ...
205
+ }
206
+ ```
207
+
208
+ Export in `src/types/index.ts`.
209
+
210
+ ### 2. Create the Utility
211
+
212
+ Add in `src/utils/`:
213
+
214
+ ```typescript
215
+ // src/utils/newFeature.ts
216
+ export const newFeature = () => {
217
+ // ...
218
+ }
219
+ ```
220
+
221
+ Export in `src/utils/index.ts` and `src/index.ts`.
222
+
223
+ ### 3. Write Tests
224
+
225
+ ```typescript
226
+ // tests/utils/newFeature.test.ts
227
+ import { describe, it, expect } from 'vitest'
228
+ import { newFeature } from '@/utils/newFeature'
229
+
230
+ describe('newFeature', () => {
231
+ it('should ...', () => {
232
+ expect(newFeature()).toBe(...)
233
+ })
234
+ })
235
+ ```
236
+
237
+ ### 4. Update Documentation
238
+
239
+ - Update `README.md` with the public API
240
+ - Update `CHANGELOG.md` in the `[Unreleased]` section
241
+
242
+ ---
243
+
244
+ ## Code Conventions
245
+
246
+ ### Commits
247
+
248
+ Use the [Conventional Commits](https://www.conventionalcommits.org/) format:
249
+
250
+ ```
251
+ feat: add new color palette
252
+ fix: resolve caching issue
253
+ docs: update README
254
+ test: add unit tests for createTheme
255
+ refactor: improve style engine performance
256
+ chore: update dependencies
257
+ ```
258
+
259
+ ### Code Style
260
+
261
+ - **Indentation**: 4 spaces
262
+ - **Quotes**: Single `'`
263
+ - **Semicolons**: No
264
+ - **Trailing comma**: Yes
265
+
266
+ ESLint and TypeScript are configured to validate these rules.
267
+
268
+ ### Exports
269
+
270
+ All public exports must be in `src/index.ts`:
271
+
272
+ ```typescript
273
+ // Types
274
+ export type { Theme, BaseColors, ... } from './types'
275
+
276
+ // Providers
277
+ export { ThemeProvider, useTheme } from './providers'
278
+
279
+ // Utils
280
+ export { createStyles, createTheme, ... } from './utils'
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Size Limits
286
+
287
+ The bundle must stay under **10 KB gzipped** for each format:
288
+
289
+ ```json
290
+ "size-limit": [
291
+ { "path": "dist/index.js", "limit": "10 KB", "gzip": true },
292
+ { "path": "dist/index.cjs", "limit": "10 KB", "gzip": true }
293
+ ]
294
+ ```
295
+
296
+ If the limit is exceeded:
297
+ - Optimize the code
298
+ - Use tree-shaking
299
+ - Avoid unnecessary dependencies
300
+
301
+ ---
302
+
303
+ ## Test Coverage
304
+
305
+ Target: **> 80%** coverage.
306
+
307
+ Reports are generated in `coverage/`:
308
+ - `coverage/index.html` - Interactive HTML report
309
+ - `coverage/coverage-final.json` - Raw data
310
+
311
+ ---
312
+
313
+ ## Security
314
+
315
+ See [SECURITY.md](./SECURITY.md) for:
316
+ - Supported versions
317
+ - How to report a vulnerability
318
+ - Project security practices
319
+
320
+ ### Key Points
321
+
322
+ - **No `eval()`** or `Function()` constructor
323
+ - **CSS sanitization** to prevent injections
324
+ - **Regular auditing** of dependencies
325
+
326
+ ---
327
+
328
+ ## Resources
329
+
330
+ - [TypeScript Handbook](https://www.typescriptlang.org/docs/)
331
+ - [Vitest Documentation](https://vitest.dev/)
332
+ - [tsup Documentation](https://tsup.egoist.dev/)
333
+ - [ESLint Rules](https://eslint.org/docs/rules/)
334
+
335
+ ---
336
+
337
+ ## Contact
338
+
339
+ For any development questions:
340
+ - Email: lilian.marzet@gmail.com
341
+ - Issues: [GitHub Issues](https://github.com/LilianMrzt/Aurora/issues)
342
+
package/README.md ADDED
@@ -0,0 +1,390 @@
1
+ # Aurora Theme
2
+
3
+ A performant, type-safe, and **fully customizable** CSS-in-JS theme management library for React applications.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Modular Theming** - Customize colors, spacing, or any token independently
8
+ - 🎯 **Color Scales** - 20 color palettes with 12 shades each (25-950)
9
+ - ⚡ **Optimized Performance** - LRU caching, static style deduplication
10
+ - 🖥️ **SSR Support** - Server-side rendering compatible
11
+ - 📦 **Lightweight** - No runtime dependencies besides React
12
+ - 🔒 **Type-safe** - Full TypeScript support with generics
13
+ - 🌗 **Dark Mode Ready** - Light and dark variants for all palettes
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @aurora-dev-ui/theme
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```tsx
24
+ import { defaultTheme, ThemeProvider, createStyles } from '@aurora-dev-ui/theme'
25
+
26
+ // 1. Wrap your app
27
+ <ThemeProvider theme={defaultTheme}>
28
+ <App />
29
+ </ThemeProvider>
30
+
31
+ // 2. Create styles
32
+ const STYLES = createStyles((theme) => ({
33
+ container: {
34
+ padding: theme.spacing.md,
35
+ backgroundColor: theme.colors.surface,
36
+ borderRadius: theme.radius.lg,
37
+ },
38
+ }))
39
+
40
+ // 3. Use in components
41
+ function MyComponent() {
42
+ return <div className={STYLES.container}>Hello!</div>
43
+ }
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Color Scales
49
+
50
+ Aurora provides **20 color scales** with **12 shades each** (25, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950).
51
+
52
+ ### Available Scales
53
+
54
+ **Neutrals**
55
+ - `gray` - Pure neutral, universal default
56
+ - `slate` - Cool/blue undertone, tech & corporate
57
+ - `stone` - Warm undertone, lifestyle & natural
58
+
59
+ **Colors**
60
+ - `red` `orange` `amber` `yellow` `lime` `green`
61
+ - `emerald` `teal` `cyan` `sky` `blue` `indigo`
62
+ - `violet` `purple` `fuchsia` `pink` `rose`
63
+
64
+ ### Usage
65
+
66
+ ```tsx
67
+ import { colors, indigo, emerald } from '@aurora-ui/theme'
68
+
69
+ // Via the colors object
70
+ colors.indigo[500] // '#6366f1'
71
+ colors.emerald[400] // '#34d399'
72
+ colors.gray[900] // '#18181b'
73
+
74
+ // Or import individual scales
75
+ indigo[600] // '#4f46e5'
76
+ emerald[50] // '#ecfdf5'
77
+
78
+ // Special values
79
+ colors.white // '#ffffff'
80
+ colors.black // '#000000'
81
+ colors.transparent // 'transparent'
82
+ ```
83
+
84
+ ### Build Custom Theme Colors
85
+
86
+ ```tsx
87
+ import { colors, defaultTheme, createTheme } from '@aurora-ui/theme'
88
+
89
+ const myTheme = createTheme(defaultTheme, {
90
+ colors: {
91
+ primary: colors.purple[500],
92
+ primaryHover: colors.purple[600],
93
+ primaryActive: colors.purple[700],
94
+ primarySubtle: colors.purple[50],
95
+ // ... other colors
96
+ }
97
+ })
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Theme Palettes (Presets)
103
+
104
+ Aurora includes **8 ready-to-use color palettes**, each with light and dark variants.
105
+
106
+ ### Available Palettes
107
+
108
+ | Palette | Style | Best For |
109
+ |---------|-------|----------|
110
+ | `indigo` | Modern, professional | SaaS, business apps |
111
+ | `rose` | Warm, friendly | Social, lifestyle |
112
+ | `emerald` | Fresh, natural | Health, fintech |
113
+ | `violet` | Creative, bold | Creative, gaming |
114
+ | `amber` | Energetic, warm | Food, education |
115
+ | `cyan` | Tech, modern | Tech, startups |
116
+ | `slate` | Minimal, corporate | Enterprise, B2B |
117
+ | `gray` | Ultra minimal | Portfolios, luxury |
118
+
119
+ ### Usage
120
+
121
+ ```tsx
122
+ import {
123
+ palettes,
124
+ roseLight,
125
+ roseDark,
126
+ createTheme,
127
+ defaultTheme
128
+ } from '@aurora-ui/theme'
129
+
130
+ // Option 1: Import directly
131
+ const roseTheme = createTheme(defaultTheme, { colors: roseLight })
132
+ const roseDarkTheme = createTheme(defaultTheme, { colors: roseDark })
133
+
134
+ // Option 2: Via palettes object
135
+ const theme = createTheme(defaultTheme, {
136
+ colors: palettes.emerald.light
137
+ })
138
+
139
+ // Option 3: Dynamic switching
140
+ const [isDark, setIsDark] = useState(false)
141
+ const theme = createTheme(defaultTheme, {
142
+ colors: palettes.violet[isDark ? 'dark' : 'light']
143
+ })
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Modular Customization
149
+
150
+ Customize only what you need - colors, spacing, or any individual token.
151
+
152
+ ### Available Presets
153
+
154
+ ```tsx
155
+ import {
156
+ // Complete themes
157
+ defaultTheme,
158
+ defaultDarkTheme,
159
+
160
+ // Individual presets
161
+ defaultColors,
162
+ defaultDarkColors,
163
+ defaultSpacing,
164
+ defaultRadius,
165
+ defaultShadows,
166
+ defaultFontSize,
167
+ defaultFontWeight,
168
+ defaultLineHeight,
169
+ defaultZIndex,
170
+ defaultTransition,
171
+ } from '@aurora-ui/theme'
172
+ ```
173
+
174
+ ### Customize Only Colors
175
+
176
+ ```tsx
177
+ import { defaultTheme, defaultColors, createTheme } from '@aurora-ui/theme'
178
+
179
+ const myTheme = createTheme(defaultTheme, {
180
+ colors: {
181
+ ...defaultColors,
182
+ primary: '#your-brand-color',
183
+ primaryHover: '#your-brand-hover',
184
+ },
185
+ })
186
+ ```
187
+
188
+ ### Customize Only Spacing
189
+
190
+ ```tsx
191
+ import { defaultTheme, defaultSpacing, createTheme } from '@aurora-ui/theme'
192
+
193
+ const myTheme = createTheme(defaultTheme, {
194
+ spacing: {
195
+ ...defaultSpacing,
196
+ md: '1.25rem', // Override medium
197
+ lg: '2rem', // Override large
198
+ },
199
+ })
200
+ ```
201
+
202
+ ### Mix and Match
203
+
204
+ ```tsx
205
+ import {
206
+ defaultSpacing,
207
+ defaultRadius,
208
+ defaultShadows,
209
+ emeraldLight,
210
+ createTheme,
211
+ defaultTheme,
212
+ } from '@aurora-ui/theme'
213
+
214
+ const myTheme = createTheme(defaultTheme, {
215
+ colors: emeraldLight, // Use emerald palette
216
+ spacing: defaultSpacing, // Keep default spacing
217
+ radius: {
218
+ ...defaultRadius,
219
+ md: '8px', // More rounded
220
+ },
221
+ })
222
+ ```
223
+
224
+ ---
225
+
226
+ ## Theme Structure
227
+
228
+ ### Colors
229
+
230
+ | Token | Description |
231
+ |-------|-------------|
232
+ | `primary`, `onPrimary`, `primaryHover`, `primaryActive`, `primarySubtle` | Primary brand color |
233
+ | `secondary`, `onSecondary`, `secondaryHover`, `secondaryActive`, `secondarySubtle` | Secondary actions |
234
+ | `accent`, `onAccent`, `accentHover`, `accentSubtle` | Accent/highlight |
235
+ | `background`, `surface`, `surfaceHover`, `surfaceActive`, `elevated`, `overlay` | Surfaces |
236
+ | `text`, `textSecondary`, `textTertiary`, `textInverse` | Text hierarchy |
237
+ | `border`, `borderHover`, `borderFocus`, `borderSubtle` | Borders |
238
+ | `success`, `warning`, `error`, `info` + variants | Semantic colors |
239
+ | `link`, `linkHover`, `linkVisited`, `focus` | Interactive |
240
+ | `disabled`, `disabledText` | Disabled states |
241
+
242
+ ### Spacing
243
+
244
+ ```tsx
245
+ spacing: {
246
+ none: '0',
247
+ xs: '0.25rem', // 4px
248
+ sm: '0.5rem', // 8px
249
+ md: '1rem', // 16px
250
+ lg: '1.5rem', // 24px
251
+ xl: '2rem', // 32px
252
+ }
253
+ ```
254
+
255
+ ### Other Tokens
256
+
257
+ | Token | Values |
258
+ |-------|--------|
259
+ | `radius` | `none`, `xs`, `sm`, `md`, `lg`, `xl`, `full` |
260
+ | `shadows` | `none`, `xs`, `sm`, `md`, `lg`, `xl` |
261
+ | `fontSize` | `xs`, `sm`, `md`, `lg`, `xl` |
262
+ | `fontWeight` | `light`, `regular`, `medium`, `semibold`, `bold` |
263
+ | `lineHeight` | `none`, `tight`, `normal`, `relaxed` |
264
+ | `zIndex` | `behind`, `base`, `dropdown`, `sticky`, `fixed`, `overlay`, `modal`, `popover`, `tooltip`, `toast` |
265
+ | `transition` | `fast`, `normal`, `slow` |
266
+
267
+ ---
268
+
269
+ ## Extending Types
270
+
271
+ Add custom tokens with full TypeScript support:
272
+
273
+ ```tsx
274
+ import type { BaseColors, ExtendTheme } from '@aurora-ui/theme'
275
+
276
+ // Extend colors
277
+ type MyColors = BaseColors & {
278
+ brand: string
279
+ brandHover: string
280
+ }
281
+
282
+ // Create extended theme type
283
+ type MyTheme = ExtendTheme<{
284
+ colors: MyColors
285
+ }>
286
+
287
+ // Use with type safety
288
+ const STYLES = createStyles<MyTheme>((theme) => ({
289
+ button: {
290
+ backgroundColor: theme.colors.brand, // ✅ TypeScript knows this!
291
+ },
292
+ }))
293
+
294
+ // Access in components
295
+ const theme = useTheme<MyTheme>()
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Dynamic Styles
301
+
302
+ ```tsx
303
+ const STYLES = createStyles((theme) => ({
304
+ button: (variant: 'primary' | 'secondary', size: 'sm' | 'md' | 'lg') => ({
305
+ backgroundColor: theme.colors[variant],
306
+ padding: theme.spacing[size],
307
+ borderRadius: theme.radius.md,
308
+ transition: theme.transition.fast,
309
+ }),
310
+ }))
311
+
312
+ // Usage
313
+ <button className={STYLES.button('primary', 'md')}>Click me</button>
314
+ ```
315
+
316
+ ---
317
+
318
+ ## SSR Support
319
+
320
+ ```tsx
321
+ import { getSSRStyles, clearSSRRules } from '@aurora-ui/theme'
322
+
323
+ // Server-side
324
+ const html = renderToString(<App />)
325
+ const styles = getSSRStyles()
326
+
327
+ const fullHtml = `
328
+ <!DOCTYPE html>
329
+ <html>
330
+ <head>
331
+ <style id="aurora-styles">${styles}</style>
332
+ </head>
333
+ <body>${html}</body>
334
+ </html>
335
+ `
336
+
337
+ clearSSRRules() // Reset for next request
338
+ ```
339
+
340
+ ---
341
+
342
+ ## API Reference
343
+
344
+ ### Types
345
+
346
+ | Type | Description |
347
+ |------|-------------|
348
+ | `Theme` | Complete theme structure |
349
+ | `BaseColors` | Color token type |
350
+ | `BaseSpacing` | Spacing token type |
351
+ | `ColorScale` | Color scale type (25-950) |
352
+ | `ColorName` | Union of color scale names |
353
+ | `PaletteName` | Union of palette names |
354
+ | `ExtendTheme<T>` | Helper to extend theme |
355
+ | `DeepPartial<T>` | For partial overrides |
356
+
357
+ ### Components & Hooks
358
+
359
+ | Export | Description |
360
+ |--------|-------------|
361
+ | `ThemeProvider` | Theme context provider |
362
+ | `useTheme<T>()` | Access current theme |
363
+
364
+ ### Styling
365
+
366
+ | Export | Description |
367
+ |--------|-------------|
368
+ | `createStyles<T>()` | Create themed styles |
369
+ | `keyframes()` | CSS keyframe animations |
370
+ | `fontFace()` | @font-face rules |
371
+ | `cssVariables()` | CSS custom properties |
372
+
373
+ ---
374
+
375
+ ## Contributing
376
+
377
+ Interested in contributing? Check out the [Developer Guide](./README.dev.md) for:
378
+
379
+ - Development setup
380
+ - Available scripts
381
+ - Project structure
382
+ - Coding conventions
383
+ - Publishing process
384
+
385
+ ---
386
+
387
+ ## License
388
+
389
+ MIT
390
+