auto-theme-js 1.0.2 → 1.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/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Gustavo Luiz Gregorio
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gustavo Luiz Gregorio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,311 +1,311 @@
1
- # AutoThemeJS
2
-
3
- [![npm version](https://img.shields.io/npm/v/auto-theme-js.svg)](https://www.npmjs.com/package/auto-theme-js)
4
- [![npm downloads](https://img.shields.io/npm/dm/auto-theme-js.svg)](https://www.npmjs.com/package/auto-theme-js)
5
- [![license](https://img.shields.io/npm/l/auto-theme-js.svg)](https://github.com/GustavoLGregorio/auto-theme-js/blob/main/LICENSE)
6
- [![GitHub stars](https://img.shields.io/github/stars/GustavoLGregorio/auto-theme-js.svg)](https://github.com/GustavoLGregorio/auto-theme-js/stargazers)
7
- [![GitHub issues](https://img.shields.io/github/issues/GustavoLGregorio/auto-theme-js.svg)](https://github.com/GustavoLGregorio/auto-theme-js/issues)
8
-
9
- <p align="center">
10
- <a href="https://auto-theme-js.vercel.app/" target="_blank"><strong>🌐 Live Demo</strong></a> â€Ē
11
- <a href="https://www.npmjs.com/package/auto-theme-js"><strong>ðŸ“Ķ npm</strong></a> â€Ē
12
- <a href="https://github.com/GustavoLGregorio/auto-theme-js"><strong>ðŸ’ŧ GitHub</strong></a>
13
- </p>
14
-
15
- Generate beautiful, harmonious color palettes from a single base color. AutoThemeJS creates complete design system color schemes with primary, secondary, tertiary, accent, and neutral color variants across 11 shade levels (50-950), similar to Tailwind CSS color scales.
16
-
17
- <p align="center">
18
- <img src="demo/img/demo_screenshot.png" alt="AutoThemeJS Demo Screenshot" width="800" />
19
- </p>
20
-
21
- ## âœĻ Features
22
-
23
- - ðŸŽĻ **Single Color Input** - Generate a complete color palette from just one color
24
- - 🌈 **Color Harmony** - Automatically creates harmonious color relationships (analogous, complementary)
25
- - 📊 **11 Shade Levels** - Each color includes shades from 50 (lightest) to 950 (darkest)
26
- - 🔄 **Multiple Color Formats** - Support for HEX, RGB, HSL, OKLCH, and OKLAB
27
- - ðŸ’ū **Serialization** - Serialize and deserialize themes for storage or transfer
28
- - 🏷ïļ **Versioning** - Built-in version tracking for stored themes
29
- - ðŸŠķ **Lightweight** - Zero dependencies, pure TypeScript
30
- - ðŸ“Ķ **TypeScript Ready** - Full type definitions included
31
-
32
- ## ðŸ“Ķ Installation
33
-
34
- ```bash
35
- npm install auto-theme-js
36
- ```
37
-
38
- ```bash
39
- yarn add auto-theme-js
40
- ```
41
-
42
- ```bash
43
- pnpm add auto-theme-js
44
- ```
45
-
46
- ## 🚀 Quick Start
47
-
48
- ```javascript
49
- import { AutoTheme } from 'auto-theme-js';
50
-
51
- // Create a theme from a hex color
52
- const theme = new AutoTheme('#8a00bd', 'hex', 'hex', '50', '950');
53
-
54
- // Access colors
55
- console.log(theme.primary['500']); // Primary color at shade 500
56
- console.log(theme.secondary['300']); // Secondary (analogous +30°) at shade 300
57
- console.log(theme.tertiary['700']); // Tertiary (analogous -30°) at shade 700
58
- console.log(theme.accent['500']); // Accent (complementary) at shade 500
59
- console.log(theme.neutral['900']); // Neutral (desaturated) at shade 900
60
-
61
- // Check version (useful for stored themes)
62
- console.log(theme.version); // e.g., 'V1'
63
- ```
64
-
65
- ## 📖 API Reference
66
-
67
- ### Constructor
68
-
69
- ```typescript
70
- new AutoTheme(color, inputType?, outputType?, minShade?, maxShade?)
71
- ```
72
-
73
- | Parameter | Type | Default | Description |
74
- |-----------|------|---------|-------------|
75
- | `color` | `Color` | required | The base color to generate the theme from |
76
- | `inputType` | `ColorType` | `'hex'` | Input color format: `'hex'`, `'rgb'`, `'hsl'`, `'oklch'`, `'oklab'` |
77
- | `outputType` | `ColorType` | `'hex'` | Output color format for all generated colors |
78
- | `minShade` | `Shade` | `'50'` | Minimum shade to generate |
79
- | `maxShade` | `Shade` | `'900'` | Maximum shade to generate |
80
-
81
- ### Theme Properties
82
-
83
- Each `AutoTheme` instance contains five color groups plus metadata:
84
-
85
- | Property | Description | Hue Rotation |
86
- |----------|-------------|--------------|
87
- | `primary` | Base color | 0° |
88
- | `secondary` | Analogous color | +30° |
89
- | `tertiary` | Analogous color | -30° |
90
- | `accent` | Complementary color | +180° |
91
- | `neutral` | Desaturated base | 0° (10% chroma) |
92
- | `version` | Library version | - |
93
- | `colorType` | Output color format | - |
94
- | `baseColor` | Original input color | - |
95
-
96
- ### Shade Levels
97
-
98
- Each color group contains shades from `50` to `950`:
99
-
100
- ```
101
- 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950
102
- ```
103
-
104
- - `50` - Lightest (97% lightness)
105
- - `500` - Base (55% lightness)
106
- - `950` - Darkest (8% lightness)
107
-
108
- ### Color Formats
109
-
110
- ```typescript
111
- type ColorType = 'hex' | 'rgb' | 'hsl' | 'oklch' | 'oklab';
112
- ```
113
-
114
- **Supported formats:**
115
-
116
- ```javascript
117
- // HEX
118
- '#8a00bd'
119
- '#8a00bdff' // alpha not supported yet in v1, so avoid transparency
120
-
121
- // RGB
122
- 'rgba(138, 0, 189, 1)'
123
-
124
- // HSL
125
- 'hsla(284, 100%, 37%, 1)'
126
-
127
- // OKLCH
128
- 'oklch(45.2% 0.234 303.4deg / 1)'
129
-
130
- // OKLAB
131
- 'oklab(45.2% 0.123 -0.098 / 1)'
132
- ```
133
-
134
- ## ðŸ’ū Serialization & Deserialization
135
-
136
- AutoThemeJS provides built-in methods to serialize themes for storage (localStorage, databases, etc.) and deserialize them back.
137
-
138
- ### Serialize
139
-
140
- ```javascript
141
- import { AutoTheme } from 'auto-theme-js';
142
-
143
- const theme = new AutoTheme('#8a00bd', 'hex', 'hex', '50', '950');
144
-
145
- // Serialize the theme to a string
146
- const serialized = AutoTheme.serialize(theme);
147
- console.log(serialized);
148
- // Output: "version:1.0.2|colorType:hex|baseColor:#8a00bd||primary:{50:#faf5ff|...}||..."
149
-
150
- // Store it
151
- localStorage.setItem('userTheme', serialized);
152
- ```
153
-
154
- ### Deserialize
155
-
156
- ```javascript
157
- // Retrieve from storage
158
- const serialized = localStorage.getItem('userTheme');
159
-
160
- // Deserialize back to a theme object
161
- const theme = AutoTheme.deserialize(serialized);
162
-
163
- // Use the theme
164
- console.log(theme.primary['500']); // #8a00bd
165
- console.log(theme.colorType); // 'hex'
166
- console.log(theme.baseColor); // '#8a00bd'
167
- console.log(theme.version); // '1.0.2'
168
- ```
169
-
170
- ### Version Checking
171
-
172
- The `version` property allows you to handle breaking changes when loading stored themes:
173
-
174
- ```javascript
175
- const theme = AutoTheme.deserialize(serialized);
176
-
177
- // Check if theme was created with a compatible version
178
- if (theme.version !== AutoTheme.VERSION) {
179
- console.log('Theme was created with a different version, consider regenerating');
180
- }
181
- ```
182
-
183
- ### Custom Escape Character
184
-
185
- If your color values might contain the default delimiter (`|`), you can specify a custom escape character:
186
-
187
- ```javascript
188
- // Serialize with custom delimiter
189
- const serialized = AutoTheme.serialize(theme, '*');
190
-
191
- // Deserialize with the same delimiter
192
- const theme = AutoTheme.deserialize(serialized, '*');
193
- ```
194
-
195
- ## ðŸŽŊ Usage Examples
196
-
197
- ### Dynamic Theme Application
198
-
199
- ```javascript
200
- import { AutoTheme } from 'auto-theme-js';
201
-
202
- function applyTheme(baseColor) {
203
- const theme = new AutoTheme(baseColor, 'hex', 'hex', '50', '950');
204
- const root = document.documentElement;
205
-
206
- // Apply CSS custom properties
207
- const properties = ['primary', 'secondary', 'tertiary', 'accent', 'neutral'];
208
- const shades = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'];
209
-
210
- for (const prop of properties) {
211
- for (const shade of shades) {
212
- root.style.setProperty(`--color-${prop}-${shade}`, theme[prop][shade]);
213
- }
214
- }
215
- }
216
-
217
- // Apply a purple theme
218
- applyTheme('#8a00bd');
219
- ```
220
-
221
- ### React Integration
222
-
223
- ```jsx
224
- import { AutoTheme } from 'auto-theme-js';
225
- import { useState, useEffect } from 'react';
226
-
227
- function ThemeProvider({ children, baseColor }) {
228
- const [theme, setTheme] = useState(null);
229
-
230
- useEffect(() => {
231
- const newTheme = new AutoTheme(baseColor, 'hex', 'hex', '50', '950');
232
- setTheme(newTheme);
233
-
234
- // Apply to CSS variables
235
- const root = document.documentElement;
236
- root.style.setProperty('--primary-500', newTheme.primary['500']);
237
- root.style.setProperty('--accent-500', newTheme.accent['500']);
238
- // ... more variables
239
- }, [baseColor]);
240
-
241
- return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
242
- }
243
- ```
244
-
245
- ### Different Output Formats
246
-
247
- ```javascript
248
- // Output as RGB
249
- const rgbTheme = new AutoTheme('#8a00bd', 'hex', 'rgb', '50', '950');
250
- console.log(rgbTheme.primary['500']); // 'rgba(138, 0, 189, 1)'
251
-
252
- // Output as HSL
253
- const hslTheme = new AutoTheme('#8a00bd', 'hex', 'hsl', '50', '950');
254
- console.log(hslTheme.primary['500']); // 'hsla(284, 100%, 37%, 1)'
255
-
256
- // Output as OKLCH (perceptually uniform)
257
- const oklchTheme = new AutoTheme('#8a00bd', 'hex', 'oklch', '50', '950');
258
- console.log(oklchTheme.primary['500']); // 'oklch(45.2% 0.234 303.4deg / 1)'
259
- ```
260
-
261
- ### Limited Shade Range
262
-
263
- ```javascript
264
- // Generate only shades 400-700 for a more focused palette
265
- const limitedTheme = new AutoTheme('#8a00bd', 'hex', 'hex', '400', '700');
266
-
267
- console.log(limitedTheme.primary['400']); // ✅ Available
268
- console.log(limitedTheme.primary['500']); // ✅ Available
269
- console.log(limitedTheme.primary['50']); // ❌ undefined (not in range)
270
- ```
271
-
272
- ## 🔧 TypeScript Support
273
-
274
- AutoThemeJS is written in TypeScript and includes full type definitions:
275
-
276
- ```typescript
277
- import { AutoTheme, Color, ColorType, Shade, ThemeProperties, Theme } from 'auto-theme-js';
278
-
279
- const color: Color = '#8a00bd';
280
- const theme: AutoTheme = new AutoTheme(color, 'hex', 'hex', '50', '950');
281
-
282
- // Type-safe access
283
- const primaryColor: Color = theme.primary['500'];
284
- const shade: Shade = '500';
285
- const property: ThemeProperties = 'primary';
286
- ```
287
-
288
- ## ðŸĪ Contributing
289
-
290
- Contributions are welcome! Please feel free to submit a Pull Request.
291
-
292
- 1. Fork the repository
293
- 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
294
- 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
295
- 4. Push to the branch (`git push origin feature/AmazingFeature`)
296
- 5. Open a Pull Request
297
-
298
- ## 📄 License
299
-
300
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
301
-
302
- ## 🔗 Links
303
-
304
- - [Live Demo](https://auto-theme-js.vercel.app/)
305
- - [npm Package](https://www.npmjs.com/package/auto-theme-js)
306
- - [GitHub Repository](https://github.com/GustavoLGregorio/auto-theme-js)
307
- - [Report Issues](https://github.com/GustavoLGregorio/auto-theme-js/issues)
308
-
309
- ---
310
-
311
- Made with âĪïļ by [Gustavo L. Gregorio](https://github.com/GustavoLGregorio)
1
+ # AutoThemeJS
2
+
3
+ [![npm version](https://img.shields.io/npm/v/auto-theme-js.svg)](https://www.npmjs.com/package/auto-theme-js)
4
+ [![npm downloads](https://img.shields.io/npm/dm/auto-theme-js.svg)](https://www.npmjs.com/package/auto-theme-js)
5
+ [![license](https://img.shields.io/npm/l/auto-theme-js.svg)](https://github.com/GustavoLGregorio/auto-theme-js/blob/main/LICENSE)
6
+ [![GitHub stars](https://img.shields.io/github/stars/GustavoLGregorio/auto-theme-js.svg)](https://github.com/GustavoLGregorio/auto-theme-js/stargazers)
7
+ [![GitHub issues](https://img.shields.io/github/issues/GustavoLGregorio/auto-theme-js.svg)](https://github.com/GustavoLGregorio/auto-theme-js/issues)
8
+
9
+ <p align="center">
10
+ <a href="https://auto-theme-js.vercel.app/" target="_blank"><strong>🌐 Live Demo</strong></a> â€Ē
11
+ <a href="https://www.npmjs.com/package/auto-theme-js"><strong>ðŸ“Ķ npm</strong></a> â€Ē
12
+ <a href="https://github.com/GustavoLGregorio/auto-theme-js"><strong>ðŸ’ŧ GitHub</strong></a>
13
+ </p>
14
+
15
+ Generate beautiful, harmonious color palettes from a single base color. AutoThemeJS creates complete design system color schemes with primary, secondary, tertiary, accent, and neutral color variants across 11 shade levels (50-950), similar to Tailwind CSS color scales.
16
+
17
+ <p align="center">
18
+ <img src="demo/img/demo_screenshot.png" alt="AutoThemeJS Demo Screenshot" width="800" />
19
+ </p>
20
+
21
+ ## âœĻ Features
22
+
23
+ - ðŸŽĻ **Single Color Input** - Generate a complete color palette from just one color
24
+ - 🌈 **Color Harmony** - Automatically creates harmonious color relationships (analogous, complementary)
25
+ - 📊 **11 Shade Levels** - Each color includes shades from 50 (lightest) to 950 (darkest)
26
+ - 🔄 **Multiple Color Formats** - Support for HEX, RGB, HSL, OKLCH, and OKLAB
27
+ - ðŸ’ū **Serialization** - Serialize and deserialize themes for storage or transfer
28
+ - 🏷ïļ **Versioning** - Built-in version tracking for stored themes
29
+ - ðŸŠķ **Lightweight** - Zero dependencies, pure TypeScript
30
+ - ðŸ“Ķ **TypeScript Ready** - Full type definitions included
31
+
32
+ ## ðŸ“Ķ Installation
33
+
34
+ ```bash
35
+ npm install auto-theme-js
36
+ ```
37
+
38
+ ```bash
39
+ yarn add auto-theme-js
40
+ ```
41
+
42
+ ```bash
43
+ pnpm add auto-theme-js
44
+ ```
45
+
46
+ ## 🚀 Quick Start
47
+
48
+ ```javascript
49
+ import { AutoTheme } from 'auto-theme-js';
50
+
51
+ // Create a theme from a hex color
52
+ const theme = new AutoTheme('#8a00bd', 'hex', 'hex', '50', '950');
53
+
54
+ // Access colors
55
+ console.log(theme.primary['500']); // Primary color at shade 500
56
+ console.log(theme.secondary['300']); // Secondary (analogous +30°) at shade 300
57
+ console.log(theme.tertiary['700']); // Tertiary (analogous -30°) at shade 700
58
+ console.log(theme.accent['500']); // Accent (complementary) at shade 500
59
+ console.log(theme.neutral['900']); // Neutral (desaturated) at shade 900
60
+
61
+ // Check version (useful for stored themes)
62
+ console.log(theme.version); // e.g., 'V1'
63
+ ```
64
+
65
+ ## 📖 API Reference
66
+
67
+ ### Constructor
68
+
69
+ ```typescript
70
+ new AutoTheme(color, inputType?, outputType?, minShade?, maxShade?)
71
+ ```
72
+
73
+ | Parameter | Type | Default | Description |
74
+ |-----------|------|---------|-------------|
75
+ | `color` | `Color` | required | The base color to generate the theme from |
76
+ | `inputType` | `ColorType` | `'hex'` | Input color format: `'hex'`, `'rgb'`, `'hsl'`, `'oklch'`, `'oklab'` |
77
+ | `outputType` | `ColorType` | `'hex'` | Output color format for all generated colors |
78
+ | `minShade` | `Shade` | `'50'` | Minimum shade to generate |
79
+ | `maxShade` | `Shade` | `'900'` | Maximum shade to generate |
80
+
81
+ ### Theme Properties
82
+
83
+ Each `AutoTheme` instance contains five color groups plus metadata:
84
+
85
+ | Property | Description | Hue Rotation |
86
+ |----------|-------------|--------------|
87
+ | `primary` | Base color | 0° |
88
+ | `secondary` | Analogous color | +30° |
89
+ | `tertiary` | Analogous color | -30° |
90
+ | `accent` | Complementary color | +180° |
91
+ | `neutral` | Desaturated base | 0° (10% chroma) |
92
+ | `version` | Library version | - |
93
+ | `colorType` | Output color format | - |
94
+ | `baseColor` | Original input color | - |
95
+
96
+ ### Shade Levels
97
+
98
+ Each color group contains shades from `50` to `950`:
99
+
100
+ ```
101
+ 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950
102
+ ```
103
+
104
+ - `50` - Lightest (97% lightness)
105
+ - `500` - Base (55% lightness)
106
+ - `950` - Darkest (8% lightness)
107
+
108
+ ### Color Formats
109
+
110
+ ```typescript
111
+ type ColorType = 'hex' | 'rgb' | 'hsl' | 'oklch' | 'oklab';
112
+ ```
113
+
114
+ **Supported formats:**
115
+
116
+ ```javascript
117
+ // HEX
118
+ '#8a00bd'
119
+ '#8a00bdff' // alpha not supported yet in v1, so avoid transparency
120
+
121
+ // RGB
122
+ 'rgba(138, 0, 189, 1)'
123
+
124
+ // HSL
125
+ 'hsla(284, 100%, 37%, 1)'
126
+
127
+ // OKLCH
128
+ 'oklch(45.2% 0.234 303.4deg / 1)'
129
+
130
+ // OKLAB
131
+ 'oklab(45.2% 0.123 -0.098 / 1)'
132
+ ```
133
+
134
+ ## ðŸ’ū Serialization & Deserialization
135
+
136
+ AutoThemeJS provides built-in methods to serialize themes for storage (localStorage, databases, etc.) and deserialize them back.
137
+
138
+ ### Serialize
139
+
140
+ ```javascript
141
+ import { AutoTheme } from 'auto-theme-js';
142
+
143
+ const theme = new AutoTheme('#8a00bd', 'hex', 'hex', '50', '950');
144
+
145
+ // Serialize the theme to a string
146
+ const serialized = AutoTheme.serialize(theme);
147
+ console.log(serialized);
148
+ // Output: "version:1.0.2|colorType:hex|baseColor:#8a00bd||primary:{50:#faf5ff|...}||..."
149
+
150
+ // Store it
151
+ localStorage.setItem('userTheme', serialized);
152
+ ```
153
+
154
+ ### Deserialize
155
+
156
+ ```javascript
157
+ // Retrieve from storage
158
+ const serialized = localStorage.getItem('userTheme');
159
+
160
+ // Deserialize back to a theme object
161
+ const theme = AutoTheme.deserialize(serialized);
162
+
163
+ // Use the theme
164
+ console.log(theme.primary['500']); // #8a00bd
165
+ console.log(theme.colorType); // 'hex'
166
+ console.log(theme.baseColor); // '#8a00bd'
167
+ console.log(theme.version); // '1.0.2'
168
+ ```
169
+
170
+ ### Version Checking
171
+
172
+ The `version` property allows you to handle breaking changes when loading stored themes:
173
+
174
+ ```javascript
175
+ const theme = AutoTheme.deserialize(serialized);
176
+
177
+ // Check if theme was created with a compatible version
178
+ if (theme.version !== AutoTheme.VERSION) {
179
+ console.log('Theme was created with a different version, consider regenerating');
180
+ }
181
+ ```
182
+
183
+ ### Custom Escape Character
184
+
185
+ If your color values might contain the default delimiter (`|`), you can specify a custom escape character:
186
+
187
+ ```javascript
188
+ // Serialize with custom delimiter
189
+ const serialized = AutoTheme.serialize(theme, '*');
190
+
191
+ // Deserialize with the same delimiter
192
+ const theme = AutoTheme.deserialize(serialized, '*');
193
+ ```
194
+
195
+ ## ðŸŽŊ Usage Examples
196
+
197
+ ### Dynamic Theme Application
198
+
199
+ ```javascript
200
+ import { AutoTheme } from 'auto-theme-js';
201
+
202
+ function applyTheme(baseColor) {
203
+ const theme = new AutoTheme(baseColor, 'hex', 'hex', '50', '950');
204
+ const root = document.documentElement;
205
+
206
+ // Apply CSS custom properties
207
+ const properties = ['primary', 'secondary', 'tertiary', 'accent', 'neutral'];
208
+ const shades = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'];
209
+
210
+ for (const prop of properties) {
211
+ for (const shade of shades) {
212
+ root.style.setProperty(`--color-${prop}-${shade}`, theme[prop][shade]);
213
+ }
214
+ }
215
+ }
216
+
217
+ // Apply a purple theme
218
+ applyTheme('#8a00bd');
219
+ ```
220
+
221
+ ### React Integration
222
+
223
+ ```jsx
224
+ import { AutoTheme } from 'auto-theme-js';
225
+ import { useState, useEffect } from 'react';
226
+
227
+ function ThemeProvider({ children, baseColor }) {
228
+ const [theme, setTheme] = useState(null);
229
+
230
+ useEffect(() => {
231
+ const newTheme = new AutoTheme(baseColor, 'hex', 'hex', '50', '950');
232
+ setTheme(newTheme);
233
+
234
+ // Apply to CSS variables
235
+ const root = document.documentElement;
236
+ root.style.setProperty('--primary-500', newTheme.primary['500']);
237
+ root.style.setProperty('--accent-500', newTheme.accent['500']);
238
+ // ... more variables
239
+ }, [baseColor]);
240
+
241
+ return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
242
+ }
243
+ ```
244
+
245
+ ### Different Output Formats
246
+
247
+ ```javascript
248
+ // Output as RGB
249
+ const rgbTheme = new AutoTheme('#8a00bd', 'hex', 'rgb', '50', '950');
250
+ console.log(rgbTheme.primary['500']); // 'rgba(138, 0, 189, 1)'
251
+
252
+ // Output as HSL
253
+ const hslTheme = new AutoTheme('#8a00bd', 'hex', 'hsl', '50', '950');
254
+ console.log(hslTheme.primary['500']); // 'hsla(284, 100%, 37%, 1)'
255
+
256
+ // Output as OKLCH (perceptually uniform)
257
+ const oklchTheme = new AutoTheme('#8a00bd', 'hex', 'oklch', '50', '950');
258
+ console.log(oklchTheme.primary['500']); // 'oklch(45.2% 0.234 303.4deg / 1)'
259
+ ```
260
+
261
+ ### Limited Shade Range
262
+
263
+ ```javascript
264
+ // Generate only shades 400-700 for a more focused palette
265
+ const limitedTheme = new AutoTheme('#8a00bd', 'hex', 'hex', '400', '700');
266
+
267
+ console.log(limitedTheme.primary['400']); // ✅ Available
268
+ console.log(limitedTheme.primary['500']); // ✅ Available
269
+ console.log(limitedTheme.primary['50']); // ❌ undefined (not in range)
270
+ ```
271
+
272
+ ## 🔧 TypeScript Support
273
+
274
+ AutoThemeJS is written in TypeScript and includes full type definitions:
275
+
276
+ ```typescript
277
+ import { AutoTheme, Color, ColorType, Shade, ThemeProperties, Theme } from 'auto-theme-js';
278
+
279
+ const color: Color = '#8a00bd';
280
+ const theme: AutoTheme = new AutoTheme(color, 'hex', 'hex', '50', '950');
281
+
282
+ // Type-safe access
283
+ const primaryColor: Color = theme.primary['500'];
284
+ const shade: Shade = '500';
285
+ const property: ThemeProperties = 'primary';
286
+ ```
287
+
288
+ ## ðŸĪ Contributing
289
+
290
+ Contributions are welcome! Please feel free to submit a Pull Request.
291
+
292
+ 1. Fork the repository
293
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
294
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
295
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
296
+ 5. Open a Pull Request
297
+
298
+ ## 📄 License
299
+
300
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
301
+
302
+ ## 🔗 Links
303
+
304
+ - [Live Demo](https://auto-theme-js.vercel.app/)
305
+ - [npm Package](https://www.npmjs.com/package/auto-theme-js)
306
+ - [GitHub Repository](https://github.com/GustavoLGregorio/auto-theme-js)
307
+ - [Report Issues](https://github.com/GustavoLGregorio/auto-theme-js/issues)
308
+
309
+ ---
310
+
311
+ Made with âĪïļ by [Gustavo L. Gregorio](https://github.com/GustavoLGregorio)
@@ -1,4 +1,5 @@
1
- type ColorType = "hex" | "hsl" | "rgb" | "oklab" | "oklch";
1
+ /** Suported CSS color types */
2
+ export type ColorType = "hex" | "hsl" | "rgb" | "oklab" | "oklch";
2
3
  type ColorHEX = `#${string}`;
3
4
  type ColorRGB = `rgba(${number}, ${number}, ${number}, ${number})`;
4
5
  type ColorHSL = `hsla(${number}, ${number}%, ${number}%, ${number})`;
package/package.json CHANGED
@@ -1,58 +1,59 @@
1
- {
2
- "name": "auto-theme-js",
3
- "version": "1.0.2",
4
- "description": "Generate beautiful, harmonious color palettes from a single base color. Create complete design system color schemes with primary, secondary, tertiary, accent, and neutral variants across 11 shade levels.",
5
- "license": "MIT",
6
- "author": "Gustavo L. Gregorio",
7
- "main": "dist/AutoTheme.js",
8
- "scripts": {
9
- "build:lin": "clear; tsc; npx ts-add-js-extension --dir=dist",
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- },
12
- "keywords": [
13
- "color",
14
- "colors",
15
- "palette",
16
- "theme",
17
- "theming",
18
- "color-palette",
19
- "color-scheme",
20
- "design-system",
21
- "tailwind",
22
- "css",
23
- "hex",
24
- "rgb",
25
- "hsl",
26
- "oklch",
27
- "oklab",
28
- "color-harmony",
29
- "complementary",
30
- "analogous",
31
- "generator",
32
- "ui",
33
- "design",
34
- "frontend",
35
- "typescript"
36
- ],
37
- "homepage": "https://github.com/GustavoLGregorio/auto-theme-js#readme",
38
- "bugs": {
39
- "url": "https://github.com/GustavoLGregorio/auto-theme-js/issues"
40
- },
41
- "repository": {
42
- "type": "git",
43
- "url": "git+https://github.com/GustavoLGregorio/auto-theme-js.git"
44
- },
45
- "type": "module",
46
- "exports": {
47
- ".": {
48
- "import": "./dist/AutoTheme.js",
49
- "types": "./dist/AutoTheme.d.ts"
50
- },
51
- "./types": {
52
- "types": "./dist/types.d.ts"
53
- }
54
- },
55
- "dependencies": {
56
- "ts-add-js-extension": "^1.6.6"
57
- }
58
- }
1
+ {
2
+ "name": "auto-theme-js",
3
+ "version": "1.0.4",
4
+ "description": "Generate beautiful, harmonious color palettes from a single base color. Create complete design system color schemes with primary, secondary, tertiary, accent, and neutral variants across 11 shade levels.",
5
+ "license": "MIT",
6
+ "author": "Gustavo L. Gregorio",
7
+ "main": "dist/AutoTheme.js",
8
+ "scripts": {
9
+ "build:lin": "clear; tsc; npx ts-add-js-extension --dir=dist",
10
+ "build:win": "cls & tsc & npx ts-add-js-extension --dir=dist",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "keywords": [
14
+ "color",
15
+ "colors",
16
+ "palette",
17
+ "theme",
18
+ "theming",
19
+ "color-palette",
20
+ "color-scheme",
21
+ "design-system",
22
+ "tailwind",
23
+ "css",
24
+ "hex",
25
+ "rgb",
26
+ "hsl",
27
+ "oklch",
28
+ "oklab",
29
+ "color-harmony",
30
+ "complementary",
31
+ "analogous",
32
+ "generator",
33
+ "ui",
34
+ "design",
35
+ "frontend",
36
+ "typescript"
37
+ ],
38
+ "homepage": "https://github.com/GustavoLGregorio/auto-theme-js#readme",
39
+ "bugs": {
40
+ "url": "https://github.com/GustavoLGregorio/auto-theme-js/issues"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/GustavoLGregorio/auto-theme-js.git"
45
+ },
46
+ "type": "module",
47
+ "exports": {
48
+ ".": {
49
+ "import": "./dist/AutoTheme.js",
50
+ "types": "./dist/AutoTheme.d.ts"
51
+ },
52
+ "./types": {
53
+ "types": "./dist/types.d.ts"
54
+ }
55
+ },
56
+ "devDependencies": {
57
+ "ts-add-js-extension": "^1.6.6"
58
+ }
59
+ }