@stfrigerio/sito-template 0.1.6 → 0.1.7
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/dist/components/molecules/ThemeSwitcher/ThemeSwitcher.d.ts +9 -2
- package/dist/components/molecules/ThemeSwitcher/ThemeSwitcher.d.ts.map +1 -1
- package/dist/components/molecules/index.d.ts +1 -0
- package/dist/components/molecules/index.d.ts.map +1 -1
- package/dist/index.esm.js +17 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1500,9 +1500,19 @@ const useTheme = () => {
|
|
|
1500
1500
|
|
|
1501
1501
|
var styles$7 = {"button":"ThemeSwitcher-module_button__VfRjU","iconWrapper":"ThemeSwitcher-module_iconWrapper__FpHo8","label":"ThemeSwitcher-module_label__2Hfkp","toggle":"ThemeSwitcher-module_toggle__ATXx4","toggleTrack":"ThemeSwitcher-module_toggleTrack__x28Rv","toggleThumb":"ThemeSwitcher-module_toggleThumb__V8QeN","dropdown":"ThemeSwitcher-module_dropdown__3qLdt","dropdownTrigger":"ThemeSwitcher-module_dropdownTrigger__UzYV5","dropdownMenu":"ThemeSwitcher-module_dropdownMenu__3L5hT","dropdownItem":"ThemeSwitcher-module_dropdownItem__inw-K","active":"ThemeSwitcher-module_active__OHP19","icon":"ThemeSwitcher-module_icon__iRZiJ","text":"ThemeSwitcher-module_text__OCOoA"};
|
|
1502
1502
|
|
|
1503
|
-
const ThemeSwitcher = ({ variant = 'button', showLabel = false, className = '', }) => {
|
|
1504
|
-
|
|
1505
|
-
const
|
|
1503
|
+
const ThemeSwitcher = ({ variant = 'button', showLabel = false, className = '', currentTheme, onThemeChange, themes: customThemes, }) => {
|
|
1504
|
+
// Try to use internal context if available, otherwise use props
|
|
1505
|
+
const contextTheme = (() => {
|
|
1506
|
+
try {
|
|
1507
|
+
return useTheme();
|
|
1508
|
+
}
|
|
1509
|
+
catch {
|
|
1510
|
+
return null;
|
|
1511
|
+
}
|
|
1512
|
+
})();
|
|
1513
|
+
const theme = currentTheme ?? contextTheme?.theme ?? 'light';
|
|
1514
|
+
const setTheme = onThemeChange ?? contextTheme?.setTheme ?? (() => { });
|
|
1515
|
+
const defaultThemes = [
|
|
1506
1516
|
{ value: 'light', label: 'Light', icon: jsxRuntime.jsx(FiSun, {}) },
|
|
1507
1517
|
{ value: 'dark', label: 'Dark', icon: jsxRuntime.jsx(FiMoon, {}) },
|
|
1508
1518
|
{ value: 'lossito', label: 'Lossito Light', icon: '✨' },
|
|
@@ -1510,21 +1520,22 @@ const ThemeSwitcher = ({ variant = 'button', showLabel = false, className = '',
|
|
|
1510
1520
|
{ value: 'dmood', label: 'Dmood Light', icon: '💙' },
|
|
1511
1521
|
{ value: 'dmood-dark', label: 'Dmood Dark', icon: '🌌' },
|
|
1512
1522
|
];
|
|
1523
|
+
const themes = customThemes ?? defaultThemes;
|
|
1513
1524
|
const currentThemeIndex = themes.findIndex(t => t.value === theme);
|
|
1514
|
-
const
|
|
1525
|
+
const currentThemeData = themes[currentThemeIndex] ?? themes[0];
|
|
1515
1526
|
if (variant === 'toggle') {
|
|
1516
1527
|
// Simple toggle between light and dark
|
|
1517
1528
|
const isDark = theme.includes('dark');
|
|
1518
1529
|
return (jsxRuntime.jsxs(framerMotion.motion.button, { className: `${styles$7.toggle} ${className}`, onClick: () => setTheme(isDark ? 'light' : 'dark'), whileTap: { scale: 0.95 }, "aria-label": "Toggle theme", children: [jsxRuntime.jsx(framerMotion.motion.div, { className: styles$7.toggleTrack, animate: { backgroundColor: isDark ? 'var(--color-primary)' : 'var(--color-border)' }, children: jsxRuntime.jsx(framerMotion.motion.div, { className: styles$7.toggleThumb, animate: { x: isDark ? 24 : 0 }, transition: { type: 'spring', stiffness: 500, damping: 30 }, children: isDark ? jsxRuntime.jsx(FiMoon, { size: 14 }) : jsxRuntime.jsx(FiSun, { size: 14 }) }) }), showLabel && jsxRuntime.jsx("span", { className: styles$7.label, children: isDark ? 'Dark' : 'Light' })] }));
|
|
1519
1530
|
}
|
|
1520
1531
|
if (variant === 'dropdown') {
|
|
1521
|
-
return (jsxRuntime.jsxs("div", { className: `${styles$7.dropdown} ${className}`, children: [jsxRuntime.jsxs(framerMotion.motion.button, { className: styles$7.dropdownTrigger, whileTap: { scale: 0.98 }, children: [
|
|
1532
|
+
return (jsxRuntime.jsxs("div", { className: `${styles$7.dropdown} ${className}`, children: [jsxRuntime.jsxs(framerMotion.motion.button, { className: styles$7.dropdownTrigger, whileTap: { scale: 0.98 }, children: [currentThemeData.icon, showLabel && jsxRuntime.jsx("span", { className: styles$7.label, children: currentThemeData.label })] }), jsxRuntime.jsx(framerMotion.motion.div, { className: styles$7.dropdownMenu, initial: { opacity: 0, y: -10 }, animate: { opacity: 1, y: 0 }, children: themes.map((t) => (jsxRuntime.jsxs(framerMotion.motion.button, { className: `${styles$7.dropdownItem} ${theme === t.value ? styles$7.active : ''}`, onClick: () => setTheme(t.value), whileHover: { x: 4 }, whileTap: { scale: 0.98 }, children: [jsxRuntime.jsx("span", { className: styles$7.icon, children: t.icon }), jsxRuntime.jsx("span", { className: styles$7.text, children: t.label })] }, t.value))) })] }));
|
|
1522
1533
|
}
|
|
1523
1534
|
// Default button variant - cycles through themes
|
|
1524
1535
|
return (jsxRuntime.jsxs(framerMotion.motion.button, { className: `${styles$7.button} ${className}`, onClick: () => {
|
|
1525
1536
|
const nextIndex = (currentThemeIndex + 1) % themes.length;
|
|
1526
1537
|
setTheme(themes[nextIndex].value);
|
|
1527
|
-
}, whileTap: { scale: 0.95 }, whileHover: { scale: 1.05 }, "aria-label": `Current theme: ${
|
|
1538
|
+
}, whileTap: { scale: 0.95 }, whileHover: { scale: 1.05 }, "aria-label": `Current theme: ${currentThemeData.label}. Click to change.`, children: [jsxRuntime.jsx(framerMotion.motion.div, { initial: { rotate: -180, opacity: 0 }, animate: { rotate: 0, opacity: 1 }, exit: { rotate: 180, opacity: 0 }, transition: { duration: 0.3 }, className: styles$7.iconWrapper, children: currentThemeData.icon }, theme), showLabel && jsxRuntime.jsx("span", { className: styles$7.label, children: currentThemeData.label })] }));
|
|
1528
1539
|
};
|
|
1529
1540
|
|
|
1530
1541
|
// THIS FILE IS AUTO GENERATED
|