@razzusharma/accent-theme 1.0.2 â 2.0.2
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 +225 -65
- package/dist/index.d.mts +88 -19
- package/dist/index.d.ts +88 -19
- package/dist/index.js +666 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +660 -119
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +75 -0
- package/dist/tailwind.d.mts +3 -0
- package/dist/tailwind.d.ts +3 -0
- package/dist/tailwind.js +107 -0
- package/dist/tailwind.mjs +89 -0
- package/package.json +31 -4
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# @razzusharma/accent-theme
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ðĻ **Zero-config accent color theming for React apps.** Just install, wrap, and use. No CSS changes required!
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
+
- â
**Zero Configuration** - CSS variables auto-injected, no globals.css changes needed
|
|
7
8
|
- ðĻ **8 Built-in Colors** - Teal, Blue, Purple, Rose, Amber, Emerald, Indigo, Cyan
|
|
9
|
+
- ð§Đ **Pre-built Components** - Pickers, swatches, menus, buttons - all styled out of the box
|
|
10
|
+
- ð **Dark Mode Ready** - Auto-detects and adapts to next-themes, ThemeProvider, or data-theme
|
|
8
11
|
- ðŊ **TypeScript Support** - Fully typed with generics
|
|
9
12
|
- ðū **Persistence** - Automatically saves user preference to localStorage
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- ðĶ **Zero Dependencies** - Only peer dependencies on React
|
|
13
|
-
- ðŠķ **Lightweight** - ~3KB gzipped
|
|
13
|
+
- ðĶ **Tailwind Plugin** - Optional plugin for extended utilities
|
|
14
|
+
- ðŠķ **Lightweight** - ~5KB gzipped
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
@@ -22,7 +23,7 @@ yarn add @razzusharma/accent-theme
|
|
|
22
23
|
pnpm add @razzusharma/accent-theme
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
## Quick Start
|
|
26
|
+
## Quick Start (It Just Works!)
|
|
26
27
|
|
|
27
28
|
### 1. Wrap your app with the provider
|
|
28
29
|
|
|
@@ -38,14 +39,133 @@ function App() {
|
|
|
38
39
|
}
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
That's it! CSS variables are auto-injected. No globals.css changes needed.
|
|
43
|
+
|
|
44
|
+
### 2. Drop in a color picker anywhere
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { AccentColorPicker } from '@razzusharma/accent-theme';
|
|
48
|
+
|
|
49
|
+
function Navbar() {
|
|
50
|
+
return (
|
|
51
|
+
<nav>
|
|
52
|
+
<AccentColorPicker variant="dropdown" size="sm" />
|
|
53
|
+
</nav>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Pre-built Components
|
|
59
|
+
|
|
60
|
+
### AccentColorPicker
|
|
61
|
+
|
|
62
|
+
The main color picker component with multiple variants:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { AccentColorPicker } from '@razzusharma/accent-theme';
|
|
66
|
+
|
|
67
|
+
// Dropdown picker (default)
|
|
68
|
+
<AccentColorPicker variant="dropdown" size="md" />
|
|
69
|
+
|
|
70
|
+
// Inline grid
|
|
71
|
+
<AccentColorPicker variant="inline" columns={4} />
|
|
72
|
+
|
|
73
|
+
// Menu style
|
|
74
|
+
<AccentColorPicker variant="menu" align="end" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Props:**
|
|
78
|
+
- `variant`: `"dropdown" | "inline" | "menu"`
|
|
79
|
+
- `size`: `"sm" | "md" | "lg"`
|
|
80
|
+
- `columns`: Number of columns for inline variant
|
|
81
|
+
- `label`: Label text for dropdown trigger
|
|
82
|
+
- `showColorName`: Show color name in dropdown
|
|
83
|
+
- `onChange`: Callback when color changes
|
|
84
|
+
- `className`: Custom classes
|
|
85
|
+
|
|
86
|
+
### AccentColorSwatches
|
|
87
|
+
|
|
88
|
+
Horizontal row of color dots:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { AccentColorSwatches } from '@razzusharma/accent-theme';
|
|
92
|
+
|
|
93
|
+
<AccentColorSwatches size="md" gap="md" showCheckmark />
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### AccentColorMenu
|
|
97
|
+
|
|
98
|
+
Dropdown menu with color names:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { AccentColorMenu } from '@razzusharma/accent-theme';
|
|
102
|
+
|
|
103
|
+
<AccentColorMenu align="end" label="Theme" />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### AccentColorButton
|
|
107
|
+
|
|
108
|
+
Button showing current accent color:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { AccentColorButton } from '@razzusharma/accent-theme';
|
|
112
|
+
|
|
113
|
+
<AccentColorButton showLabel buttonVariant="ghost" />
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### AccentColorGrid
|
|
117
|
+
|
|
118
|
+
Configurable grid layout:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { AccentColorGrid } from '@razzusharma/accent-theme';
|
|
122
|
+
|
|
123
|
+
<AccentColorGrid columns={4} showLabels gap="md" />
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### CurrentAccentIndicator
|
|
127
|
+
|
|
128
|
+
Non-interactive indicator showing current color:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { CurrentAccentIndicator } from '@razzusharma/accent-theme';
|
|
132
|
+
|
|
133
|
+
<CurrentAccentIndicator showName pulseOnChange />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### AccentThemeReset
|
|
137
|
+
|
|
138
|
+
Reset button to go back to default:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { AccentThemeReset } from '@razzusharma/accent-theme';
|
|
142
|
+
|
|
143
|
+
<AccentThemeReset variant="button" text="Reset Theme" />
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Provider Configuration
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<AccentThemeProvider
|
|
150
|
+
defaultColor="teal" // Default accent color
|
|
151
|
+
customColors={{...}} // Add custom colors
|
|
152
|
+
storageKey="accent-color" // localStorage key
|
|
153
|
+
cssVariablePrefix="brand" // Prefix CSS variables (--brand-primary)
|
|
154
|
+
injectCSS={true} // Auto-inject base CSS (default: true)
|
|
155
|
+
enableDarkMode={true} // Auto-detect dark mode (default: true)
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</AccentThemeProvider>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Using the Hook
|
|
42
162
|
|
|
43
163
|
```tsx
|
|
44
164
|
import { useAccentTheme, useAccentColor } from '@razzusharma/accent-theme';
|
|
45
165
|
|
|
46
166
|
function MyComponent() {
|
|
47
|
-
const { accentColor, setAccentColor } = useAccentTheme();
|
|
48
|
-
const { primary, light, gradient } = useAccentColor();
|
|
167
|
+
const { accentColor, setAccentColor, resetToDefault } = useAccentTheme();
|
|
168
|
+
const { primary, light, dark, gradient } = useAccentColor();
|
|
49
169
|
|
|
50
170
|
return (
|
|
51
171
|
<div style={{ color: primary }}>
|
|
@@ -58,33 +178,44 @@ function MyComponent() {
|
|
|
58
178
|
}
|
|
59
179
|
```
|
|
60
180
|
|
|
61
|
-
|
|
181
|
+
## Tailwind CSS Integration (Optional)
|
|
62
182
|
|
|
63
|
-
|
|
64
|
-
import { AccentColorPicker } from '@razzusharma/accent-theme';
|
|
183
|
+
For enhanced Tailwind integration, add the plugin:
|
|
65
184
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
185
|
+
```js
|
|
186
|
+
// tailwind.config.js
|
|
187
|
+
import { accentThemePlugin } from '@razzusharma/accent-theme/tailwind';
|
|
188
|
+
|
|
189
|
+
export default {
|
|
190
|
+
plugins: [accentThemePlugin],
|
|
73
191
|
}
|
|
74
192
|
```
|
|
75
193
|
|
|
76
|
-
|
|
194
|
+
This adds utility classes:
|
|
195
|
+
```html
|
|
196
|
+
<div class="bg-primary text-primary-foreground ring-accent">
|
|
197
|
+
Content with accent colors
|
|
198
|
+
</div>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Without the Plugin
|
|
202
|
+
|
|
203
|
+
If you prefer manual setup, CSS variables are available:
|
|
77
204
|
|
|
78
|
-
|
|
205
|
+
```css
|
|
206
|
+
.my-button {
|
|
207
|
+
background: hsl(var(--primary));
|
|
208
|
+
color: hsl(var(--primary-foreground));
|
|
209
|
+
}
|
|
210
|
+
```
|
|
79
211
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
| `cssVariablePrefix` | `string` | `''` | Prefix for CSS variables |
|
|
212
|
+
```html
|
|
213
|
+
<button class="bg-[hsl(var(--primary))] text-white">
|
|
214
|
+
Click me
|
|
215
|
+
</button>
|
|
216
|
+
```
|
|
86
217
|
|
|
87
|
-
|
|
218
|
+
## Custom Colors
|
|
88
219
|
|
|
89
220
|
```tsx
|
|
90
221
|
import { AccentThemeProvider } from '@razzusharma/accent-theme';
|
|
@@ -112,32 +243,55 @@ function App() {
|
|
|
112
243
|
}
|
|
113
244
|
```
|
|
114
245
|
|
|
246
|
+
## Dark Mode
|
|
247
|
+
|
|
248
|
+
The package automatically detects dark mode from:
|
|
249
|
+
- `next-themes`
|
|
250
|
+
- `ThemeProvider`
|
|
251
|
+
- `data-theme="dark"` attribute
|
|
252
|
+
- `class="dark"` on html element
|
|
253
|
+
- `prefers-color-scheme: dark` media query
|
|
254
|
+
|
|
115
255
|
## CSS Variables
|
|
116
256
|
|
|
117
|
-
The
|
|
257
|
+
The following CSS variables are set on the root element:
|
|
118
258
|
|
|
119
259
|
```css
|
|
120
260
|
:root {
|
|
121
|
-
--primary: 174 72% 35%;
|
|
261
|
+
--primary: 174 72% 35%; /* HSL values */
|
|
122
262
|
--primary-foreground: 210 40% 98%;
|
|
123
263
|
--accent: 174 72% 45%;
|
|
124
264
|
--ring: 174 72% 45%;
|
|
125
265
|
}
|
|
126
266
|
```
|
|
127
267
|
|
|
128
|
-
|
|
129
|
-
|
|
268
|
+
With `cssVariablePrefix="brand"`:
|
|
130
269
|
```css
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
270
|
+
:root {
|
|
271
|
+
--brand-primary: 174 72% 35%;
|
|
272
|
+
--brand-primary-foreground: 210 40% 98%;
|
|
273
|
+
--brand-accent: 174 72% 45%;
|
|
274
|
+
--brand-ring: 174 72% 45%;
|
|
134
275
|
}
|
|
135
276
|
```
|
|
136
277
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
278
|
+
## Importing CSS Manually
|
|
279
|
+
|
|
280
|
+
If you prefer to disable auto-injection and import CSS manually:
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
// Disable auto-injection
|
|
284
|
+
<AccentThemeProvider injectCSS={false}>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
// Import CSS in your app
|
|
289
|
+
import '@razzusharma/accent-theme/styles.css';
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Or in CSS:
|
|
293
|
+
```css
|
|
294
|
+
@import '@razzusharma/accent-theme/styles.css';
|
|
141
295
|
```
|
|
142
296
|
|
|
143
297
|
## API Reference
|
|
@@ -150,6 +304,8 @@ const {
|
|
|
150
304
|
setAccentColor, // Function to change color
|
|
151
305
|
accentConfig, // Full color config object
|
|
152
306
|
mounted, // Hydration flag
|
|
307
|
+
defaultColor, // Default color name
|
|
308
|
+
resetToDefault, // Reset function
|
|
153
309
|
} = useAccentTheme();
|
|
154
310
|
```
|
|
155
311
|
|
|
@@ -163,39 +319,43 @@ const {
|
|
|
163
319
|
dark, // hsl() string for dark variant
|
|
164
320
|
gradient, // Tailwind gradient class
|
|
165
321
|
mounted, // Hydration flag
|
|
322
|
+
isDark, // Current dark mode state
|
|
166
323
|
} = useAccentColor();
|
|
167
324
|
```
|
|
168
325
|
|
|
169
|
-
###
|
|
170
|
-
|
|
171
|
-
```tsx
|
|
172
|
-
<AccentColorPicker
|
|
173
|
-
size="md" // 'sm' | 'md' | 'lg'
|
|
174
|
-
variant="dropdown" // 'dropdown' | 'inline'
|
|
175
|
-
columns={4} // Number of columns for inline
|
|
176
|
-
onChange={(color) => console.log(color)}
|
|
177
|
-
/>
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## Tailwind CSS Integration
|
|
326
|
+
### Color Config Structure
|
|
181
327
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
'primary-foreground': 'hsl(var(--primary-foreground))',
|
|
191
|
-
accent: 'hsl(var(--accent))',
|
|
192
|
-
ring: 'hsl(var(--ring))',
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
},
|
|
328
|
+
```ts
|
|
329
|
+
interface AccentColorConfig {
|
|
330
|
+
name: string; // Display name
|
|
331
|
+
primary: string; // HSL value "174 72% 35%"
|
|
332
|
+
primaryForeground: string; // HSL value for text
|
|
333
|
+
light: string; // Lighter variant
|
|
334
|
+
dark: string; // Darker variant
|
|
335
|
+
gradient: string; // Tailwind gradient classes
|
|
196
336
|
}
|
|
197
337
|
```
|
|
198
338
|
|
|
339
|
+
## Built-in Colors
|
|
340
|
+
|
|
341
|
+
| Color | Name | Primary |
|
|
342
|
+
|-------|------|---------|
|
|
343
|
+
| teal | Teal | `#199c88` |
|
|
344
|
+
| blue | Ocean Blue | `#0b6dc6` |
|
|
345
|
+
| purple | Royal Purple | `#7c3aed` |
|
|
346
|
+
| rose | Rose Pink | `#e11d48` |
|
|
347
|
+
| amber | Sunset Amber | `#d97706` |
|
|
348
|
+
| emerald | Forest Emerald | `#208562` |
|
|
349
|
+
| indigo | Deep Indigo | `#4f46e5` |
|
|
350
|
+
| cyan | Electric Cyan | `#0ba5c9` |
|
|
351
|
+
|
|
352
|
+
## Browser Support
|
|
353
|
+
|
|
354
|
+
- Chrome/Edge 88+
|
|
355
|
+
- Firefox 78+
|
|
356
|
+
- Safari 14+
|
|
357
|
+
- Supports server-side rendering (Next.js, Remix, etc.)
|
|
358
|
+
|
|
199
359
|
## License
|
|
200
360
|
|
|
201
361
|
MIT ÂĐ razzusharma
|
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,10 @@ interface AccentThemeContextType {
|
|
|
14
14
|
accentColor: AccentColor;
|
|
15
15
|
setAccentColor: (color: AccentColor) => void;
|
|
16
16
|
accentConfig: AccentColorConfig;
|
|
17
|
+
colors: Record<string, AccentColorConfig>;
|
|
17
18
|
mounted: boolean;
|
|
19
|
+
defaultColor: AccentColor;
|
|
20
|
+
resetToDefault: () => void;
|
|
18
21
|
}
|
|
19
22
|
interface AccentThemeProviderProps {
|
|
20
23
|
children: ReactNode;
|
|
@@ -22,9 +25,62 @@ interface AccentThemeProviderProps {
|
|
|
22
25
|
customColors?: Record<string, AccentColorConfig>;
|
|
23
26
|
storageKey?: string;
|
|
24
27
|
cssVariablePrefix?: string;
|
|
28
|
+
injectCSS?: boolean;
|
|
29
|
+
enableDarkMode?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type ComponentSize = "sm" | "md" | "lg";
|
|
32
|
+
interface BaseComponentProps {
|
|
33
|
+
className?: string;
|
|
34
|
+
size?: ComponentSize;
|
|
35
|
+
}
|
|
36
|
+
interface AccentColorPickerProps extends BaseComponentProps {
|
|
37
|
+
variant?: "dropdown" | "inline" | "menu";
|
|
38
|
+
columns?: number;
|
|
39
|
+
align?: "start" | "center" | "end";
|
|
40
|
+
onChange?: (color: AccentColor) => void;
|
|
41
|
+
label?: string;
|
|
42
|
+
showColorName?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface AccentColorSwatchesProps extends BaseComponentProps {
|
|
45
|
+
onChange?: (color: AccentColor) => void;
|
|
46
|
+
showCheckmark?: boolean;
|
|
47
|
+
gap?: "sm" | "md" | "lg";
|
|
48
|
+
}
|
|
49
|
+
interface AccentColorMenuProps extends BaseComponentProps {
|
|
50
|
+
onChange?: (color: AccentColor) => void;
|
|
51
|
+
align?: "start" | "center" | "end";
|
|
52
|
+
label?: string;
|
|
53
|
+
}
|
|
54
|
+
interface AccentColorButtonProps extends BaseComponentProps {
|
|
55
|
+
onClick?: () => void;
|
|
56
|
+
showLabel?: boolean;
|
|
57
|
+
buttonVariant?: "default" | "ghost" | "outline";
|
|
58
|
+
}
|
|
59
|
+
interface AccentThemeResetProps extends BaseComponentProps {
|
|
60
|
+
text?: string;
|
|
61
|
+
onReset?: () => void;
|
|
62
|
+
variant?: "button" | "link" | "subtle";
|
|
63
|
+
}
|
|
64
|
+
interface CurrentAccentIndicatorProps extends BaseComponentProps {
|
|
65
|
+
showName?: boolean;
|
|
66
|
+
pulseOnChange?: boolean;
|
|
67
|
+
}
|
|
68
|
+
interface AccentColorGridProps extends BaseComponentProps {
|
|
69
|
+
columns?: 2 | 3 | 4 | 5 | 6 | 8;
|
|
70
|
+
onChange?: (color: AccentColor) => void;
|
|
71
|
+
showLabels?: boolean;
|
|
72
|
+
gap?: "sm" | "md" | "lg";
|
|
73
|
+
}
|
|
74
|
+
interface AccentColorSwatchProps {
|
|
75
|
+
color: AccentColor;
|
|
76
|
+
isSelected?: boolean;
|
|
77
|
+
onClick?: () => void;
|
|
78
|
+
size?: ComponentSize;
|
|
79
|
+
className?: string;
|
|
80
|
+
showCheckmark?: boolean;
|
|
25
81
|
}
|
|
26
82
|
|
|
27
|
-
declare function AccentThemeProvider({ children, defaultColor, customColors, storageKey, cssVariablePrefix }: AccentThemeProviderProps): React.FunctionComponentElement<React.ProviderProps<AccentThemeContextType>>;
|
|
83
|
+
declare function AccentThemeProvider({ children, defaultColor, customColors, storageKey, cssVariablePrefix, injectCSS, enableDarkMode, }: AccentThemeProviderProps): React.FunctionComponentElement<React.ProviderProps<AccentThemeContextType>>;
|
|
28
84
|
declare function useAccentTheme(): AccentThemeContextType;
|
|
29
85
|
declare function useAccentColor(): {
|
|
30
86
|
primary: string;
|
|
@@ -33,25 +89,12 @@ declare function useAccentColor(): {
|
|
|
33
89
|
dark: string;
|
|
34
90
|
gradient: string;
|
|
35
91
|
mounted: boolean;
|
|
92
|
+
isDark: boolean;
|
|
36
93
|
};
|
|
94
|
+
declare function useAccentDarkMode(): boolean;
|
|
37
95
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
variant?: "dropdown" | "inline";
|
|
41
|
-
columns?: number;
|
|
42
|
-
className?: string;
|
|
43
|
-
onChange?: (color: AccentColor) => void;
|
|
44
|
-
}
|
|
45
|
-
declare function AccentColorPicker({ size, variant, columns, className, onChange, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
|
|
46
|
-
className: string;
|
|
47
|
-
}, HTMLElement>;
|
|
48
|
-
interface AccentColorSwatchProps {
|
|
49
|
-
color: AccentColor;
|
|
50
|
-
isSelected?: boolean;
|
|
51
|
-
onClick?: () => void;
|
|
52
|
-
size?: "sm" | "md" | "lg";
|
|
53
|
-
}
|
|
54
|
-
declare function AccentColorSwatch({ color, isSelected, onClick, size }: AccentColorSwatchProps): React.DetailedReactHTMLElement<{
|
|
96
|
+
declare function AccentColorSwatch({ color, isSelected, onClick, size, className, showCheckmark, }: AccentColorSwatchProps): React.DetailedReactHTMLElement<{
|
|
97
|
+
type: string;
|
|
55
98
|
onClick: (() => void) | undefined;
|
|
56
99
|
className: string;
|
|
57
100
|
style: {
|
|
@@ -59,9 +102,33 @@ declare function AccentColorSwatch({ color, isSelected, onClick, size }: AccentC
|
|
|
59
102
|
background: string;
|
|
60
103
|
};
|
|
61
104
|
title: string;
|
|
105
|
+
"aria-label": string;
|
|
106
|
+
"aria-pressed": boolean | undefined;
|
|
62
107
|
}, HTMLElement> | null;
|
|
108
|
+
declare function AccentColorPicker({ size, variant, columns, className, align, onChange, label, showColorName, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
|
|
109
|
+
className: string;
|
|
110
|
+
}, HTMLElement> | React.FunctionComponentElement<AccentColorMenuProps>;
|
|
111
|
+
declare function AccentColorSwatches({ className, size, onChange, showCheckmark, gap, }: AccentColorSwatchesProps): React.DetailedReactHTMLElement<{
|
|
112
|
+
className: string;
|
|
113
|
+
}, HTMLElement>;
|
|
114
|
+
declare function AccentColorMenu({ className, size: _size, onChange, align, label, }: AccentColorMenuProps): React.DetailedReactHTMLElement<{
|
|
115
|
+
className: string;
|
|
116
|
+
}, HTMLElement>;
|
|
117
|
+
declare function AccentColorButton({ className, size, onClick, showLabel, buttonVariant, }: AccentColorButtonProps): React.DetailedReactHTMLElement<{
|
|
118
|
+
className: string;
|
|
119
|
+
}, HTMLElement>;
|
|
120
|
+
declare function AccentThemeReset({ className, size, text, onReset, variant, }: AccentThemeResetProps): React.DetailedReactHTMLElement<{
|
|
121
|
+
className: string;
|
|
122
|
+
}, HTMLElement>;
|
|
123
|
+
declare function CurrentAccentIndicator({ className, size, showName, pulseOnChange, }: CurrentAccentIndicatorProps): React.DetailedReactHTMLElement<{
|
|
124
|
+
className: string;
|
|
125
|
+
}, HTMLElement>;
|
|
126
|
+
declare function AccentColorGrid({ className, size, columns, onChange, showLabels, gap, }: AccentColorGridProps): React.DetailedReactHTMLElement<{
|
|
127
|
+
className: string;
|
|
128
|
+
}, HTMLElement>;
|
|
63
129
|
|
|
64
130
|
declare const defaultAccentColors: Record<AccentColor, AccentColorConfig>;
|
|
131
|
+
declare function mergeColors(defaultColors: Record<string, AccentColorConfig>, customColors?: Record<string, AccentColorConfig>): Record<string, AccentColorConfig>;
|
|
65
132
|
|
|
66
133
|
declare function generateCSSVariables(config: AccentColorConfig, prefix?: string): Record<string, string>;
|
|
67
134
|
declare function applyCSSVariables(element: HTMLElement, variables: Record<string, string>): void;
|
|
@@ -80,4 +147,6 @@ declare const storage: {
|
|
|
80
147
|
remove: (key: string) => void;
|
|
81
148
|
};
|
|
82
149
|
|
|
83
|
-
|
|
150
|
+
declare const VERSION = "2.0.0";
|
|
151
|
+
|
|
152
|
+
export { type AccentColor, AccentColorButton, type AccentColorButtonProps, type AccentColorConfig, AccentColorGrid, type AccentColorGridProps, AccentColorMenu, type AccentColorMenuProps, AccentColorPicker, type AccentColorPickerProps, AccentColorSwatch, type AccentColorSwatchProps, AccentColorSwatches, type AccentColorSwatchesProps, type AccentThemeContextType, AccentThemeProvider, type AccentThemeProviderProps, AccentThemeReset, type AccentThemeResetProps, type BaseComponentProps, type ComponentSize, CurrentAccentIndicator, type CurrentAccentIndicatorProps, VERSION, adjustHSL, applyCSSVariables, createGradient, createShadow, defaultAccentColors, generateCSSVariables, getContrastColor, isClient, mergeColors, storage, useAccentColor, useAccentDarkMode, useAccentTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,10 @@ interface AccentThemeContextType {
|
|
|
14
14
|
accentColor: AccentColor;
|
|
15
15
|
setAccentColor: (color: AccentColor) => void;
|
|
16
16
|
accentConfig: AccentColorConfig;
|
|
17
|
+
colors: Record<string, AccentColorConfig>;
|
|
17
18
|
mounted: boolean;
|
|
19
|
+
defaultColor: AccentColor;
|
|
20
|
+
resetToDefault: () => void;
|
|
18
21
|
}
|
|
19
22
|
interface AccentThemeProviderProps {
|
|
20
23
|
children: ReactNode;
|
|
@@ -22,9 +25,62 @@ interface AccentThemeProviderProps {
|
|
|
22
25
|
customColors?: Record<string, AccentColorConfig>;
|
|
23
26
|
storageKey?: string;
|
|
24
27
|
cssVariablePrefix?: string;
|
|
28
|
+
injectCSS?: boolean;
|
|
29
|
+
enableDarkMode?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type ComponentSize = "sm" | "md" | "lg";
|
|
32
|
+
interface BaseComponentProps {
|
|
33
|
+
className?: string;
|
|
34
|
+
size?: ComponentSize;
|
|
35
|
+
}
|
|
36
|
+
interface AccentColorPickerProps extends BaseComponentProps {
|
|
37
|
+
variant?: "dropdown" | "inline" | "menu";
|
|
38
|
+
columns?: number;
|
|
39
|
+
align?: "start" | "center" | "end";
|
|
40
|
+
onChange?: (color: AccentColor) => void;
|
|
41
|
+
label?: string;
|
|
42
|
+
showColorName?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface AccentColorSwatchesProps extends BaseComponentProps {
|
|
45
|
+
onChange?: (color: AccentColor) => void;
|
|
46
|
+
showCheckmark?: boolean;
|
|
47
|
+
gap?: "sm" | "md" | "lg";
|
|
48
|
+
}
|
|
49
|
+
interface AccentColorMenuProps extends BaseComponentProps {
|
|
50
|
+
onChange?: (color: AccentColor) => void;
|
|
51
|
+
align?: "start" | "center" | "end";
|
|
52
|
+
label?: string;
|
|
53
|
+
}
|
|
54
|
+
interface AccentColorButtonProps extends BaseComponentProps {
|
|
55
|
+
onClick?: () => void;
|
|
56
|
+
showLabel?: boolean;
|
|
57
|
+
buttonVariant?: "default" | "ghost" | "outline";
|
|
58
|
+
}
|
|
59
|
+
interface AccentThemeResetProps extends BaseComponentProps {
|
|
60
|
+
text?: string;
|
|
61
|
+
onReset?: () => void;
|
|
62
|
+
variant?: "button" | "link" | "subtle";
|
|
63
|
+
}
|
|
64
|
+
interface CurrentAccentIndicatorProps extends BaseComponentProps {
|
|
65
|
+
showName?: boolean;
|
|
66
|
+
pulseOnChange?: boolean;
|
|
67
|
+
}
|
|
68
|
+
interface AccentColorGridProps extends BaseComponentProps {
|
|
69
|
+
columns?: 2 | 3 | 4 | 5 | 6 | 8;
|
|
70
|
+
onChange?: (color: AccentColor) => void;
|
|
71
|
+
showLabels?: boolean;
|
|
72
|
+
gap?: "sm" | "md" | "lg";
|
|
73
|
+
}
|
|
74
|
+
interface AccentColorSwatchProps {
|
|
75
|
+
color: AccentColor;
|
|
76
|
+
isSelected?: boolean;
|
|
77
|
+
onClick?: () => void;
|
|
78
|
+
size?: ComponentSize;
|
|
79
|
+
className?: string;
|
|
80
|
+
showCheckmark?: boolean;
|
|
25
81
|
}
|
|
26
82
|
|
|
27
|
-
declare function AccentThemeProvider({ children, defaultColor, customColors, storageKey, cssVariablePrefix }: AccentThemeProviderProps): React.FunctionComponentElement<React.ProviderProps<AccentThemeContextType>>;
|
|
83
|
+
declare function AccentThemeProvider({ children, defaultColor, customColors, storageKey, cssVariablePrefix, injectCSS, enableDarkMode, }: AccentThemeProviderProps): React.FunctionComponentElement<React.ProviderProps<AccentThemeContextType>>;
|
|
28
84
|
declare function useAccentTheme(): AccentThemeContextType;
|
|
29
85
|
declare function useAccentColor(): {
|
|
30
86
|
primary: string;
|
|
@@ -33,25 +89,12 @@ declare function useAccentColor(): {
|
|
|
33
89
|
dark: string;
|
|
34
90
|
gradient: string;
|
|
35
91
|
mounted: boolean;
|
|
92
|
+
isDark: boolean;
|
|
36
93
|
};
|
|
94
|
+
declare function useAccentDarkMode(): boolean;
|
|
37
95
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
variant?: "dropdown" | "inline";
|
|
41
|
-
columns?: number;
|
|
42
|
-
className?: string;
|
|
43
|
-
onChange?: (color: AccentColor) => void;
|
|
44
|
-
}
|
|
45
|
-
declare function AccentColorPicker({ size, variant, columns, className, onChange, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
|
|
46
|
-
className: string;
|
|
47
|
-
}, HTMLElement>;
|
|
48
|
-
interface AccentColorSwatchProps {
|
|
49
|
-
color: AccentColor;
|
|
50
|
-
isSelected?: boolean;
|
|
51
|
-
onClick?: () => void;
|
|
52
|
-
size?: "sm" | "md" | "lg";
|
|
53
|
-
}
|
|
54
|
-
declare function AccentColorSwatch({ color, isSelected, onClick, size }: AccentColorSwatchProps): React.DetailedReactHTMLElement<{
|
|
96
|
+
declare function AccentColorSwatch({ color, isSelected, onClick, size, className, showCheckmark, }: AccentColorSwatchProps): React.DetailedReactHTMLElement<{
|
|
97
|
+
type: string;
|
|
55
98
|
onClick: (() => void) | undefined;
|
|
56
99
|
className: string;
|
|
57
100
|
style: {
|
|
@@ -59,9 +102,33 @@ declare function AccentColorSwatch({ color, isSelected, onClick, size }: AccentC
|
|
|
59
102
|
background: string;
|
|
60
103
|
};
|
|
61
104
|
title: string;
|
|
105
|
+
"aria-label": string;
|
|
106
|
+
"aria-pressed": boolean | undefined;
|
|
62
107
|
}, HTMLElement> | null;
|
|
108
|
+
declare function AccentColorPicker({ size, variant, columns, className, align, onChange, label, showColorName, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
|
|
109
|
+
className: string;
|
|
110
|
+
}, HTMLElement> | React.FunctionComponentElement<AccentColorMenuProps>;
|
|
111
|
+
declare function AccentColorSwatches({ className, size, onChange, showCheckmark, gap, }: AccentColorSwatchesProps): React.DetailedReactHTMLElement<{
|
|
112
|
+
className: string;
|
|
113
|
+
}, HTMLElement>;
|
|
114
|
+
declare function AccentColorMenu({ className, size: _size, onChange, align, label, }: AccentColorMenuProps): React.DetailedReactHTMLElement<{
|
|
115
|
+
className: string;
|
|
116
|
+
}, HTMLElement>;
|
|
117
|
+
declare function AccentColorButton({ className, size, onClick, showLabel, buttonVariant, }: AccentColorButtonProps): React.DetailedReactHTMLElement<{
|
|
118
|
+
className: string;
|
|
119
|
+
}, HTMLElement>;
|
|
120
|
+
declare function AccentThemeReset({ className, size, text, onReset, variant, }: AccentThemeResetProps): React.DetailedReactHTMLElement<{
|
|
121
|
+
className: string;
|
|
122
|
+
}, HTMLElement>;
|
|
123
|
+
declare function CurrentAccentIndicator({ className, size, showName, pulseOnChange, }: CurrentAccentIndicatorProps): React.DetailedReactHTMLElement<{
|
|
124
|
+
className: string;
|
|
125
|
+
}, HTMLElement>;
|
|
126
|
+
declare function AccentColorGrid({ className, size, columns, onChange, showLabels, gap, }: AccentColorGridProps): React.DetailedReactHTMLElement<{
|
|
127
|
+
className: string;
|
|
128
|
+
}, HTMLElement>;
|
|
63
129
|
|
|
64
130
|
declare const defaultAccentColors: Record<AccentColor, AccentColorConfig>;
|
|
131
|
+
declare function mergeColors(defaultColors: Record<string, AccentColorConfig>, customColors?: Record<string, AccentColorConfig>): Record<string, AccentColorConfig>;
|
|
65
132
|
|
|
66
133
|
declare function generateCSSVariables(config: AccentColorConfig, prefix?: string): Record<string, string>;
|
|
67
134
|
declare function applyCSSVariables(element: HTMLElement, variables: Record<string, string>): void;
|
|
@@ -80,4 +147,6 @@ declare const storage: {
|
|
|
80
147
|
remove: (key: string) => void;
|
|
81
148
|
};
|
|
82
149
|
|
|
83
|
-
|
|
150
|
+
declare const VERSION = "2.0.0";
|
|
151
|
+
|
|
152
|
+
export { type AccentColor, AccentColorButton, type AccentColorButtonProps, type AccentColorConfig, AccentColorGrid, type AccentColorGridProps, AccentColorMenu, type AccentColorMenuProps, AccentColorPicker, type AccentColorPickerProps, AccentColorSwatch, type AccentColorSwatchProps, AccentColorSwatches, type AccentColorSwatchesProps, type AccentThemeContextType, AccentThemeProvider, type AccentThemeProviderProps, AccentThemeReset, type AccentThemeResetProps, type BaseComponentProps, type ComponentSize, CurrentAccentIndicator, type CurrentAccentIndicatorProps, VERSION, adjustHSL, applyCSSVariables, createGradient, createShadow, defaultAccentColors, generateCSSVariables, getContrastColor, isClient, mergeColors, storage, useAccentColor, useAccentDarkMode, useAccentTheme };
|