@fakhrirafiki/theme-engine 0.2.0 → 0.2.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 +17 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.mjs +19 -0
- package/dist/styles/tailwind.css +16 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -390,6 +390,22 @@ function CustomControls() {
|
|
|
390
390
|
</button>
|
|
391
391
|
)
|
|
392
392
|
}
|
|
393
|
+
|
|
394
|
+
// Or apply a preset by ID (from built-in or custom presets)
|
|
395
|
+
function QuickPresetSwitcher() {
|
|
396
|
+
const { setThemePresetById } = useTheme()
|
|
397
|
+
|
|
398
|
+
return (
|
|
399
|
+
<div>
|
|
400
|
+
<button onClick={() => setThemePresetById('modern-minimal')}>
|
|
401
|
+
Modern Minimal
|
|
402
|
+
</button>
|
|
403
|
+
<button onClick={() => setThemePresetById('tiket-ngobrol')}>
|
|
404
|
+
Ngobrol Blue
|
|
405
|
+
</button>
|
|
406
|
+
</div>
|
|
407
|
+
)
|
|
408
|
+
}
|
|
393
409
|
```
|
|
394
410
|
|
|
395
411
|
## 🔄 Migration Guide
|
|
@@ -563,4 +579,4 @@ This architecture ensures seamless coordination between appearance modes and col
|
|
|
563
579
|
|
|
564
580
|
## 📄 License
|
|
565
581
|
|
|
566
|
-
MIT License - see the monorepo root for details.
|
|
582
|
+
MIT License - see the monorepo root for details.
|
package/dist/index.d.mts
CHANGED
|
@@ -336,6 +336,8 @@ interface UnifiedThemeContextValue {
|
|
|
336
336
|
} | null;
|
|
337
337
|
/** Apply a new color preset */
|
|
338
338
|
applyPreset: (preset: ThemePreset) => void;
|
|
339
|
+
/** Apply a preset by its ID from the available preset collection */
|
|
340
|
+
setThemePresetById: (presetId: string) => void;
|
|
339
341
|
/** Clear the current preset and revert to default colors */
|
|
340
342
|
clearPreset: () => void;
|
|
341
343
|
/** Available presets (merged built-in + custom) */
|
package/dist/index.d.ts
CHANGED
|
@@ -336,6 +336,8 @@ interface UnifiedThemeContextValue {
|
|
|
336
336
|
} | null;
|
|
337
337
|
/** Apply a new color preset */
|
|
338
338
|
applyPreset: (preset: ThemePreset) => void;
|
|
339
|
+
/** Apply a preset by its ID from the available preset collection */
|
|
340
|
+
setThemePresetById: (presetId: string) => void;
|
|
339
341
|
/** Clear the current preset and revert to default colors */
|
|
340
342
|
clearPreset: () => void;
|
|
341
343
|
/** Available presets (merged built-in + custom) */
|
package/dist/index.js
CHANGED
|
@@ -3892,6 +3892,24 @@ function ThemeProvider({
|
|
|
3892
3892
|
applyPresetColors(preset.colors, resolvedMode);
|
|
3893
3893
|
}
|
|
3894
3894
|
}, [presetStorageKey, enablePresets, applyPresetColors, resolvedMode]);
|
|
3895
|
+
const setThemePresetById = (0, import_react.useCallback)((presetId) => {
|
|
3896
|
+
const preset = getAvailablePresetById(presetId);
|
|
3897
|
+
if (!preset) {
|
|
3898
|
+
if (typeof window !== "undefined") {
|
|
3899
|
+
console.warn("\u{1F3A8} UnifiedTheme: Preset not found for id:", presetId);
|
|
3900
|
+
}
|
|
3901
|
+
return;
|
|
3902
|
+
}
|
|
3903
|
+
const presetData = {
|
|
3904
|
+
id: presetId,
|
|
3905
|
+
name: preset.label,
|
|
3906
|
+
colors: {
|
|
3907
|
+
light: preset.styles.light,
|
|
3908
|
+
dark: preset.styles.dark
|
|
3909
|
+
}
|
|
3910
|
+
};
|
|
3911
|
+
applyPreset(presetData);
|
|
3912
|
+
}, [getAvailablePresetById, applyPreset]);
|
|
3895
3913
|
const clearPreset = (0, import_react.useCallback)(() => {
|
|
3896
3914
|
if (enablePresets && typeof window !== "undefined") {
|
|
3897
3915
|
try {
|
|
@@ -3946,6 +3964,7 @@ function ThemeProvider({
|
|
|
3946
3964
|
toggleMode: handleModeToggle,
|
|
3947
3965
|
currentPreset,
|
|
3948
3966
|
applyPreset,
|
|
3967
|
+
setThemePresetById,
|
|
3949
3968
|
clearPreset,
|
|
3950
3969
|
availablePresets,
|
|
3951
3970
|
builtInPresets,
|
package/dist/index.mjs
CHANGED
|
@@ -3851,6 +3851,24 @@ function ThemeProvider({
|
|
|
3851
3851
|
applyPresetColors(preset.colors, resolvedMode);
|
|
3852
3852
|
}
|
|
3853
3853
|
}, [presetStorageKey, enablePresets, applyPresetColors, resolvedMode]);
|
|
3854
|
+
const setThemePresetById = useCallback((presetId) => {
|
|
3855
|
+
const preset = getAvailablePresetById(presetId);
|
|
3856
|
+
if (!preset) {
|
|
3857
|
+
if (typeof window !== "undefined") {
|
|
3858
|
+
console.warn("\u{1F3A8} UnifiedTheme: Preset not found for id:", presetId);
|
|
3859
|
+
}
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
const presetData = {
|
|
3863
|
+
id: presetId,
|
|
3864
|
+
name: preset.label,
|
|
3865
|
+
colors: {
|
|
3866
|
+
light: preset.styles.light,
|
|
3867
|
+
dark: preset.styles.dark
|
|
3868
|
+
}
|
|
3869
|
+
};
|
|
3870
|
+
applyPreset(presetData);
|
|
3871
|
+
}, [getAvailablePresetById, applyPreset]);
|
|
3854
3872
|
const clearPreset = useCallback(() => {
|
|
3855
3873
|
if (enablePresets && typeof window !== "undefined") {
|
|
3856
3874
|
try {
|
|
@@ -3905,6 +3923,7 @@ function ThemeProvider({
|
|
|
3905
3923
|
toggleMode: handleModeToggle,
|
|
3906
3924
|
currentPreset,
|
|
3907
3925
|
applyPreset,
|
|
3926
|
+
setThemePresetById,
|
|
3908
3927
|
clearPreset,
|
|
3909
3928
|
availablePresets,
|
|
3910
3929
|
builtInPresets,
|
package/dist/styles/tailwind.css
CHANGED
|
@@ -44,6 +44,22 @@
|
|
|
44
44
|
--color-sidebar-border: var(--sidebar-border);
|
|
45
45
|
--color-sidebar-ring: var(--sidebar-ring);
|
|
46
46
|
|
|
47
|
+
/* Semantic accent colors for status and feedback */
|
|
48
|
+
--color-accent-info: var(--accent-info);
|
|
49
|
+
--color-accent-info-foreground: var(--accent-info-foreground);
|
|
50
|
+
--color-accent-success: var(--accent-success);
|
|
51
|
+
--color-accent-success-foreground: var(--accent-success-foreground);
|
|
52
|
+
--color-accent-warning: var(--accent-warning);
|
|
53
|
+
--color-accent-warning-foreground: var(--accent-warning-foreground);
|
|
54
|
+
--color-accent-danger: var(--accent-danger);
|
|
55
|
+
--color-accent-danger-foreground: var(--accent-danger-foreground);
|
|
56
|
+
--color-accent-brand: var(--accent-brand);
|
|
57
|
+
--color-accent-brand-foreground: var(--accent-brand-foreground);
|
|
58
|
+
--color-accent-feature: var(--accent-feature);
|
|
59
|
+
--color-accent-feature-foreground: var(--accent-feature-foreground);
|
|
60
|
+
--color-accent-highlight: var(--accent-highlight);
|
|
61
|
+
--color-accent-highlight-foreground: var(--accent-highlight-foreground);
|
|
62
|
+
|
|
47
63
|
/* Dynamic border radius system */
|
|
48
64
|
--radius-sm: calc(var(--radius) - 4px);
|
|
49
65
|
--radius-md: calc(var(--radius) - 2px);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fakhrirafiki/theme-engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Elegant theming system with smooth transitions, custom presets, semantic accent colors, and complete shadcn/ui support for modern React applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dark-mode",
|
|
58
58
|
"light-mode",
|
|
59
59
|
"react",
|
|
60
|
-
"typescript",
|
|
60
|
+
"typescript",
|
|
61
61
|
"transitions",
|
|
62
62
|
"shadcn",
|
|
63
63
|
"tailwind",
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
"accent-colors",
|
|
71
71
|
"semantic-colors"
|
|
72
72
|
],
|
|
73
|
-
"author": "
|
|
73
|
+
"author": "Tiket Ngobrol Team",
|
|
74
74
|
"license": "MIT"
|
|
75
|
-
}
|
|
75
|
+
}
|