@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.
@@ -1,9 +1,16 @@
1
1
  import React from 'react';
2
- interface ThemeSwitcherProps {
2
+ export interface ThemeOption {
3
+ value: string;
4
+ label: string;
5
+ icon: React.ReactNode;
6
+ }
7
+ export interface ThemeSwitcherProps {
3
8
  variant?: 'button' | 'dropdown' | 'toggle';
4
9
  showLabel?: boolean;
5
10
  className?: string;
11
+ currentTheme?: string;
12
+ onThemeChange?: (theme: string) => void;
13
+ themes?: ThemeOption[];
6
14
  }
7
15
  export declare const ThemeSwitcher: React.FC<ThemeSwitcherProps>;
8
- export {};
9
16
  //# sourceMappingURL=ThemeSwitcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeSwitcher.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/ThemeSwitcher/ThemeSwitcher.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,kBAAkB;IACxB,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAuGtD,CAAC"}
1
+ {"version":3,"file":"ThemeSwitcher.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/ThemeSwitcher/ThemeSwitcher.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IAC/B,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsHtD,CAAC"}
@@ -5,6 +5,7 @@ export type { SearchBarProps } from './SearchBar';
5
5
  export { TimeInput } from './TimeInput';
6
6
  export type { TimeInputProps } from './TimeInput';
7
7
  export { ThemeSwitcher } from './ThemeSwitcher/ThemeSwitcher';
8
+ export type { ThemeSwitcherProps, ThemeOption } from './ThemeSwitcher/ThemeSwitcher';
8
9
  export { Tabs } from './Tabs/Tabs';
9
10
  export type { TabType } from './Tabs/Tabs';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/molecules/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/molecules/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAErF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1479,9 +1479,19 @@ const useTheme = () => {
1479
1479
 
1480
1480
  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"};
1481
1481
 
1482
- const ThemeSwitcher = ({ variant = 'button', showLabel = false, className = '', }) => {
1483
- const { theme, setTheme } = useTheme();
1484
- const themes = [
1482
+ const ThemeSwitcher = ({ variant = 'button', showLabel = false, className = '', currentTheme, onThemeChange, themes: customThemes, }) => {
1483
+ // Try to use internal context if available, otherwise use props
1484
+ const contextTheme = (() => {
1485
+ try {
1486
+ return useTheme();
1487
+ }
1488
+ catch {
1489
+ return null;
1490
+ }
1491
+ })();
1492
+ const theme = currentTheme ?? contextTheme?.theme ?? 'light';
1493
+ const setTheme = onThemeChange ?? contextTheme?.setTheme ?? (() => { });
1494
+ const defaultThemes = [
1485
1495
  { value: 'light', label: 'Light', icon: jsx(FiSun, {}) },
1486
1496
  { value: 'dark', label: 'Dark', icon: jsx(FiMoon, {}) },
1487
1497
  { value: 'lossito', label: 'Lossito Light', icon: '✨' },
@@ -1489,21 +1499,22 @@ const ThemeSwitcher = ({ variant = 'button', showLabel = false, className = '',
1489
1499
  { value: 'dmood', label: 'Dmood Light', icon: '💙' },
1490
1500
  { value: 'dmood-dark', label: 'Dmood Dark', icon: '🌌' },
1491
1501
  ];
1502
+ const themes = customThemes ?? defaultThemes;
1492
1503
  const currentThemeIndex = themes.findIndex(t => t.value === theme);
1493
- const currentTheme = themes[currentThemeIndex];
1504
+ const currentThemeData = themes[currentThemeIndex] ?? themes[0];
1494
1505
  if (variant === 'toggle') {
1495
1506
  // Simple toggle between light and dark
1496
1507
  const isDark = theme.includes('dark');
1497
1508
  return (jsxs(motion.button, { className: `${styles$7.toggle} ${className}`, onClick: () => setTheme(isDark ? 'light' : 'dark'), whileTap: { scale: 0.95 }, "aria-label": "Toggle theme", children: [jsx(motion.div, { className: styles$7.toggleTrack, animate: { backgroundColor: isDark ? 'var(--color-primary)' : 'var(--color-border)' }, children: jsx(motion.div, { className: styles$7.toggleThumb, animate: { x: isDark ? 24 : 0 }, transition: { type: 'spring', stiffness: 500, damping: 30 }, children: isDark ? jsx(FiMoon, { size: 14 }) : jsx(FiSun, { size: 14 }) }) }), showLabel && jsx("span", { className: styles$7.label, children: isDark ? 'Dark' : 'Light' })] }));
1498
1509
  }
1499
1510
  if (variant === 'dropdown') {
1500
- return (jsxs("div", { className: `${styles$7.dropdown} ${className}`, children: [jsxs(motion.button, { className: styles$7.dropdownTrigger, whileTap: { scale: 0.98 }, children: [currentTheme.icon, showLabel && jsx("span", { className: styles$7.label, children: currentTheme.label })] }), jsx(motion.div, { className: styles$7.dropdownMenu, initial: { opacity: 0, y: -10 }, animate: { opacity: 1, y: 0 }, children: themes.map((t) => (jsxs(motion.button, { className: `${styles$7.dropdownItem} ${theme === t.value ? styles$7.active : ''}`, onClick: () => setTheme(t.value), whileHover: { x: 4 }, whileTap: { scale: 0.98 }, children: [jsx("span", { className: styles$7.icon, children: t.icon }), jsx("span", { className: styles$7.text, children: t.label })] }, t.value))) })] }));
1511
+ return (jsxs("div", { className: `${styles$7.dropdown} ${className}`, children: [jsxs(motion.button, { className: styles$7.dropdownTrigger, whileTap: { scale: 0.98 }, children: [currentThemeData.icon, showLabel && jsx("span", { className: styles$7.label, children: currentThemeData.label })] }), jsx(motion.div, { className: styles$7.dropdownMenu, initial: { opacity: 0, y: -10 }, animate: { opacity: 1, y: 0 }, children: themes.map((t) => (jsxs(motion.button, { className: `${styles$7.dropdownItem} ${theme === t.value ? styles$7.active : ''}`, onClick: () => setTheme(t.value), whileHover: { x: 4 }, whileTap: { scale: 0.98 }, children: [jsx("span", { className: styles$7.icon, children: t.icon }), jsx("span", { className: styles$7.text, children: t.label })] }, t.value))) })] }));
1501
1512
  }
1502
1513
  // Default button variant - cycles through themes
1503
1514
  return (jsxs(motion.button, { className: `${styles$7.button} ${className}`, onClick: () => {
1504
1515
  const nextIndex = (currentThemeIndex + 1) % themes.length;
1505
1516
  setTheme(themes[nextIndex].value);
1506
- }, whileTap: { scale: 0.95 }, whileHover: { scale: 1.05 }, "aria-label": `Current theme: ${currentTheme.label}. Click to change.`, children: [jsx(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: currentTheme.icon }, theme), showLabel && jsx("span", { className: styles$7.label, children: currentTheme.label })] }));
1517
+ }, whileTap: { scale: 0.95 }, whileHover: { scale: 1.05 }, "aria-label": `Current theme: ${currentThemeData.label}. Click to change.`, children: [jsx(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 && jsx("span", { className: styles$7.label, children: currentThemeData.label })] }));
1507
1518
  };
1508
1519
 
1509
1520
  // THIS FILE IS AUTO GENERATED