@shohojdhara/atomix 0.2.5 → 0.2.6
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/atomix.css +36 -8
- package/dist/atomix.min.css +1 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.esm.js +81 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +81 -39
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/applemix.css +36 -8
- package/dist/themes/applemix.min.css +1 -1
- package/dist/themes/boomdevs.css +36 -8
- package/dist/themes/boomdevs.min.css +1 -1
- package/dist/themes/esrar.css +36 -8
- package/dist/themes/esrar.min.css +1 -1
- package/dist/themes/flashtrade.css +36 -8
- package/dist/themes/flashtrade.min.css +1 -1
- package/dist/themes/mashroom.css +36 -8
- package/dist/themes/mashroom.min.css +1 -1
- package/dist/themes/shaj-default.css +36 -8
- package/dist/themes/shaj-default.min.css +1 -1
- package/package.json +1 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +0 -2
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +0 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +121 -11
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +146 -45
- package/src/components/ColorModeToggle/index.ts +1 -1
- package/src/lib/constants/components.ts +1 -1
- package/src/styles/06-components/_components.atomix-glass.scss +4 -3
- package/src/styles/06-components/_components.color-mode-toggle.scss +43 -6
package/dist/index.js
CHANGED
|
@@ -1563,7 +1563,7 @@ const ATOMIX_GLASS = {
|
|
|
1563
1563
|
CORNER_RADIUS: 16, // Default border-radius matching design system
|
|
1564
1564
|
PADDING: '0 0',
|
|
1565
1565
|
MODE: 'standard',
|
|
1566
|
-
OVER_LIGHT:
|
|
1566
|
+
OVER_LIGHT: false,
|
|
1567
1567
|
ENABLE_OVER_LIGHT_LAYERS: true,
|
|
1568
1568
|
},
|
|
1569
1569
|
CONSTANTS: {
|
|
@@ -2856,7 +2856,6 @@ const AtomixGlassContainer = React.forwardRef(({ children, className = '', style
|
|
|
2856
2856
|
padding: `var(--atomix-glass-container-padding)`,
|
|
2857
2857
|
borderRadius: `var(--atomix-glass-container-radius)`,
|
|
2858
2858
|
boxShadow: `var(--atomix-glass-container-box-shadow)`,
|
|
2859
|
-
transition: effectiveReducedMotion ? 'none' : 'all 0.2s ease-out',
|
|
2860
2859
|
}, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseDown: onMouseDown, onMouseUp: onMouseUp, children: [jsxRuntime.jsxs("div", { className: ATOMIX_GLASS.FILTER_CLASS, children: [jsxRuntime.jsx(GlassFilter, { mode: mode, id: filterId, displacementScale: typeof displacementScale === 'number' && !isNaN(displacementScale)
|
|
2861
2860
|
? displacementScale
|
|
2862
2861
|
: 0, aberrationIntensity: typeof aberrationIntensity === 'number' && !isNaN(aberrationIntensity)
|
|
@@ -3926,7 +3925,6 @@ function AtomixGlass({ children, displacementScale = ATOMIX_GLASS.DEFAULTS.DISPL
|
|
|
3926
3925
|
width: adjustedSize.width,
|
|
3927
3926
|
borderRadius: `${effectiveCornerRadius}px`,
|
|
3928
3927
|
transform: baseStyle.transform,
|
|
3929
|
-
transition: baseStyle.transition,
|
|
3930
3928
|
} }), jsxRuntime.jsx("div", { className: [
|
|
3931
3929
|
ATOMIX_GLASS.BACKGROUND_LAYER_CLASS,
|
|
3932
3930
|
ATOMIX_GLASS.BACKGROUND_LAYER_BLACK_CLASS,
|
|
@@ -3941,7 +3939,6 @@ function AtomixGlass({ children, displacementScale = ATOMIX_GLASS.DEFAULTS.DISPL
|
|
|
3941
3939
|
width: adjustedSize.width,
|
|
3942
3940
|
borderRadius: `${effectiveCornerRadius}px`,
|
|
3943
3941
|
transform: baseStyle.transform,
|
|
3944
|
-
transition: baseStyle.transition,
|
|
3945
3942
|
} }), shouldRenderOverLightLayers && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: ATOMIX_GLASS.BASE_LAYER_CLASS }), jsxRuntime.jsx("div", { className: ATOMIX_GLASS.OVERLAY_LAYER_CLASS }), jsxRuntime.jsx("div", { className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS, style: {
|
|
3946
3943
|
opacity: opacityValues.over *
|
|
3947
3944
|
ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
@@ -8894,58 +8891,103 @@ const WaterfallChart = React.memo(React.forwardRef(({ waterfallData = [], config
|
|
|
8894
8891
|
}));
|
|
8895
8892
|
WaterfallChart.displayName = 'WaterfallChart';
|
|
8896
8893
|
|
|
8897
|
-
const
|
|
8898
|
-
|
|
8894
|
+
const DEFAULT_STORAGE_KEY = 'atomix-color-mode';
|
|
8895
|
+
const DEFAULT_DATA_ATTRIBUTE = 'data-atomix-color-mode';
|
|
8896
|
+
const SIZE_MAP = {
|
|
8897
|
+
sm: 16,
|
|
8898
|
+
md: 24,
|
|
8899
|
+
lg: 32,
|
|
8900
|
+
};
|
|
8901
|
+
const ColorModeToggle = ({ className = '', style, value: controlledValue, defaultValue = 'light', onChange, lightIcon, darkIcon, size = 'md', disabled = false, storageKey = DEFAULT_STORAGE_KEY, dataAttribute = DEFAULT_DATA_ATTRIBUTE, disableStorage = false, disableSystemPreference = false, 'aria-label': ariaLabel, showTooltip = true, }) => {
|
|
8902
|
+
const isControlled = controlledValue !== undefined;
|
|
8903
|
+
const [internalMode, setInternalMode] = React.useState(defaultValue);
|
|
8904
|
+
const colorMode = isControlled ? controlledValue : internalMode;
|
|
8899
8905
|
// Initialize color mode from localStorage or system preference
|
|
8900
8906
|
React.useEffect(() => {
|
|
8907
|
+
if (isControlled)
|
|
8908
|
+
return;
|
|
8909
|
+
// SSR check
|
|
8910
|
+
if (typeof window === 'undefined')
|
|
8911
|
+
return;
|
|
8901
8912
|
// Check if color mode is already set in localStorage
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8913
|
+
if (!disableStorage) {
|
|
8914
|
+
try {
|
|
8915
|
+
const storedColorMode = localStorage.getItem(storageKey);
|
|
8916
|
+
if (storedColorMode === 'light' || storedColorMode === 'dark') {
|
|
8917
|
+
setInternalMode(storedColorMode);
|
|
8918
|
+
return;
|
|
8919
|
+
}
|
|
8920
|
+
}
|
|
8921
|
+
catch (error) {
|
|
8922
|
+
console.warn('ColorModeToggle: Failed to read from localStorage', error);
|
|
8923
|
+
}
|
|
8905
8924
|
}
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8925
|
+
// Use system preference if no stored preference
|
|
8926
|
+
if (!disableSystemPreference && window.matchMedia) {
|
|
8927
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
8928
|
+
if (prefersDark) {
|
|
8929
|
+
setInternalMode('dark');
|
|
8930
|
+
}
|
|
8909
8931
|
}
|
|
8910
|
-
}, []);
|
|
8932
|
+
}, [isControlled, disableStorage, disableSystemPreference, storageKey]);
|
|
8911
8933
|
// Update the document theme attribute when colorMode changes
|
|
8912
8934
|
React.useEffect(() => {
|
|
8935
|
+
if (typeof window === 'undefined')
|
|
8936
|
+
return;
|
|
8913
8937
|
const validColorMode = colorMode === 'dark' ? 'dark' : 'light';
|
|
8914
|
-
document.body.setAttribute(
|
|
8915
|
-
|
|
8916
|
-
|
|
8938
|
+
document.body.setAttribute(dataAttribute, validColorMode);
|
|
8939
|
+
if (!disableStorage) {
|
|
8940
|
+
try {
|
|
8941
|
+
localStorage.setItem(storageKey, validColorMode);
|
|
8942
|
+
}
|
|
8943
|
+
catch (error) {
|
|
8944
|
+
console.warn('ColorModeToggle: Failed to write to localStorage', error);
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
}, [colorMode, dataAttribute, disableStorage, storageKey]);
|
|
8917
8948
|
// Listen for system color scheme changes
|
|
8918
8949
|
React.useEffect(() => {
|
|
8950
|
+
if (isControlled || disableSystemPreference || typeof window === 'undefined')
|
|
8951
|
+
return;
|
|
8919
8952
|
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
8920
8953
|
const handleSystemThemeChange = (event) => {
|
|
8921
8954
|
// Only update if user hasn't explicitly set a preference
|
|
8922
|
-
if (
|
|
8923
|
-
|
|
8924
|
-
}
|
|
8925
|
-
};
|
|
8926
|
-
// Add event listener for system theme changes
|
|
8927
|
-
if (darkModeMediaQuery.addEventListener) {
|
|
8928
|
-
darkModeMediaQuery.addEventListener('change', handleSystemThemeChange);
|
|
8929
|
-
}
|
|
8930
|
-
else {
|
|
8931
|
-
// Fallback for older browsers
|
|
8932
|
-
darkModeMediaQuery.addListener(handleSystemThemeChange);
|
|
8933
|
-
}
|
|
8934
|
-
// Clean up event listener
|
|
8935
|
-
return () => {
|
|
8936
|
-
if (darkModeMediaQuery.removeEventListener) {
|
|
8937
|
-
darkModeMediaQuery.removeEventListener('change', handleSystemThemeChange);
|
|
8955
|
+
if (disableStorage) {
|
|
8956
|
+
setInternalMode(event.matches ? 'dark' : 'light');
|
|
8938
8957
|
}
|
|
8939
8958
|
else {
|
|
8940
|
-
|
|
8941
|
-
|
|
8959
|
+
try {
|
|
8960
|
+
const hasStoredPreference = localStorage.getItem(storageKey);
|
|
8961
|
+
if (!hasStoredPreference) {
|
|
8962
|
+
setInternalMode(event.matches ? 'dark' : 'light');
|
|
8963
|
+
}
|
|
8964
|
+
}
|
|
8965
|
+
catch (error) {
|
|
8966
|
+
console.warn('ColorModeToggle: Failed to check localStorage', error);
|
|
8967
|
+
}
|
|
8942
8968
|
}
|
|
8943
8969
|
};
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8970
|
+
darkModeMediaQuery.addEventListener('change', handleSystemThemeChange);
|
|
8971
|
+
return () => {
|
|
8972
|
+
darkModeMediaQuery.removeEventListener('change', handleSystemThemeChange);
|
|
8973
|
+
};
|
|
8974
|
+
}, [isControlled, disableSystemPreference, disableStorage, storageKey]);
|
|
8975
|
+
const toggleColorMode = React.useCallback(() => {
|
|
8976
|
+
if (disabled)
|
|
8977
|
+
return;
|
|
8978
|
+
const newMode = colorMode === 'light' ? 'dark' : 'light';
|
|
8979
|
+
if (!isControlled) {
|
|
8980
|
+
setInternalMode(newMode);
|
|
8981
|
+
}
|
|
8982
|
+
onChange?.(newMode);
|
|
8983
|
+
}, [disabled, colorMode, isControlled, onChange]);
|
|
8984
|
+
const iconSize = SIZE_MAP[size];
|
|
8985
|
+
const nextMode = colorMode === 'light' ? 'dark' : 'light';
|
|
8986
|
+
const label = ariaLabel || `Switch to ${nextMode} mode`;
|
|
8987
|
+
const title = showTooltip ? `Switch to ${nextMode} mode` : undefined;
|
|
8988
|
+
const defaultLightIcon = (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: iconSize, height: iconSize, fill: "currentColor", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M9.37 5.51c-.18.64-.27 1.31-.27 1.99 0 4.08 3.32 7.4 7.4 7.4.68 0 1.35-.09 1.99-.27C17.45 17.19 14.93 19 12 19c-3.86 0-7-3.14-7-7 0-2.93 1.81-5.45 4.37-6.49zM12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9c0-.46-.04-.92-.1-1.36-.98 1.37-2.58 2.26-4.4 2.26-2.98 0-5.4-2.42-5.4-5.4 0-1.81.89-3.42 2.26-4.4-.44-.06-.9-.1-1.36-.1z" }) }));
|
|
8989
|
+
const defaultDarkIcon = (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: iconSize, height: iconSize, fill: "currentColor", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41L5.99 4.58zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41l-1.06-1.06zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41.39.39 1.03.39 1.41 0l1.06-1.06zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41.39.39 1.03.39 1.41 0l1.06-1.06z" }) }));
|
|
8990
|
+
return (jsxRuntime.jsx("button", { type: "button", className: `c-color-mode-toggle c-color-mode-toggle--${size} ${disabled ? 'c-color-mode-toggle--disabled' : ''} ${className}`, onClick: toggleColorMode, disabled: disabled, "aria-label": label, "aria-pressed": colorMode === 'dark', title: title, style: style, children: colorMode === 'light' ? (lightIcon || defaultLightIcon) : (darkIcon || defaultDarkIcon) }));
|
|
8949
8991
|
};
|
|
8950
8992
|
ColorModeToggle.displayName = 'ColorModeToggle';
|
|
8951
8993
|
|