@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/charts.js
CHANGED
|
@@ -510,7 +510,9 @@ const _reduceInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
510
510
|
ENABLE_OVER_LIGHT_LAYERS: !0
|
|
511
511
|
},
|
|
512
512
|
CONSTANTS: {
|
|
513
|
-
ACTIVATION_ZONE:
|
|
513
|
+
ACTIVATION_ZONE: 350,
|
|
514
|
+
LERP_FACTOR: .08,
|
|
515
|
+
SMOOTHSTEP_POWER: 2.5,
|
|
514
516
|
MIN_BLUR: .1,
|
|
515
517
|
MOUSE_INFLUENCE_DIVISOR: 100,
|
|
516
518
|
EDGE_FADE_PIXELS: 2,
|
|
@@ -1600,7 +1602,7 @@ const {CONSTANTS: CONSTANTS$2} = ATOMIX_GLASS, calculateDistance = (pos1, pos2)
|
|
|
1600
1602
|
// Silently handle errors
|
|
1601
1603
|
}
|
|
1602
1604
|
return CONSTANTS$2.DEFAULT_CORNER_RADIUS;
|
|
1603
|
-
}, getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
1605
|
+
}, 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) => {
|
|
1604
1606
|
switch (mode) {
|
|
1605
1607
|
case "standard":
|
|
1606
1608
|
return displacementMap;
|
|
@@ -1773,7 +1775,7 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
1773
1775
|
}, 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 = {
|
|
1774
1776
|
width: 0,
|
|
1775
1777
|
height: 0
|
|
1776
|
-
}, onClick: onClick, mode: mode = "standard", effectiveWithoutEffects: effectiveWithoutEffects = !1, effectiveReducedMotion: effectiveReducedMotion = !1, shaderVariant: shaderVariant = "liquidGlass", withLiquidBlur: withLiquidBlur = !1,
|
|
1778
|
+
}, onClick: onClick, mode: mode = "standard", effectiveWithoutEffects: effectiveWithoutEffects = !1, effectiveReducedMotion: effectiveReducedMotion = !1, shaderVariant: shaderVariant = "liquidGlass", withLiquidBlur: withLiquidBlur = !1, contentRef: contentRef}, ref) => {
|
|
1777
1779
|
// Generate a stable, deterministic ID for SSR compatibility
|
|
1778
1780
|
// Use a module-level counter that's consistent across server and client
|
|
1779
1781
|
const filterId = useMemo((() => "atomix-glass-filter-" + ++idCounter), []), [shaderMapUrl, setShaderMapUrl] = useState(""), shaderGeneratorRef = useRef(null), shaderUtilsRef = useRef(null), shaderDebounceTimeoutRef = useRef(null);
|
|
@@ -1958,21 +1960,12 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
1958
1960
|
onClick: onClick,
|
|
1959
1961
|
children: jsxs("div", {
|
|
1960
1962
|
className: ATOMIX_GLASS.INNER_CLASS,
|
|
1961
|
-
style: {
|
|
1962
|
-
padding: "var(--atomix-glass-container-padding)",
|
|
1963
|
-
boxShadow: "var(--atomix-glass-container-box-shadow)"
|
|
1964
|
-
},
|
|
1965
1963
|
onMouseEnter: onMouseEnter,
|
|
1966
1964
|
onMouseLeave: onMouseLeave,
|
|
1967
1965
|
onMouseDown: onMouseDown,
|
|
1968
1966
|
onMouseUp: onMouseUp,
|
|
1969
1967
|
children: [ jsxs("div", {
|
|
1970
1968
|
className: ATOMIX_GLASS.FILTER_CLASS,
|
|
1971
|
-
style: {
|
|
1972
|
-
zIndex: 1,
|
|
1973
|
-
position: "absolute",
|
|
1974
|
-
inset: 0
|
|
1975
|
-
},
|
|
1976
1969
|
children: [ jsx(GlassFilter, {
|
|
1977
1970
|
blurAmount: blurAmount,
|
|
1978
1971
|
mode: mode,
|
|
@@ -1987,28 +1980,14 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
1987
1980
|
},
|
|
1988
1981
|
className: ATOMIX_GLASS.FILTER_OVERLAY_CLASS,
|
|
1989
1982
|
style: {
|
|
1990
|
-
filter: `url(#${filterId})
|
|
1991
|
-
backdropFilter: "var(--atomix-glass-container-backdrop)",
|
|
1992
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
1983
|
+
filter: `url(#${filterId})`
|
|
1993
1984
|
}
|
|
1994
1985
|
}), jsx("div", {
|
|
1995
|
-
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
1996
|
-
style: {
|
|
1997
|
-
boxShadow: "var(--atomix-glass-container-shadow)",
|
|
1998
|
-
opacity: "var(--atomix-glass-container-shadow-opacity)",
|
|
1999
|
-
background: "var(--atomix-glass-container-bg)",
|
|
2000
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
2001
|
-
}
|
|
1986
|
+
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
2002
1987
|
}) ]
|
|
2003
1988
|
}), jsx("div", {
|
|
2004
1989
|
ref: contentRef,
|
|
2005
1990
|
className: ATOMIX_GLASS.CONTENT_CLASS,
|
|
2006
|
-
style: {
|
|
2007
|
-
position: "relative",
|
|
2008
|
-
textShadow: "var(--atomix-glass-container-text-shadow)",
|
|
2009
|
-
// Ensure content is always above the filter layer (zIndex 1)
|
|
2010
|
-
zIndex: elasticity > 0 ? 100 : 2
|
|
2011
|
-
},
|
|
2012
1991
|
children: children
|
|
2013
1992
|
}) ]
|
|
2014
1993
|
})
|
|
@@ -2112,31 +2091,39 @@ class {
|
|
|
2112
2091
|
saturationBoost: baseOverLightConfig.saturationBoost
|
|
2113
2092
|
};
|
|
2114
2093
|
// Calculate mouse influence
|
|
2115
|
-
|
|
2116
|
-
let elasticTranslation = {
|
|
2094
|
+
let computedDirectionalScale = directionalScale, elasticTranslation = {
|
|
2117
2095
|
x: 0,
|
|
2118
2096
|
y: 0
|
|
2119
2097
|
};
|
|
2120
|
-
|
|
2098
|
+
// Calculate elastic translation and directional scale
|
|
2099
|
+
if (!effectiveWithoutEffects && wrapperElement) {
|
|
2121
2100
|
const rect = wrapperElement.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
2122
|
-
//
|
|
2123
|
-
let fadeInFactor = 0;
|
|
2101
|
+
// Mouse presence and edge distance logic
|
|
2124
2102
|
if (globalMousePosition.x && globalMousePosition.y && validateGlassSize(glassSize)) {
|
|
2125
|
-
const edgeDistanceX = Math.max(0, Math.abs(
|
|
2103
|
+
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({
|
|
2126
2104
|
x: edgeDistanceX,
|
|
2127
2105
|
y: edgeDistanceY
|
|
2128
2106
|
}, {
|
|
2129
2107
|
x: 0,
|
|
2130
2108
|
y: 0
|
|
2131
|
-
})
|
|
2132
|
-
|
|
2109
|
+
}), rawT = edgeDistance > ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE, fadeInFactor = (t => {
|
|
2110
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
2111
|
+
return clamped * clamped * (3 - 2 * clamped);
|
|
2112
|
+
})(rawT);
|
|
2113
|
+
// Directional scale
|
|
2114
|
+
if (elasticTranslation = {
|
|
2115
|
+
x: deltaX * elasticity * .1 * fadeInFactor,
|
|
2116
|
+
y: deltaY * elasticity * .1 * fadeInFactor
|
|
2117
|
+
}, !isOverLight && edgeDistance <= ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE) {
|
|
2118
|
+
const centerDistance = calculateDistance(globalMousePosition, center);
|
|
2119
|
+
if (centerDistance > 0) {
|
|
2120
|
+
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);
|
|
2121
|
+
computedDirectionalScale = `scaleX(${Math.max(.85, softScaleX)}) scaleY(${Math.max(.85, softScaleY)})`;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2133
2124
|
}
|
|
2134
|
-
elasticTranslation = {
|
|
2135
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
2136
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
2137
|
-
};
|
|
2138
2125
|
}
|
|
2139
|
-
const transformStyle = effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" :
|
|
2126
|
+
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}`;
|
|
2140
2127
|
// Update Wrapper Styles (glassVars)
|
|
2141
2128
|
if (wrapperElement) {
|
|
2142
2129
|
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 = {
|
|
@@ -2243,7 +2230,13 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2243
2230
|
}), internalMouseOffsetRef = useRef({
|
|
2244
2231
|
x: 0,
|
|
2245
2232
|
y: 0
|
|
2246
|
-
}),
|
|
2233
|
+
}), targetMouseOffsetRef = useRef({
|
|
2234
|
+
x: 0,
|
|
2235
|
+
y: 0
|
|
2236
|
+
}), targetGlobalMousePositionRef = useRef({
|
|
2237
|
+
x: 0,
|
|
2238
|
+
y: 0
|
|
2239
|
+
}), 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}) {
|
|
2247
2240
|
const [glassSize, setGlassSize] = useState({
|
|
2248
2241
|
width: 270,
|
|
2249
2242
|
height: 69
|
|
@@ -2340,7 +2333,23 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2340
2333
|
const timeoutId = setTimeout(extractRadius, 100);
|
|
2341
2334
|
return () => clearTimeout(timeoutId);
|
|
2342
2335
|
}), [ children, debugBorderRadius, contentRef ]),
|
|
2343
|
-
// Media query
|
|
2336
|
+
// Media query detection for reduced motion and high contrast
|
|
2337
|
+
useEffect((() => {
|
|
2338
|
+
if ("undefined" == typeof window || "function" != typeof window.matchMedia) return;
|
|
2339
|
+
const mediaQueryReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)"), mediaQueryHighContrast = window.matchMedia("(prefers-contrast: high)");
|
|
2340
|
+
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
2341
|
+
const handleReducedMotionChange = e => {
|
|
2342
|
+
setUserPrefersReducedMotion(e.matches);
|
|
2343
|
+
}, handleHighContrastChange = e => {
|
|
2344
|
+
setUserPrefersHighContrast(e.matches);
|
|
2345
|
+
};
|
|
2346
|
+
return mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
2347
|
+
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange), () => {
|
|
2348
|
+
mediaQueryReducedMotion.removeEventListener("change", handleReducedMotionChange),
|
|
2349
|
+
mediaQueryHighContrast.removeEventListener("change", handleHighContrastChange);
|
|
2350
|
+
};
|
|
2351
|
+
}), []),
|
|
2352
|
+
// Background detection for overLight auto-detect
|
|
2344
2353
|
useEffect((() => {
|
|
2345
2354
|
if (("auto" === overLight || "object" == typeof overLight && null !== overLight) && glassRef.current) {
|
|
2346
2355
|
const element = glassRef.current, cachedResult = ((parentElement, overLightConfig) => {
|
|
@@ -2440,102 +2449,36 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2440
2449
|
}), 150);
|
|
2441
2450
|
return () => clearTimeout(timeoutId);
|
|
2442
2451
|
}
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
2446
|
-
const handleReducedMotionChange = e => {
|
|
2447
|
-
setUserPrefersReducedMotion(e.matches);
|
|
2448
|
-
}, handleHighContrastChange = e => {
|
|
2449
|
-
setUserPrefersHighContrast(e.matches);
|
|
2450
|
-
};
|
|
2451
|
-
return mediaQueryReducedMotion.addEventListener ? (mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
2452
|
-
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange)) : mediaQueryReducedMotion.addListener && (mediaQueryReducedMotion.addListener(handleReducedMotionChange),
|
|
2453
|
-
mediaQueryHighContrast.addListener(handleHighContrastChange)), () => {
|
|
2454
|
-
// ignore
|
|
2455
|
-
};
|
|
2456
|
-
} catch (error) {
|
|
2457
|
-
return;
|
|
2458
|
-
}
|
|
2459
|
-
}), [ overLight, glassRef, debugOverLight ]);
|
|
2452
|
+
"boolean" == typeof overLight && setDetectedOverLight(!1);
|
|
2453
|
+
}), [ overLight, glassRef ]);
|
|
2460
2454
|
/**
|
|
2461
2455
|
* Get effective overLight value based on configuration
|
|
2462
2456
|
*/
|
|
2463
|
-
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))), []),
|
|
2464
|
-
const isOverLight = getEffectiveOverLight(), baseConfig = {
|
|
2457
|
+
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((() => {
|
|
2458
|
+
const isOverLight = getEffectiveOverLight(), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1, baseConfig = {
|
|
2465
2459
|
isOverLight: isOverLight,
|
|
2466
2460
|
threshold: .7,
|
|
2467
|
-
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5)) : 0,
|
|
2468
|
-
contrast: 1,
|
|
2469
|
-
|
|
2470
|
-
brightness: 1,
|
|
2471
|
-
// Base brightness
|
|
2461
|
+
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5 * hoverIntensity * activeIntensity)) : 0,
|
|
2462
|
+
contrast: 1.4,
|
|
2463
|
+
brightness: .9,
|
|
2472
2464
|
saturationBoost: 1.3,
|
|
2465
|
+
// Fixed value — dynamic saturation amplifies perceived displacement
|
|
2473
2466
|
shadowIntensity: .9,
|
|
2474
2467
|
borderOpacity: .7
|
|
2475
2468
|
};
|
|
2476
2469
|
if ("object" == typeof overLight && null !== overLight) {
|
|
2477
|
-
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)
|
|
2478
|
-
return {
|
|
2470
|
+
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 = {
|
|
2479
2471
|
...baseConfig,
|
|
2480
2472
|
threshold: validatedThreshold,
|
|
2481
|
-
opacity: validatedOpacity,
|
|
2473
|
+
opacity: validatedOpacity * hoverIntensity * activeIntensity,
|
|
2482
2474
|
contrast: validatedContrast,
|
|
2483
2475
|
brightness: validatedBrightness,
|
|
2484
2476
|
saturationBoost: validatedSaturationBoost
|
|
2485
2477
|
};
|
|
2478
|
+
return "undefined" == typeof process || process.env, finalConfig;
|
|
2486
2479
|
}
|
|
2487
|
-
return baseConfig;
|
|
2488
|
-
}), [ overLight, getEffectiveOverLight, validateConfigValue ]),
|
|
2489
|
-
const mouseInfluence = calculateMouseInfluence(mouseOffset), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1;
|
|
2490
|
-
return {
|
|
2491
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
2492
|
-
threshold: baseOverLightConfig.threshold,
|
|
2493
|
-
opacity: baseOverLightConfig.opacity * hoverIntensity * activeIntensity,
|
|
2494
|
-
contrast: Math.min(1.6, baseOverLightConfig.contrast + .1 * mouseInfluence),
|
|
2495
|
-
brightness: Math.min(1.1, baseOverLightConfig.brightness + .05 * mouseInfluence),
|
|
2496
|
-
saturationBoost: baseOverLightConfig.saturationBoost,
|
|
2497
|
-
shadowIntensity: Math.min(1.2, Math.max(.5, baseOverLightConfig.shadowIntensity + .2 * mouseInfluence)),
|
|
2498
|
-
borderOpacity: Math.min(1, Math.max(.3, baseOverLightConfig.borderOpacity + .1 * mouseInfluence))
|
|
2499
|
-
};
|
|
2500
|
-
}), [ baseOverLightConfig, mouseOffset, isHovered, isActive ]), updateRectRef = useRef(null), calculateDirectionalScale = useCallback((() => {
|
|
2501
|
-
if (baseOverLightConfig.isOverLight) return "scale(1)";
|
|
2502
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return "scale(1)";
|
|
2503
|
-
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({
|
|
2504
|
-
x: edgeDistanceX,
|
|
2505
|
-
y: edgeDistanceY
|
|
2506
|
-
}, {
|
|
2507
|
-
x: 0,
|
|
2508
|
-
y: 0
|
|
2509
|
-
});
|
|
2510
|
-
if (edgeDistance > CONSTANTS.ACTIVATION_ZONE) return "scale(1)";
|
|
2511
|
-
const fadeInFactor = 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE, centerDistance = calculateDistance(globalMousePosition, center);
|
|
2512
|
-
if (0 === centerDistance) return "scale(1)";
|
|
2513
|
-
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;
|
|
2514
|
-
return `scaleX(${Math.max(.8, scaleX)}) scaleY(${Math.max(.8, scaleY)})`;
|
|
2515
|
-
}), [ globalMousePosition, elasticity, glassSize, glassRef, baseOverLightConfig ]), calculateFadeInFactor = useCallback((() => {
|
|
2516
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return 0;
|
|
2517
|
-
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({
|
|
2518
|
-
x: edgeDistanceX,
|
|
2519
|
-
y: edgeDistanceY
|
|
2520
|
-
}, {
|
|
2521
|
-
x: 0,
|
|
2522
|
-
y: 0
|
|
2523
|
-
});
|
|
2524
|
-
return edgeDistance > CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE;
|
|
2525
|
-
}), [ globalMousePosition, glassSize, glassRef ]), calculateElasticTranslation = useCallback((() => {
|
|
2526
|
-
if (!glassRef.current) return {
|
|
2527
|
-
x: 0,
|
|
2528
|
-
y: 0
|
|
2529
|
-
};
|
|
2530
|
-
const fadeInFactor = calculateFadeInFactor(), rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
2531
|
-
return {
|
|
2532
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
2533
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
2534
|
-
};
|
|
2535
|
-
}), [ globalMousePosition, elasticity, calculateFadeInFactor, glassRef ]), elasticTranslation = useMemo((() => effectiveWithoutEffects ? {
|
|
2536
|
-
x: 0,
|
|
2537
|
-
y: 0
|
|
2538
|
-
} : 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 => {
|
|
2480
|
+
return "undefined" == typeof process || process.env, baseConfig;
|
|
2481
|
+
}), [ 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 => {
|
|
2539
2482
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
2540
2483
|
if (effectiveWithoutEffects) return;
|
|
2541
2484
|
const container = mouseContainer?.current || glassRef.current;
|
|
@@ -2544,35 +2487,61 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2544
2487
|
let rect = cachedRectRef.current;
|
|
2545
2488
|
if (rect && 0 !== rect.width && 0 !== rect.height || (rect = container.getBoundingClientRect(),
|
|
2546
2489
|
cachedRectRef.current = rect), 0 === rect.width || 0 === rect.height) return;
|
|
2547
|
-
const center = calculateElementCenter(rect)
|
|
2490
|
+
const center = calculateElementCenter(rect);
|
|
2491
|
+
// Write raw target — the lerp loop will smoothly pursue it
|
|
2492
|
+
targetMouseOffsetRef.current = {
|
|
2548
2493
|
x: (globalPos.x - center.x) / rect.width * 100,
|
|
2549
2494
|
y: (globalPos.y - center.y) / rect.height * 100
|
|
2495
|
+
}, targetGlobalMousePositionRef.current = globalPos;
|
|
2496
|
+
}), [ mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]), startLerpLoop = useCallback((() => {
|
|
2497
|
+
if (lerpActiveRef.current) return;
|
|
2498
|
+
lerpActiveRef.current = !0;
|
|
2499
|
+
const LERP_T = CONSTANTS.LERP_FACTOR, tick = () => {
|
|
2500
|
+
if (!lerpActiveRef.current) return;
|
|
2501
|
+
const cur = internalMouseOffsetRef.current, tgt = targetMouseOffsetRef.current, dx = tgt.x - cur.x, dy = tgt.y - cur.y;
|
|
2502
|
+
// If we're close enough, snap and park
|
|
2503
|
+
if (Math.abs(dx) < .05 && Math.abs(dy) < .05) internalMouseOffsetRef.current = {
|
|
2504
|
+
...tgt
|
|
2505
|
+
}, internalGlobalMousePositionRef.current = {
|
|
2506
|
+
...targetGlobalMousePositionRef.current
|
|
2507
|
+
}; else {
|
|
2508
|
+
internalMouseOffsetRef.current = {
|
|
2509
|
+
x: lerp(cur.x, tgt.x, LERP_T),
|
|
2510
|
+
y: lerp(cur.y, tgt.y, LERP_T)
|
|
2511
|
+
};
|
|
2512
|
+
const curG = internalGlobalMousePositionRef.current, tgtG = targetGlobalMousePositionRef.current;
|
|
2513
|
+
internalGlobalMousePositionRef.current = {
|
|
2514
|
+
x: lerp(curG.x, tgtG.x, LERP_T),
|
|
2515
|
+
y: lerp(curG.y, tgtG.y, LERP_T)
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
// Imperative style update with the smoothed values
|
|
2519
|
+
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
2520
|
+
mouseOffset: internalMouseOffsetRef.current,
|
|
2521
|
+
globalMousePosition: internalGlobalMousePositionRef.current,
|
|
2522
|
+
glassSize: glassSize,
|
|
2523
|
+
isHovered: isHovered,
|
|
2524
|
+
isActive: isActive,
|
|
2525
|
+
isOverLight: overLightConfig.isOverLight,
|
|
2526
|
+
baseOverLightConfig: overLightConfig,
|
|
2527
|
+
effectiveBorderRadius: effectiveBorderRadius,
|
|
2528
|
+
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
2529
|
+
effectiveReducedMotion: effectiveReducedMotion,
|
|
2530
|
+
elasticity: elasticity,
|
|
2531
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
2532
|
+
onClick: onClick,
|
|
2533
|
+
withLiquidBlur: withLiquidBlur,
|
|
2534
|
+
blurAmount: blurAmount,
|
|
2535
|
+
saturation: saturation,
|
|
2536
|
+
padding: padding
|
|
2537
|
+
}), lerpRafRef.current = requestAnimationFrame(tick);
|
|
2550
2538
|
};
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
globalMousePosition: globalPos,
|
|
2558
|
-
glassSize: glassSize,
|
|
2559
|
-
isHovered: isHovered,
|
|
2560
|
-
isActive: isActive,
|
|
2561
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
2562
|
-
baseOverLightConfig: baseOverLightConfig,
|
|
2563
|
-
effectiveBorderRadius: effectiveBorderRadius,
|
|
2564
|
-
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
2565
|
-
effectiveReducedMotion: effectiveReducedMotion,
|
|
2566
|
-
elasticity: elasticity,
|
|
2567
|
-
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
2568
|
-
// Simplified directional scale for fast path
|
|
2569
|
-
onClick: onClick,
|
|
2570
|
-
withLiquidBlur: withLiquidBlur,
|
|
2571
|
-
blurAmount: blurAmount,
|
|
2572
|
-
saturation: saturation,
|
|
2573
|
-
padding: padding
|
|
2574
|
-
});
|
|
2575
|
-
}), [ mouseContainer, glassRef, wrapperRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects, glassSize, isHovered, isActive, baseOverLightConfig, effectiveBorderRadius, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]);
|
|
2539
|
+
// 0.08 – lower = more viscous
|
|
2540
|
+
lerpRafRef.current = requestAnimationFrame(tick);
|
|
2541
|
+
}), [ glassRef, wrapperRef, glassSize, isHovered, isActive, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]), stopLerpLoop = useCallback((() => {
|
|
2542
|
+
lerpActiveRef.current = !1, null !== lerpRafRef.current && (cancelAnimationFrame(lerpRafRef.current),
|
|
2543
|
+
lerpRafRef.current = null);
|
|
2544
|
+
}), []);
|
|
2576
2545
|
/**
|
|
2577
2546
|
* Validate and clamp a numeric config value
|
|
2578
2547
|
*/
|
|
@@ -2580,7 +2549,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2580
2549
|
useEffect((() => {
|
|
2581
2550
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
2582
2551
|
if (effectiveWithoutEffects) return;
|
|
2583
|
-
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition)
|
|
2552
|
+
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition);
|
|
2553
|
+
// Start the lerp loop — it will smoothly chase the target
|
|
2554
|
+
startLerpLoop();
|
|
2555
|
+
const container = mouseContainer?.current || glassRef.current;
|
|
2584
2556
|
let resizeObserver = null;
|
|
2585
2557
|
return container && "undefined" != typeof ResizeObserver && (resizeObserver = new ResizeObserver((() => {
|
|
2586
2558
|
null !== updateRectRef.current && cancelAnimationFrame(updateRectRef.current), updateRectRef.current = requestAnimationFrame((() => {
|
|
@@ -2588,10 +2560,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2588
2560
|
container && (cachedRectRef.current = container.getBoundingClientRect()), updateRectRef.current = null;
|
|
2589
2561
|
}));
|
|
2590
2562
|
})), resizeObserver.observe(container)), () => {
|
|
2591
|
-
unsubscribe(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
2563
|
+
unsubscribe(), stopLerpLoop(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
2592
2564
|
updateRectRef.current = null), resizeObserver && resizeObserver.disconnect();
|
|
2593
2565
|
};
|
|
2594
|
-
}), [ handleGlobalMousePosition, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
2566
|
+
}), [ handleGlobalMousePosition, startLerpLoop, stopLerpLoop, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
2595
2567
|
// Also call updateStyles on other state changes (hover, active, etc)
|
|
2596
2568
|
useEffect((() => {
|
|
2597
2569
|
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
@@ -2600,22 +2572,22 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2600
2572
|
glassSize: glassSize,
|
|
2601
2573
|
isHovered: isHovered,
|
|
2602
2574
|
isActive: isActive,
|
|
2603
|
-
isOverLight:
|
|
2604
|
-
baseOverLightConfig:
|
|
2575
|
+
isOverLight: overLightConfig.isOverLight,
|
|
2576
|
+
baseOverLightConfig: overLightConfig,
|
|
2605
2577
|
effectiveBorderRadius: effectiveBorderRadius,
|
|
2606
2578
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
2607
2579
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
2608
2580
|
elasticity: elasticity,
|
|
2609
|
-
directionalScale:
|
|
2581
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
2610
2582
|
onClick: onClick,
|
|
2611
2583
|
withLiquidBlur: withLiquidBlur,
|
|
2612
2584
|
blurAmount: blurAmount,
|
|
2613
2585
|
saturation: saturation,
|
|
2614
2586
|
padding: padding
|
|
2615
2587
|
});
|
|
2616
|
-
}), [ isHovered, isActive, glassSize,
|
|
2588
|
+
}), [ isHovered, isActive, glassSize, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, wrapperRef, glassRef, externalMouseOffset, externalGlobalMousePosition, withLiquidBlur, blurAmount, saturation, padding, onClick ]);
|
|
2617
2589
|
// Event handlers
|
|
2618
|
-
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []),
|
|
2590
|
+
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []), handleKeyDown = useCallback((e => {
|
|
2619
2591
|
!onClick || "Enter" !== e.key && " " !== e.key || (e.preventDefault(), onClick());
|
|
2620
2592
|
}), [ onClick ]);
|
|
2621
2593
|
return {
|
|
@@ -2633,14 +2605,11 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2633
2605
|
mouseOffset: mouseOffset,
|
|
2634
2606
|
// This is now static (refs or props) unless prop changes
|
|
2635
2607
|
overLightConfig: overLightConfig,
|
|
2636
|
-
elasticTranslation: elasticTranslation,
|
|
2637
|
-
directionalScale: directionalScale,
|
|
2638
2608
|
transformStyle: transformStyle,
|
|
2639
2609
|
handleMouseEnter: handleMouseEnter,
|
|
2640
2610
|
handleMouseLeave: handleMouseLeave,
|
|
2641
2611
|
handleMouseDown: handleMouseDown,
|
|
2642
2612
|
handleMouseUp: handleMouseUp,
|
|
2643
|
-
handleMouseMove: handleMouseMove,
|
|
2644
2613
|
handleKeyDown: handleKeyDown
|
|
2645
2614
|
};
|
|
2646
2615
|
}
|
|
@@ -2738,25 +2707,56 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2738
2707
|
withLiquidBlur: withLiquidBlur,
|
|
2739
2708
|
padding: padding,
|
|
2740
2709
|
style: style
|
|
2741
|
-
}), isOverLight = useMemo((() => overLightConfig
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2710
|
+
}), isOverLight = useMemo((() => overLightConfig.isOverLight), [ overLightConfig.isOverLight ]), shouldRenderOverLightLayers = withOverLightLayers && isOverLight, {zIndex: customZIndex, ...restStyle} = style, isFixedOrSticky = "fixed" === restStyle.position || "sticky" === restStyle.position, rootLayoutStyle = useMemo((() => {
|
|
2711
|
+
if (!isFixedOrSticky) return {};
|
|
2712
|
+
const {position: p, top: t, left: l, right: r, bottom: b} = restStyle;
|
|
2713
|
+
return {
|
|
2714
|
+
...p && {
|
|
2715
|
+
position: p
|
|
2716
|
+
},
|
|
2717
|
+
...void 0 !== t && {
|
|
2718
|
+
top: t
|
|
2719
|
+
},
|
|
2720
|
+
...void 0 !== l && {
|
|
2721
|
+
left: l
|
|
2722
|
+
},
|
|
2723
|
+
...void 0 !== r && {
|
|
2724
|
+
right: r
|
|
2725
|
+
},
|
|
2726
|
+
...void 0 !== b && {
|
|
2727
|
+
bottom: b
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
}), [ isFixedOrSticky, restStyle ]), baseStyle = useMemo((() => {
|
|
2731
|
+
if (isFixedOrSticky) {
|
|
2732
|
+
const {position: _p, top: _t, left: _l, right: _r, bottom: _b, ...visualStyle} = restStyle;
|
|
2733
|
+
return {
|
|
2734
|
+
...visualStyle,
|
|
2735
|
+
...!effectiveWithoutEffects && {
|
|
2736
|
+
transform: transformStyle
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2745
2739
|
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2740
|
+
return {
|
|
2741
|
+
...restStyle,
|
|
2742
|
+
...!effectiveWithoutEffects && {
|
|
2743
|
+
transform: transformStyle
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
}), [ 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((() => ({
|
|
2747
|
+
position: isFixedOrSticky ? "absolute" : restStyle.position || "absolute",
|
|
2748
|
+
top: isFixedOrSticky ? 0 : restStyle.top || 0,
|
|
2749
|
+
left: isFixedOrSticky ? 0 : restStyle.left || 0
|
|
2750
|
+
})), [ isFixedOrSticky, restStyle.position, restStyle.top, restStyle.left ]), adjustedSize = useMemo((() => {
|
|
2751
2751
|
const resolveSize = (propValue, styleValue, measuredSize) => {
|
|
2752
2752
|
const explicitSize = propValue ?? styleValue;
|
|
2753
2753
|
return void 0 !== explicitSize ? "number" == typeof explicitSize ? `${explicitSize}px` : explicitSize : "fixed" === positionStyles.position ? `${Math.max(measuredSize, 0)}px` : "100%";
|
|
2754
2754
|
};
|
|
2755
2755
|
return {
|
|
2756
|
-
width: resolveSize(width,
|
|
2757
|
-
height: resolveSize(height,
|
|
2756
|
+
width: resolveSize(width, restStyle.width, glassSize.width),
|
|
2757
|
+
height: resolveSize(height, restStyle.height, glassSize.height)
|
|
2758
2758
|
};
|
|
2759
|
-
}), [ width, height,
|
|
2759
|
+
}), [ width, height, restStyle.width, restStyle.height, positionStyles.position, glassSize.width, glassSize.height ]), gradientValues = useMemo((() => {
|
|
2760
2760
|
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT;
|
|
2761
2761
|
return {
|
|
2762
2762
|
borderGradientAngle: GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER,
|
|
@@ -2798,6 +2798,9 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2798
2798
|
}), [ isHovered, isActive, isOverLight, overLightConfig.opacity ]), glassVars = useMemo((() => {
|
|
2799
2799
|
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;
|
|
2800
2800
|
return {
|
|
2801
|
+
...void 0 !== customZIndex && {
|
|
2802
|
+
"--atomix-glass-base-z-index": customZIndex
|
|
2803
|
+
},
|
|
2801
2804
|
"--atomix-glass-radius": `${effectiveBorderRadius}px`,
|
|
2802
2805
|
"--atomix-glass-transform": transformStyle || "none",
|
|
2803
2806
|
"--atomix-glass-position": positionStyles.position,
|
|
@@ -2818,22 +2821,19 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2818
2821
|
"--atomix-glass-base-opacity": opacityValues.base,
|
|
2819
2822
|
"--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})`,
|
|
2820
2823
|
"--atomix-glass-overlay-opacity": opacityValues.over,
|
|
2821
|
-
"--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})
|
|
2824
|
+
"--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})`,
|
|
2825
|
+
"--atomix-glass-overlay-highlight-opacity": opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
2826
|
+
"--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}%)`
|
|
2822
2827
|
};
|
|
2823
|
-
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
2824
|
-
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(" ")
|
|
2825
|
-
style: {
|
|
2826
|
-
...positionStyles,
|
|
2827
|
-
height: adjustedSize.height,
|
|
2828
|
-
width: adjustedSize.width,
|
|
2829
|
-
borderRadius: `${effectiveBorderRadius}px`,
|
|
2830
|
-
transform: baseStyle.transform
|
|
2831
|
-
}
|
|
2828
|
+
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity, customZIndex ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
2829
|
+
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(" ")
|
|
2832
2830
|
});
|
|
2833
2831
|
return jsxs("div", {
|
|
2834
2832
|
...rest,
|
|
2835
2833
|
className: componentClassName,
|
|
2836
|
-
style:
|
|
2834
|
+
style: {
|
|
2835
|
+
...glassVars
|
|
2836
|
+
},
|
|
2837
2837
|
role: role || (onClick ? "button" : void 0),
|
|
2838
2838
|
tabIndex: onClick ? tabIndex ?? 0 : tabIndex,
|
|
2839
2839
|
"aria-label": ariaLabel,
|
|
@@ -2845,7 +2845,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2845
2845
|
ref: glassRef,
|
|
2846
2846
|
contentRef: contentRef,
|
|
2847
2847
|
className: className,
|
|
2848
|
-
style:
|
|
2848
|
+
style: rootLayoutStyle,
|
|
2849
2849
|
borderRadius: effectiveBorderRadius,
|
|
2850
2850
|
displacementScale: effectiveWithoutEffects ? 0 : "shader" === mode ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.SHADER_DISPLACEMENT : isOverLight ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.OVER_LIGHT_DISPLACEMENT : displacementScale,
|
|
2851
2851
|
blurAmount: effectiveWithoutEffects ? 0 : blurAmount,
|
|
@@ -2880,7 +2880,6 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2880
2880
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
2881
2881
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
2882
2882
|
shaderVariant: shaderVariant,
|
|
2883
|
-
elasticity: elasticity,
|
|
2884
2883
|
withLiquidBlur: withLiquidBlur,
|
|
2885
2884
|
children: children
|
|
2886
2885
|
}), Boolean(onClick) && jsxs(Fragment, {
|
|
@@ -2897,11 +2896,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2897
2896
|
}), jsx("div", {
|
|
2898
2897
|
className: ATOMIX_GLASS.OVERLAY_LAYER_CLASS
|
|
2899
2898
|
}), jsx("div", {
|
|
2900
|
-
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
2901
|
-
style: {
|
|
2902
|
-
opacity: opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
2903
|
-
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}%)`
|
|
2904
|
-
}
|
|
2899
|
+
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
2905
2900
|
}) ]
|
|
2906
2901
|
}), withBorder && jsxs(Fragment, {
|
|
2907
2902
|
children: [ jsx("span", {
|