@shohojdhara/atomix 0.4.4 → 0.4.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 +50 -11
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +1 -1
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.js +184 -189
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +4 -4
- package/dist/core.js +194 -199
- package/dist/core.js.map +1 -1
- package/dist/forms.js +184 -189
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +189 -194
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +44 -47
- package/dist/index.esm.js +496 -613
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +528 -631
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +60 -39
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +8 -42
- package/src/components/AtomixGlass/glass-utils.ts +27 -14
- package/src/components/AtomixGlass/stories/Overview.stories.tsx +19 -21
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +1162 -515
- package/src/components/AtomixGlass/stories/shared-components.tsx +11 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +5 -5
- package/src/components/Breadcrumb/BreadcrumbCompound.test.tsx +2 -2
- package/src/components/Button/Button.tsx +6 -6
- package/src/components/Card/Card.tsx +3 -3
- package/src/components/Dropdown/Dropdown.tsx +5 -3
- package/src/components/Footer/Footer.tsx +124 -166
- package/src/components/Footer/FooterLink.tsx +16 -19
- package/src/components/Footer/FooterSection.tsx +40 -39
- package/src/components/Footer/FooterSocialLink.tsx +59 -58
- package/src/components/Footer/README.md +1 -1
- package/src/components/Hero/Hero.tsx +72 -142
- package/src/components/Navigation/Menu/MegaMenu.tsx +17 -12
- package/src/components/Navigation/Menu/Menu.tsx +49 -24
- package/src/components/Navigation/Nav/NavItem.tsx +5 -3
- package/src/components/Navigation/Navbar/Navbar.tsx +13 -5
- package/src/components/Navigation/SideMenu/SideMenu.tsx +2 -2
- package/src/components/Navigation/SideMenu/SideMenuItem.tsx +4 -4
- package/src/components/Slider/Slider.tsx +7 -4
- package/src/lib/composables/index.ts +1 -2
- package/src/lib/composables/useAtomixGlass.ts +246 -222
- package/src/lib/composables/useAtomixGlassStyles.ts +46 -23
- package/src/lib/composables/useFooter.ts +117 -20
- package/src/lib/composables/useSlider.ts +3 -1
- package/src/lib/constants/components.ts +3 -1
- package/src/lib/types/components.ts +44 -12
- package/src/styles/06-components/_components.atomix-glass.scss +72 -14
- package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +0 -222
- package/src/lib/composables/atomix-glass/useGlassBackgroundDetection.ts +0 -329
- package/src/lib/composables/atomix-glass/useGlassCornerRadius.ts +0 -82
- package/src/lib/composables/atomix-glass/useGlassMouseTracking.ts +0 -153
- package/src/lib/composables/atomix-glass/useGlassOverLight.ts +0 -198
- package/src/lib/composables/atomix-glass/useGlassState.ts +0 -112
- package/src/lib/composables/atomix-glass/useGlassTransforms.ts +0 -160
- package/src/lib/composables/glass-styles.ts +0 -302
- package/src/lib/composables/useGlassContainer.ts +0 -177
package/dist/forms.js
CHANGED
|
@@ -58,7 +58,9 @@ import React, { memo, forwardRef, useMemo, useState, useRef, useEffect, useCallb
|
|
|
58
58
|
ENABLE_OVER_LIGHT_LAYERS: !0
|
|
59
59
|
},
|
|
60
60
|
CONSTANTS: {
|
|
61
|
-
ACTIVATION_ZONE:
|
|
61
|
+
ACTIVATION_ZONE: 350,
|
|
62
|
+
LERP_FACTOR: .08,
|
|
63
|
+
SMOOTHSTEP_POWER: 2.5,
|
|
62
64
|
MIN_BLUR: .1,
|
|
63
65
|
MOUSE_INFLUENCE_DIVISOR: 100,
|
|
64
66
|
EDGE_FADE_PIXELS: 2,
|
|
@@ -294,7 +296,7 @@ import React, { memo, forwardRef, useMemo, useState, useRef, useEffect, useCallb
|
|
|
294
296
|
// Silently handle errors
|
|
295
297
|
}
|
|
296
298
|
return CONSTANTS$2.DEFAULT_CORNER_RADIUS;
|
|
297
|
-
}, getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
299
|
+
}, lerp = (a, b, t) => a + (b - a) * t, softClamp = (value, max) => max <= 0 ? 0 : max * (1 - Math.exp(-value / max)), getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
298
300
|
switch (mode) {
|
|
299
301
|
case "standard":
|
|
300
302
|
return displacementMap;
|
|
@@ -467,7 +469,7 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
467
469
|
}, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseDown: onMouseDown, onMouseUp: onMouseUp, isHovered: isHovered = !1, isActive: isActive = !1, overLight: overLight = !1, overLightConfig: overLightConfig = {}, borderRadius: borderRadius = 0, padding: padding = "0 0", glassSize: glassSize = {
|
|
468
470
|
width: 0,
|
|
469
471
|
height: 0
|
|
470
|
-
}, onClick: onClick, mode: mode = "standard", effectiveWithoutEffects: effectiveWithoutEffects = !1, effectiveReducedMotion: effectiveReducedMotion = !1, shaderVariant: shaderVariant = "liquidGlass", withLiquidBlur: withLiquidBlur = !1,
|
|
472
|
+
}, onClick: onClick, mode: mode = "standard", effectiveWithoutEffects: effectiveWithoutEffects = !1, effectiveReducedMotion: effectiveReducedMotion = !1, shaderVariant: shaderVariant = "liquidGlass", withLiquidBlur: withLiquidBlur = !1, contentRef: contentRef}, ref) => {
|
|
471
473
|
// Generate a stable, deterministic ID for SSR compatibility
|
|
472
474
|
// Use a module-level counter that's consistent across server and client
|
|
473
475
|
const filterId = useMemo((() => "atomix-glass-filter-" + ++idCounter), []), [shaderMapUrl, setShaderMapUrl] = useState(""), shaderGeneratorRef = useRef(null), shaderUtilsRef = useRef(null), shaderDebounceTimeoutRef = useRef(null);
|
|
@@ -652,21 +654,12 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
652
654
|
onClick: onClick,
|
|
653
655
|
children: jsxs("div", {
|
|
654
656
|
className: ATOMIX_GLASS.INNER_CLASS,
|
|
655
|
-
style: {
|
|
656
|
-
padding: "var(--atomix-glass-container-padding)",
|
|
657
|
-
boxShadow: "var(--atomix-glass-container-box-shadow)"
|
|
658
|
-
},
|
|
659
657
|
onMouseEnter: onMouseEnter,
|
|
660
658
|
onMouseLeave: onMouseLeave,
|
|
661
659
|
onMouseDown: onMouseDown,
|
|
662
660
|
onMouseUp: onMouseUp,
|
|
663
661
|
children: [ jsxs("div", {
|
|
664
662
|
className: ATOMIX_GLASS.FILTER_CLASS,
|
|
665
|
-
style: {
|
|
666
|
-
zIndex: 1,
|
|
667
|
-
position: "absolute",
|
|
668
|
-
inset: 0
|
|
669
|
-
},
|
|
670
663
|
children: [ jsx(GlassFilter, {
|
|
671
664
|
blurAmount: blurAmount,
|
|
672
665
|
mode: mode,
|
|
@@ -681,28 +674,14 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
681
674
|
},
|
|
682
675
|
className: ATOMIX_GLASS.FILTER_OVERLAY_CLASS,
|
|
683
676
|
style: {
|
|
684
|
-
filter: `url(#${filterId})
|
|
685
|
-
backdropFilter: "var(--atomix-glass-container-backdrop)",
|
|
686
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
677
|
+
filter: `url(#${filterId})`
|
|
687
678
|
}
|
|
688
679
|
}), jsx("div", {
|
|
689
|
-
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
690
|
-
style: {
|
|
691
|
-
boxShadow: "var(--atomix-glass-container-shadow)",
|
|
692
|
-
opacity: "var(--atomix-glass-container-shadow-opacity)",
|
|
693
|
-
background: "var(--atomix-glass-container-bg)",
|
|
694
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
695
|
-
}
|
|
680
|
+
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
696
681
|
}) ]
|
|
697
682
|
}), jsx("div", {
|
|
698
683
|
ref: contentRef,
|
|
699
684
|
className: ATOMIX_GLASS.CONTENT_CLASS,
|
|
700
|
-
style: {
|
|
701
|
-
position: "relative",
|
|
702
|
-
textShadow: "var(--atomix-glass-container-text-shadow)",
|
|
703
|
-
// Ensure content is always above the filter layer (zIndex 1)
|
|
704
|
-
zIndex: elasticity > 0 ? 100 : 2
|
|
705
|
-
},
|
|
706
685
|
children: children
|
|
707
686
|
}) ]
|
|
708
687
|
})
|
|
@@ -806,31 +785,39 @@ class {
|
|
|
806
785
|
saturationBoost: baseOverLightConfig.saturationBoost
|
|
807
786
|
};
|
|
808
787
|
// Calculate mouse influence
|
|
809
|
-
|
|
810
|
-
let elasticTranslation = {
|
|
788
|
+
let computedDirectionalScale = directionalScale, elasticTranslation = {
|
|
811
789
|
x: 0,
|
|
812
790
|
y: 0
|
|
813
791
|
};
|
|
814
|
-
|
|
792
|
+
// Calculate elastic translation and directional scale
|
|
793
|
+
if (!effectiveWithoutEffects && wrapperElement) {
|
|
815
794
|
const rect = wrapperElement.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
816
|
-
//
|
|
817
|
-
let fadeInFactor = 0;
|
|
795
|
+
// Mouse presence and edge distance logic
|
|
818
796
|
if (globalMousePosition.x && globalMousePosition.y && validateGlassSize(glassSize)) {
|
|
819
|
-
const edgeDistanceX = Math.max(0, Math.abs(
|
|
797
|
+
const deltaX = globalMousePosition.x - center.x, deltaY = globalMousePosition.y - center.y, edgeDistanceX = Math.max(0, Math.abs(deltaX) - glassSize.width / 2), edgeDistanceY = Math.max(0, Math.abs(deltaY) - glassSize.height / 2), edgeDistance = calculateDistance({
|
|
820
798
|
x: edgeDistanceX,
|
|
821
799
|
y: edgeDistanceY
|
|
822
800
|
}, {
|
|
823
801
|
x: 0,
|
|
824
802
|
y: 0
|
|
825
|
-
})
|
|
826
|
-
|
|
803
|
+
}), rawT = edgeDistance > ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE, fadeInFactor = (t => {
|
|
804
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
805
|
+
return clamped * clamped * (3 - 2 * clamped);
|
|
806
|
+
})(rawT);
|
|
807
|
+
// Directional scale
|
|
808
|
+
if (elasticTranslation = {
|
|
809
|
+
x: deltaX * elasticity * .1 * fadeInFactor,
|
|
810
|
+
y: deltaY * elasticity * .1 * fadeInFactor
|
|
811
|
+
}, !isOverLight && edgeDistance <= ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE) {
|
|
812
|
+
const centerDistance = calculateDistance(globalMousePosition, center);
|
|
813
|
+
if (centerDistance > 0) {
|
|
814
|
+
const normalizedX = deltaX / centerDistance, normalizedY = deltaY / centerDistance, stretchIntensity = Math.min(centerDistance / 300, 1) * elasticity * rawT, scaleX = 1 + Math.abs(normalizedX) * stretchIntensity * .3 - Math.abs(normalizedY) * stretchIntensity * .15, scaleY = 1 + Math.abs(normalizedY) * stretchIntensity * .3 - Math.abs(normalizedX) * stretchIntensity * .15, softScaleX = 1 - softClamp(Math.max(0, 1 - scaleX), .2), softScaleY = 1 - softClamp(Math.max(0, 1 - scaleY), .2);
|
|
815
|
+
computedDirectionalScale = `scaleX(${Math.max(.85, softScaleX)}) scaleY(${Math.max(.85, softScaleY)})`;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
827
818
|
}
|
|
828
|
-
elasticTranslation = {
|
|
829
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
830
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
831
|
-
};
|
|
832
819
|
}
|
|
833
|
-
const transformStyle = effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" :
|
|
820
|
+
const transformStyle = effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" : computedDirectionalScale}`;
|
|
834
821
|
// Update Wrapper Styles (glassVars)
|
|
835
822
|
if (wrapperElement) {
|
|
836
823
|
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT, borderGradientAngle = GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER, borderStop1 = Math.max(GRADIENT.BORDER_STOP_1.MIN, GRADIENT.BORDER_STOP_1.BASE + my * GRADIENT.BORDER_STOP_1.MULTIPLIER), borderStop2 = Math.min(GRADIENT.BORDER_STOP_2.MAX, GRADIENT.BORDER_STOP_2.BASE + my * GRADIENT.BORDER_STOP_2.MULTIPLIER), borderOpacities = [ GRADIENT.BORDER_OPACITY.BASE_1 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_LOW, GRADIENT.BORDER_OPACITY.BASE_2 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_HIGH, GRADIENT.BORDER_OPACITY.BASE_3 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_LOW, GRADIENT.BORDER_OPACITY.BASE_4 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_HIGH ], configBorderOpacity = overLightConfig.borderOpacity, whiteColor = ATOMIX_GLASS.CONSTANTS.PALETTE.WHITE, blackColor = ATOMIX_GLASS.CONSTANTS.PALETTE.BLACK, hoverPositions = {
|
|
@@ -937,7 +924,13 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
937
924
|
}), internalMouseOffsetRef = useRef({
|
|
938
925
|
x: 0,
|
|
939
926
|
y: 0
|
|
940
|
-
}),
|
|
927
|
+
}), targetMouseOffsetRef = useRef({
|
|
928
|
+
x: 0,
|
|
929
|
+
y: 0
|
|
930
|
+
}), targetGlobalMousePositionRef = useRef({
|
|
931
|
+
x: 0,
|
|
932
|
+
y: 0
|
|
933
|
+
}), lerpRafRef = useRef(null), lerpActiveRef = useRef(!1), [dynamicBorderRadius, setDynamicCornerRadius] = useState(CONSTANTS.DEFAULT_CORNER_RADIUS), [userPrefersReducedMotion, setUserPrefersReducedMotion] = useState(!1), [userPrefersHighContrast, setUserPrefersHighContrast] = useState(!1), [detectedOverLight, setDetectedOverLight] = useState(!1), effectiveBorderRadius = useMemo((() => void 0 !== borderRadius ? Math.max(0, borderRadius) : Math.max(0, dynamicBorderRadius)), [ borderRadius, dynamicBorderRadius ]), {glassSize: glassSize} = function({glassRef: glassRef, effectiveBorderRadius: effectiveBorderRadius, cachedRectRef: cachedRectRef}) {
|
|
941
934
|
const [glassSize, setGlassSize] = useState({
|
|
942
935
|
width: 270,
|
|
943
936
|
height: 69
|
|
@@ -1034,7 +1027,23 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1034
1027
|
const timeoutId = setTimeout(extractRadius, 100);
|
|
1035
1028
|
return () => clearTimeout(timeoutId);
|
|
1036
1029
|
}), [ children, debugBorderRadius, contentRef ]),
|
|
1037
|
-
// Media query
|
|
1030
|
+
// Media query detection for reduced motion and high contrast
|
|
1031
|
+
useEffect((() => {
|
|
1032
|
+
if ("undefined" == typeof window || "function" != typeof window.matchMedia) return;
|
|
1033
|
+
const mediaQueryReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)"), mediaQueryHighContrast = window.matchMedia("(prefers-contrast: high)");
|
|
1034
|
+
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
1035
|
+
const handleReducedMotionChange = e => {
|
|
1036
|
+
setUserPrefersReducedMotion(e.matches);
|
|
1037
|
+
}, handleHighContrastChange = e => {
|
|
1038
|
+
setUserPrefersHighContrast(e.matches);
|
|
1039
|
+
};
|
|
1040
|
+
return mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
1041
|
+
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange), () => {
|
|
1042
|
+
mediaQueryReducedMotion.removeEventListener("change", handleReducedMotionChange),
|
|
1043
|
+
mediaQueryHighContrast.removeEventListener("change", handleHighContrastChange);
|
|
1044
|
+
};
|
|
1045
|
+
}), []),
|
|
1046
|
+
// Background detection for overLight auto-detect
|
|
1038
1047
|
useEffect((() => {
|
|
1039
1048
|
if (("auto" === overLight || "object" == typeof overLight && null !== overLight) && glassRef.current) {
|
|
1040
1049
|
const element = glassRef.current, cachedResult = ((parentElement, overLightConfig) => {
|
|
@@ -1134,102 +1143,36 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1134
1143
|
}), 150);
|
|
1135
1144
|
return () => clearTimeout(timeoutId);
|
|
1136
1145
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
1140
|
-
const handleReducedMotionChange = e => {
|
|
1141
|
-
setUserPrefersReducedMotion(e.matches);
|
|
1142
|
-
}, handleHighContrastChange = e => {
|
|
1143
|
-
setUserPrefersHighContrast(e.matches);
|
|
1144
|
-
};
|
|
1145
|
-
return mediaQueryReducedMotion.addEventListener ? (mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
1146
|
-
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange)) : mediaQueryReducedMotion.addListener && (mediaQueryReducedMotion.addListener(handleReducedMotionChange),
|
|
1147
|
-
mediaQueryHighContrast.addListener(handleHighContrastChange)), () => {
|
|
1148
|
-
// ignore
|
|
1149
|
-
};
|
|
1150
|
-
} catch (error) {
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
}), [ overLight, glassRef, debugOverLight ]);
|
|
1146
|
+
"boolean" == typeof overLight && setDetectedOverLight(!1);
|
|
1147
|
+
}), [ overLight, glassRef ]);
|
|
1154
1148
|
/**
|
|
1155
1149
|
* Get effective overLight value based on configuration
|
|
1156
1150
|
*/
|
|
1157
|
-
const getEffectiveOverLight = useCallback((() => "boolean" == typeof overLight ? overLight : ("auto" === overLight || "object" == typeof overLight && null !== overLight) && detectedOverLight), [ overLight, detectedOverLight ]), validateConfigValue = useCallback(((value, min, max, defaultValue) => "number" != typeof value || isNaN(value) || !isFinite(value) ? defaultValue : Math.min(max, Math.max(min, value))), []),
|
|
1158
|
-
const isOverLight = getEffectiveOverLight(), baseConfig = {
|
|
1151
|
+
const getEffectiveOverLight = useCallback((() => "boolean" == typeof overLight ? overLight : ("auto" === overLight || "object" == typeof overLight && null !== overLight) && detectedOverLight), [ overLight, detectedOverLight ]), validateConfigValue = useCallback(((value, min, max, defaultValue) => "number" != typeof value || isNaN(value) || !isFinite(value) ? defaultValue : Math.min(max, Math.max(min, value))), []), overLightConfig = useMemo((() => {
|
|
1152
|
+
const isOverLight = getEffectiveOverLight(), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1, baseConfig = {
|
|
1159
1153
|
isOverLight: isOverLight,
|
|
1160
1154
|
threshold: .7,
|
|
1161
|
-
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5)) : 0,
|
|
1162
|
-
contrast: 1,
|
|
1163
|
-
|
|
1164
|
-
brightness: 1,
|
|
1165
|
-
// Base brightness
|
|
1155
|
+
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5 * hoverIntensity * activeIntensity)) : 0,
|
|
1156
|
+
contrast: 1.4,
|
|
1157
|
+
brightness: .9,
|
|
1166
1158
|
saturationBoost: 1.3,
|
|
1159
|
+
// Fixed value — dynamic saturation amplifies perceived displacement
|
|
1167
1160
|
shadowIntensity: .9,
|
|
1168
1161
|
borderOpacity: .7
|
|
1169
1162
|
};
|
|
1170
1163
|
if ("object" == typeof overLight && null !== overLight) {
|
|
1171
|
-
const objConfig = overLight, validatedThreshold = validateConfigValue(objConfig.threshold, .1, 1, baseConfig.threshold), validatedOpacity = validateConfigValue(objConfig.opacity, .1, 1, baseConfig.opacity), validatedContrast = validateConfigValue(objConfig.contrast, .5, 2.5, baseConfig.contrast), validatedBrightness = validateConfigValue(objConfig.brightness, .5, 2, baseConfig.brightness), validatedSaturationBoost = validateConfigValue(objConfig.saturationBoost, .5, 3, baseConfig.saturationBoost)
|
|
1172
|
-
return {
|
|
1164
|
+
const objConfig = overLight, validatedThreshold = validateConfigValue(objConfig.threshold, .1, 1, baseConfig.threshold), validatedOpacity = validateConfigValue(objConfig.opacity, .1, 1, baseConfig.opacity), validatedContrast = validateConfigValue(objConfig.contrast, .5, 2.5, baseConfig.contrast), validatedBrightness = validateConfigValue(objConfig.brightness, .5, 2, baseConfig.brightness), validatedSaturationBoost = validateConfigValue(objConfig.saturationBoost, .5, 3, baseConfig.saturationBoost), finalConfig = {
|
|
1173
1165
|
...baseConfig,
|
|
1174
1166
|
threshold: validatedThreshold,
|
|
1175
|
-
opacity: validatedOpacity,
|
|
1167
|
+
opacity: validatedOpacity * hoverIntensity * activeIntensity,
|
|
1176
1168
|
contrast: validatedContrast,
|
|
1177
1169
|
brightness: validatedBrightness,
|
|
1178
1170
|
saturationBoost: validatedSaturationBoost
|
|
1179
1171
|
};
|
|
1172
|
+
return "undefined" == typeof process || process.env, finalConfig;
|
|
1180
1173
|
}
|
|
1181
|
-
return baseConfig;
|
|
1182
|
-
}), [ overLight, getEffectiveOverLight, validateConfigValue ]),
|
|
1183
|
-
const mouseInfluence = calculateMouseInfluence(mouseOffset), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1;
|
|
1184
|
-
return {
|
|
1185
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
1186
|
-
threshold: baseOverLightConfig.threshold,
|
|
1187
|
-
opacity: baseOverLightConfig.opacity * hoverIntensity * activeIntensity,
|
|
1188
|
-
contrast: Math.min(1.6, baseOverLightConfig.contrast + .1 * mouseInfluence),
|
|
1189
|
-
brightness: Math.min(1.1, baseOverLightConfig.brightness + .05 * mouseInfluence),
|
|
1190
|
-
saturationBoost: baseOverLightConfig.saturationBoost,
|
|
1191
|
-
shadowIntensity: Math.min(1.2, Math.max(.5, baseOverLightConfig.shadowIntensity + .2 * mouseInfluence)),
|
|
1192
|
-
borderOpacity: Math.min(1, Math.max(.3, baseOverLightConfig.borderOpacity + .1 * mouseInfluence))
|
|
1193
|
-
};
|
|
1194
|
-
}), [ baseOverLightConfig, mouseOffset, isHovered, isActive ]), updateRectRef = useRef(null), calculateDirectionalScale = useCallback((() => {
|
|
1195
|
-
if (baseOverLightConfig.isOverLight) return "scale(1)";
|
|
1196
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return "scale(1)";
|
|
1197
|
-
const rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect), deltaX = globalMousePosition.x - center.x, deltaY = globalMousePosition.y - center.y, edgeDistanceX = Math.max(0, Math.abs(deltaX) - glassSize.width / 2), edgeDistanceY = Math.max(0, Math.abs(deltaY) - glassSize.height / 2), edgeDistance = calculateDistance({
|
|
1198
|
-
x: edgeDistanceX,
|
|
1199
|
-
y: edgeDistanceY
|
|
1200
|
-
}, {
|
|
1201
|
-
x: 0,
|
|
1202
|
-
y: 0
|
|
1203
|
-
});
|
|
1204
|
-
if (edgeDistance > CONSTANTS.ACTIVATION_ZONE) return "scale(1)";
|
|
1205
|
-
const fadeInFactor = 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE, centerDistance = calculateDistance(globalMousePosition, center);
|
|
1206
|
-
if (0 === centerDistance) return "scale(1)";
|
|
1207
|
-
const normalizedX = deltaX / centerDistance, normalizedY = deltaY / centerDistance, stretchIntensity = Math.min(centerDistance / 300, 1) * elasticity * fadeInFactor, scaleX = 1 + Math.abs(normalizedX) * stretchIntensity * .3 - Math.abs(normalizedY) * stretchIntensity * .15, scaleY = 1 + Math.abs(normalizedY) * stretchIntensity * .3 - Math.abs(normalizedX) * stretchIntensity * .15;
|
|
1208
|
-
return `scaleX(${Math.max(.8, scaleX)}) scaleY(${Math.max(.8, scaleY)})`;
|
|
1209
|
-
}), [ globalMousePosition, elasticity, glassSize, glassRef, baseOverLightConfig ]), calculateFadeInFactor = useCallback((() => {
|
|
1210
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return 0;
|
|
1211
|
-
const rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect), edgeDistanceX = Math.max(0, Math.abs(globalMousePosition.x - center.x) - glassSize.width / 2), edgeDistanceY = Math.max(0, Math.abs(globalMousePosition.y - center.y) - glassSize.height / 2), edgeDistance = calculateDistance({
|
|
1212
|
-
x: edgeDistanceX,
|
|
1213
|
-
y: edgeDistanceY
|
|
1214
|
-
}, {
|
|
1215
|
-
x: 0,
|
|
1216
|
-
y: 0
|
|
1217
|
-
});
|
|
1218
|
-
return edgeDistance > CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE;
|
|
1219
|
-
}), [ globalMousePosition, glassSize, glassRef ]), calculateElasticTranslation = useCallback((() => {
|
|
1220
|
-
if (!glassRef.current) return {
|
|
1221
|
-
x: 0,
|
|
1222
|
-
y: 0
|
|
1223
|
-
};
|
|
1224
|
-
const fadeInFactor = calculateFadeInFactor(), rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
1225
|
-
return {
|
|
1226
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
1227
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
1228
|
-
};
|
|
1229
|
-
}), [ globalMousePosition, elasticity, calculateFadeInFactor, glassRef ]), elasticTranslation = useMemo((() => effectiveWithoutEffects ? {
|
|
1230
|
-
x: 0,
|
|
1231
|
-
y: 0
|
|
1232
|
-
} : calculateElasticTranslation()), [ calculateElasticTranslation, effectiveWithoutEffects ]), directionalScale = useMemo((() => effectiveWithoutEffects ? "scale(1)" : calculateDirectionalScale()), [ calculateDirectionalScale, effectiveWithoutEffects ]), transformStyle = useMemo((() => effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" : directionalScale}`), [ elasticTranslation, isActive, onClick, directionalScale, effectiveWithoutEffects ]), handleGlobalMousePosition = useCallback((globalPos => {
|
|
1174
|
+
return "undefined" == typeof process || process.env, baseConfig;
|
|
1175
|
+
}), [ overLight, getEffectiveOverLight, isHovered, isActive, validateConfigValue, debugOverLight ]), transformStyle = useMemo((() => effectiveWithoutEffects || isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)"), [ effectiveWithoutEffects, isActive, onClick ]), updateRectRef = useRef(null), handleGlobalMousePosition = useCallback((globalPos => {
|
|
1233
1176
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
1234
1177
|
if (effectiveWithoutEffects) return;
|
|
1235
1178
|
const container = mouseContainer?.current || glassRef.current;
|
|
@@ -1238,35 +1181,61 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1238
1181
|
let rect = cachedRectRef.current;
|
|
1239
1182
|
if (rect && 0 !== rect.width && 0 !== rect.height || (rect = container.getBoundingClientRect(),
|
|
1240
1183
|
cachedRectRef.current = rect), 0 === rect.width || 0 === rect.height) return;
|
|
1241
|
-
const center = calculateElementCenter(rect)
|
|
1184
|
+
const center = calculateElementCenter(rect);
|
|
1185
|
+
// Write raw target — the lerp loop will smoothly pursue it
|
|
1186
|
+
targetMouseOffsetRef.current = {
|
|
1242
1187
|
x: (globalPos.x - center.x) / rect.width * 100,
|
|
1243
1188
|
y: (globalPos.y - center.y) / rect.height * 100
|
|
1189
|
+
}, targetGlobalMousePositionRef.current = globalPos;
|
|
1190
|
+
}), [ mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]), startLerpLoop = useCallback((() => {
|
|
1191
|
+
if (lerpActiveRef.current) return;
|
|
1192
|
+
lerpActiveRef.current = !0;
|
|
1193
|
+
const LERP_T = CONSTANTS.LERP_FACTOR, tick = () => {
|
|
1194
|
+
if (!lerpActiveRef.current) return;
|
|
1195
|
+
const cur = internalMouseOffsetRef.current, tgt = targetMouseOffsetRef.current, dx = tgt.x - cur.x, dy = tgt.y - cur.y;
|
|
1196
|
+
// If we're close enough, snap and park
|
|
1197
|
+
if (Math.abs(dx) < .05 && Math.abs(dy) < .05) internalMouseOffsetRef.current = {
|
|
1198
|
+
...tgt
|
|
1199
|
+
}, internalGlobalMousePositionRef.current = {
|
|
1200
|
+
...targetGlobalMousePositionRef.current
|
|
1201
|
+
}; else {
|
|
1202
|
+
internalMouseOffsetRef.current = {
|
|
1203
|
+
x: lerp(cur.x, tgt.x, LERP_T),
|
|
1204
|
+
y: lerp(cur.y, tgt.y, LERP_T)
|
|
1205
|
+
};
|
|
1206
|
+
const curG = internalGlobalMousePositionRef.current, tgtG = targetGlobalMousePositionRef.current;
|
|
1207
|
+
internalGlobalMousePositionRef.current = {
|
|
1208
|
+
x: lerp(curG.x, tgtG.x, LERP_T),
|
|
1209
|
+
y: lerp(curG.y, tgtG.y, LERP_T)
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
// Imperative style update with the smoothed values
|
|
1213
|
+
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
1214
|
+
mouseOffset: internalMouseOffsetRef.current,
|
|
1215
|
+
globalMousePosition: internalGlobalMousePositionRef.current,
|
|
1216
|
+
glassSize: glassSize,
|
|
1217
|
+
isHovered: isHovered,
|
|
1218
|
+
isActive: isActive,
|
|
1219
|
+
isOverLight: overLightConfig.isOverLight,
|
|
1220
|
+
baseOverLightConfig: overLightConfig,
|
|
1221
|
+
effectiveBorderRadius: effectiveBorderRadius,
|
|
1222
|
+
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1223
|
+
effectiveReducedMotion: effectiveReducedMotion,
|
|
1224
|
+
elasticity: elasticity,
|
|
1225
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
1226
|
+
onClick: onClick,
|
|
1227
|
+
withLiquidBlur: withLiquidBlur,
|
|
1228
|
+
blurAmount: blurAmount,
|
|
1229
|
+
saturation: saturation,
|
|
1230
|
+
padding: padding
|
|
1231
|
+
}), lerpRafRef.current = requestAnimationFrame(tick);
|
|
1244
1232
|
};
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
globalMousePosition: globalPos,
|
|
1252
|
-
glassSize: glassSize,
|
|
1253
|
-
isHovered: isHovered,
|
|
1254
|
-
isActive: isActive,
|
|
1255
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
1256
|
-
baseOverLightConfig: baseOverLightConfig,
|
|
1257
|
-
effectiveBorderRadius: effectiveBorderRadius,
|
|
1258
|
-
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1259
|
-
effectiveReducedMotion: effectiveReducedMotion,
|
|
1260
|
-
elasticity: elasticity,
|
|
1261
|
-
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
1262
|
-
// Simplified directional scale for fast path
|
|
1263
|
-
onClick: onClick,
|
|
1264
|
-
withLiquidBlur: withLiquidBlur,
|
|
1265
|
-
blurAmount: blurAmount,
|
|
1266
|
-
saturation: saturation,
|
|
1267
|
-
padding: padding
|
|
1268
|
-
});
|
|
1269
|
-
}), [ mouseContainer, glassRef, wrapperRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects, glassSize, isHovered, isActive, baseOverLightConfig, effectiveBorderRadius, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]);
|
|
1233
|
+
// 0.08 – lower = more viscous
|
|
1234
|
+
lerpRafRef.current = requestAnimationFrame(tick);
|
|
1235
|
+
}), [ glassRef, wrapperRef, glassSize, isHovered, isActive, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]), stopLerpLoop = useCallback((() => {
|
|
1236
|
+
lerpActiveRef.current = !1, null !== lerpRafRef.current && (cancelAnimationFrame(lerpRafRef.current),
|
|
1237
|
+
lerpRafRef.current = null);
|
|
1238
|
+
}), []);
|
|
1270
1239
|
/**
|
|
1271
1240
|
* Validate and clamp a numeric config value
|
|
1272
1241
|
*/
|
|
@@ -1274,7 +1243,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1274
1243
|
useEffect((() => {
|
|
1275
1244
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
1276
1245
|
if (effectiveWithoutEffects) return;
|
|
1277
|
-
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition)
|
|
1246
|
+
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition);
|
|
1247
|
+
// Start the lerp loop — it will smoothly chase the target
|
|
1248
|
+
startLerpLoop();
|
|
1249
|
+
const container = mouseContainer?.current || glassRef.current;
|
|
1278
1250
|
let resizeObserver = null;
|
|
1279
1251
|
return container && "undefined" != typeof ResizeObserver && (resizeObserver = new ResizeObserver((() => {
|
|
1280
1252
|
null !== updateRectRef.current && cancelAnimationFrame(updateRectRef.current), updateRectRef.current = requestAnimationFrame((() => {
|
|
@@ -1282,10 +1254,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1282
1254
|
container && (cachedRectRef.current = container.getBoundingClientRect()), updateRectRef.current = null;
|
|
1283
1255
|
}));
|
|
1284
1256
|
})), resizeObserver.observe(container)), () => {
|
|
1285
|
-
unsubscribe(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
1257
|
+
unsubscribe(), stopLerpLoop(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
1286
1258
|
updateRectRef.current = null), resizeObserver && resizeObserver.disconnect();
|
|
1287
1259
|
};
|
|
1288
|
-
}), [ handleGlobalMousePosition, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
1260
|
+
}), [ handleGlobalMousePosition, startLerpLoop, stopLerpLoop, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
1289
1261
|
// Also call updateStyles on other state changes (hover, active, etc)
|
|
1290
1262
|
useEffect((() => {
|
|
1291
1263
|
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
@@ -1294,22 +1266,22 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1294
1266
|
glassSize: glassSize,
|
|
1295
1267
|
isHovered: isHovered,
|
|
1296
1268
|
isActive: isActive,
|
|
1297
|
-
isOverLight:
|
|
1298
|
-
baseOverLightConfig:
|
|
1269
|
+
isOverLight: overLightConfig.isOverLight,
|
|
1270
|
+
baseOverLightConfig: overLightConfig,
|
|
1299
1271
|
effectiveBorderRadius: effectiveBorderRadius,
|
|
1300
1272
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1301
1273
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
1302
1274
|
elasticity: elasticity,
|
|
1303
|
-
directionalScale:
|
|
1275
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
1304
1276
|
onClick: onClick,
|
|
1305
1277
|
withLiquidBlur: withLiquidBlur,
|
|
1306
1278
|
blurAmount: blurAmount,
|
|
1307
1279
|
saturation: saturation,
|
|
1308
1280
|
padding: padding
|
|
1309
1281
|
});
|
|
1310
|
-
}), [ isHovered, isActive, glassSize,
|
|
1282
|
+
}), [ isHovered, isActive, glassSize, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, wrapperRef, glassRef, externalMouseOffset, externalGlobalMousePosition, withLiquidBlur, blurAmount, saturation, padding, onClick ]);
|
|
1311
1283
|
// Event handlers
|
|
1312
|
-
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []),
|
|
1284
|
+
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []), handleKeyDown = useCallback((e => {
|
|
1313
1285
|
!onClick || "Enter" !== e.key && " " !== e.key || (e.preventDefault(), onClick());
|
|
1314
1286
|
}), [ onClick ]);
|
|
1315
1287
|
return {
|
|
@@ -1327,14 +1299,11 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1327
1299
|
mouseOffset: mouseOffset,
|
|
1328
1300
|
// This is now static (refs or props) unless prop changes
|
|
1329
1301
|
overLightConfig: overLightConfig,
|
|
1330
|
-
elasticTranslation: elasticTranslation,
|
|
1331
|
-
directionalScale: directionalScale,
|
|
1332
1302
|
transformStyle: transformStyle,
|
|
1333
1303
|
handleMouseEnter: handleMouseEnter,
|
|
1334
1304
|
handleMouseLeave: handleMouseLeave,
|
|
1335
1305
|
handleMouseDown: handleMouseDown,
|
|
1336
1306
|
handleMouseUp: handleMouseUp,
|
|
1337
|
-
handleMouseMove: handleMouseMove,
|
|
1338
1307
|
handleKeyDown: handleKeyDown
|
|
1339
1308
|
};
|
|
1340
1309
|
}
|
|
@@ -1432,25 +1401,56 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1432
1401
|
withLiquidBlur: withLiquidBlur,
|
|
1433
1402
|
padding: padding,
|
|
1434
1403
|
style: style
|
|
1435
|
-
}), isOverLight = useMemo((() => overLightConfig
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1404
|
+
}), isOverLight = useMemo((() => overLightConfig.isOverLight), [ overLightConfig.isOverLight ]), shouldRenderOverLightLayers = withOverLightLayers && isOverLight, {zIndex: customZIndex, ...restStyle} = style, isFixedOrSticky = "fixed" === restStyle.position || "sticky" === restStyle.position, rootLayoutStyle = useMemo((() => {
|
|
1405
|
+
if (!isFixedOrSticky) return {};
|
|
1406
|
+
const {position: p, top: t, left: l, right: r, bottom: b} = restStyle;
|
|
1407
|
+
return {
|
|
1408
|
+
...p && {
|
|
1409
|
+
position: p
|
|
1410
|
+
},
|
|
1411
|
+
...void 0 !== t && {
|
|
1412
|
+
top: t
|
|
1413
|
+
},
|
|
1414
|
+
...void 0 !== l && {
|
|
1415
|
+
left: l
|
|
1416
|
+
},
|
|
1417
|
+
...void 0 !== r && {
|
|
1418
|
+
right: r
|
|
1419
|
+
},
|
|
1420
|
+
...void 0 !== b && {
|
|
1421
|
+
bottom: b
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
}), [ isFixedOrSticky, restStyle ]), baseStyle = useMemo((() => {
|
|
1425
|
+
if (isFixedOrSticky) {
|
|
1426
|
+
const {position: _p, top: _t, left: _l, right: _r, bottom: _b, ...visualStyle} = restStyle;
|
|
1427
|
+
return {
|
|
1428
|
+
...visualStyle,
|
|
1429
|
+
...!effectiveWithoutEffects && {
|
|
1430
|
+
transform: transformStyle
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1439
1433
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1434
|
+
return {
|
|
1435
|
+
...restStyle,
|
|
1436
|
+
...!effectiveWithoutEffects && {
|
|
1437
|
+
transform: transformStyle
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
}), [ isFixedOrSticky, restStyle, effectiveWithoutEffects, transformStyle ]), componentClassName = [ ATOMIX_GLASS.BASE_CLASS, effectiveReducedMotion && `${ATOMIX_GLASS.BASE_CLASS}--reduced-motion`, effectiveHighContrast && `${ATOMIX_GLASS.BASE_CLASS}--high-contrast`, effectiveWithoutEffects && `${ATOMIX_GLASS.BASE_CLASS}--disabled-effects`, className ].filter(Boolean).join(" "), positionStyles = useMemo((() => ({
|
|
1441
|
+
position: isFixedOrSticky ? "absolute" : restStyle.position || "absolute",
|
|
1442
|
+
top: isFixedOrSticky ? 0 : restStyle.top || 0,
|
|
1443
|
+
left: isFixedOrSticky ? 0 : restStyle.left || 0
|
|
1444
|
+
})), [ isFixedOrSticky, restStyle.position, restStyle.top, restStyle.left ]), adjustedSize = useMemo((() => {
|
|
1445
1445
|
const resolveSize = (propValue, styleValue, measuredSize) => {
|
|
1446
1446
|
const explicitSize = propValue ?? styleValue;
|
|
1447
1447
|
return void 0 !== explicitSize ? "number" == typeof explicitSize ? `${explicitSize}px` : explicitSize : "fixed" === positionStyles.position ? `${Math.max(measuredSize, 0)}px` : "100%";
|
|
1448
1448
|
};
|
|
1449
1449
|
return {
|
|
1450
|
-
width: resolveSize(width,
|
|
1451
|
-
height: resolveSize(height,
|
|
1450
|
+
width: resolveSize(width, restStyle.width, glassSize.width),
|
|
1451
|
+
height: resolveSize(height, restStyle.height, glassSize.height)
|
|
1452
1452
|
};
|
|
1453
|
-
}), [ width, height,
|
|
1453
|
+
}), [ width, height, restStyle.width, restStyle.height, positionStyles.position, glassSize.width, glassSize.height ]), gradientValues = useMemo((() => {
|
|
1454
1454
|
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT;
|
|
1455
1455
|
return {
|
|
1456
1456
|
borderGradientAngle: GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER,
|
|
@@ -1492,6 +1492,9 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1492
1492
|
}), [ isHovered, isActive, isOverLight, overLightConfig.opacity ]), glassVars = useMemo((() => {
|
|
1493
1493
|
const whiteColor = ATOMIX_GLASS.CONSTANTS.PALETTE.WHITE, blackColor = ATOMIX_GLASS.CONSTANTS.PALETTE.BLACK, {borderGradientAngle: borderGradientAngle, borderStop1: borderStop1, borderStop2: borderStop2, borderOpacities: borderOpacities, hoverPositions: hoverPositions, basePosition: basePosition, mx: mx, my: my, absMx: absMx, absMy: absMy} = gradientValues, configBorderOpacity = overLightConfig?.borderOpacity ?? 1;
|
|
1494
1494
|
return {
|
|
1495
|
+
...void 0 !== customZIndex && {
|
|
1496
|
+
"--atomix-glass-base-z-index": customZIndex
|
|
1497
|
+
},
|
|
1495
1498
|
"--atomix-glass-radius": `${effectiveBorderRadius}px`,
|
|
1496
1499
|
"--atomix-glass-transform": transformStyle || "none",
|
|
1497
1500
|
"--atomix-glass-position": positionStyles.position,
|
|
@@ -1512,22 +1515,19 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1512
1515
|
"--atomix-glass-base-opacity": opacityValues.base,
|
|
1513
1516
|
"--atomix-glass-base-gradient": isOverLight ? `linear-gradient(${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.ANGLE}deg, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_START_BASE + mx * ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_START_MULTIPLIER}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_MID_BASE + my * ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_MID_MULTIPLIER}) ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_MID_STOP}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_END_BASE + absMx * ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_END_MULTIPLIER}) 100%)` : `rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.WHITE_OPACITY})`,
|
|
1514
1517
|
"--atomix-glass-overlay-opacity": opacityValues.over,
|
|
1515
|
-
"--atomix-glass-overlay-gradient": isOverLight ? `radial-gradient(circle at ${basePosition.x}% ${basePosition.y}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_BASE + absMx * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_MULTIPLIER}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID}) ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID_STOP}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_BASE + absMy * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_MULTIPLIER}) 100%)` : `rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.WHITE_OPACITY})
|
|
1518
|
+
"--atomix-glass-overlay-gradient": isOverLight ? `radial-gradient(circle at ${basePosition.x}% ${basePosition.y}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_BASE + absMx * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_MULTIPLIER}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID}) ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID_STOP}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_BASE + absMy * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_MULTIPLIER}) 100%)` : `rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.WHITE_OPACITY})`,
|
|
1519
|
+
"--atomix-glass-overlay-highlight-opacity": opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
1520
|
+
"--atomix-glass-overlay-highlight-bg": `radial-gradient(circle at ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_X}% ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_Y}%, rgba(255, 255, 255, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.WHITE_OPACITY}) 0%, transparent ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.STOP}%)`
|
|
1516
1521
|
};
|
|
1517
|
-
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
1518
|
-
className: [ ATOMIX_GLASS.BACKGROUND_LAYER_CLASS, "dark" === layerType ? ATOMIX_GLASS.BACKGROUND_LAYER_DARK_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_BLACK_CLASS, isOverLight ? ATOMIX_GLASS.BACKGROUND_LAYER_OVER_LIGHT_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_HIDDEN_CLASS ].filter(Boolean).join(" ")
|
|
1519
|
-
style: {
|
|
1520
|
-
...positionStyles,
|
|
1521
|
-
height: adjustedSize.height,
|
|
1522
|
-
width: adjustedSize.width,
|
|
1523
|
-
borderRadius: `${effectiveBorderRadius}px`,
|
|
1524
|
-
transform: baseStyle.transform
|
|
1525
|
-
}
|
|
1522
|
+
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity, customZIndex ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
1523
|
+
className: [ ATOMIX_GLASS.BACKGROUND_LAYER_CLASS, "dark" === layerType ? ATOMIX_GLASS.BACKGROUND_LAYER_DARK_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_BLACK_CLASS, isOverLight ? ATOMIX_GLASS.BACKGROUND_LAYER_OVER_LIGHT_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_HIDDEN_CLASS ].filter(Boolean).join(" ")
|
|
1526
1524
|
});
|
|
1527
1525
|
return jsxs("div", {
|
|
1528
1526
|
...rest,
|
|
1529
1527
|
className: componentClassName,
|
|
1530
|
-
style:
|
|
1528
|
+
style: {
|
|
1529
|
+
...glassVars
|
|
1530
|
+
},
|
|
1531
1531
|
role: role || (onClick ? "button" : void 0),
|
|
1532
1532
|
tabIndex: onClick ? tabIndex ?? 0 : tabIndex,
|
|
1533
1533
|
"aria-label": ariaLabel,
|
|
@@ -1539,7 +1539,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1539
1539
|
ref: glassRef,
|
|
1540
1540
|
contentRef: contentRef,
|
|
1541
1541
|
className: className,
|
|
1542
|
-
style:
|
|
1542
|
+
style: rootLayoutStyle,
|
|
1543
1543
|
borderRadius: effectiveBorderRadius,
|
|
1544
1544
|
displacementScale: effectiveWithoutEffects ? 0 : "shader" === mode ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.SHADER_DISPLACEMENT : isOverLight ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.OVER_LIGHT_DISPLACEMENT : displacementScale,
|
|
1545
1545
|
blurAmount: effectiveWithoutEffects ? 0 : blurAmount,
|
|
@@ -1574,7 +1574,6 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1574
1574
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1575
1575
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
1576
1576
|
shaderVariant: shaderVariant,
|
|
1577
|
-
elasticity: elasticity,
|
|
1578
1577
|
withLiquidBlur: withLiquidBlur,
|
|
1579
1578
|
children: children
|
|
1580
1579
|
}), Boolean(onClick) && jsxs(Fragment, {
|
|
@@ -1591,11 +1590,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1591
1590
|
}), jsx("div", {
|
|
1592
1591
|
className: ATOMIX_GLASS.OVERLAY_LAYER_CLASS
|
|
1593
1592
|
}), jsx("div", {
|
|
1594
|
-
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
1595
|
-
style: {
|
|
1596
|
-
opacity: opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
1597
|
-
background: `radial-gradient(circle at ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_X}% ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_Y}%, rgba(255, 255, 255, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.WHITE_OPACITY}) 0%, transparent ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.STOP}%)`
|
|
1598
|
-
}
|
|
1593
|
+
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
1599
1594
|
}) ]
|
|
1600
1595
|
}), withBorder && jsxs(Fragment, {
|
|
1601
1596
|
children: [ jsx("span", {
|