@shohojdhara/atomix 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atomix.css +70 -33
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +2 -2
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.d.ts +93 -109
- package/dist/charts.js +273 -371
- package/dist/charts.js.map +1 -1
- package/dist/core.js +183 -184
- package/dist/core.js.map +1 -1
- package/dist/forms.js +183 -184
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +183 -184
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +7 -51
- package/dist/index.esm.js +281 -470
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +287 -476
- 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 -38
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +6 -35
- 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/Chart/BubbleChart.tsx +6 -2
- package/src/components/Chart/Chart.stories.tsx +108 -96
- package/src/components/Chart/ChartToolbar.tsx +6 -4
- package/src/components/Chart/ChartTooltip.tsx +5 -4
- package/src/components/Chart/GaugeChart.tsx +20 -12
- package/src/components/Chart/HeatmapChart.tsx +53 -23
- package/src/components/Chart/TreemapChart.tsx +44 -15
- package/src/components/Chart/index.ts +0 -2
- package/src/components/Chart/types.ts +4 -4
- package/src/components/Navigation/Navbar/Navbar.tsx +13 -5
- package/src/components/index.ts +0 -1
- 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/constants/components.ts +3 -1
- package/src/styles/01-settings/_settings.chart.scss +13 -13
- package/src/styles/06-components/_components.atomix-glass.scss +45 -20
- package/src/styles/06-components/_components.chart.scss +23 -5
- package/src/components/Chart/AnimatedChart.tsx +0 -230
- 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/core.js
CHANGED
|
@@ -567,7 +567,9 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
567
567
|
ENABLE_OVER_LIGHT_LAYERS: !0
|
|
568
568
|
},
|
|
569
569
|
CONSTANTS: {
|
|
570
|
-
ACTIVATION_ZONE:
|
|
570
|
+
ACTIVATION_ZONE: 350,
|
|
571
|
+
LERP_FACTOR: .08,
|
|
572
|
+
SMOOTHSTEP_POWER: 2.5,
|
|
571
573
|
MIN_BLUR: .1,
|
|
572
574
|
MOUSE_INFLUENCE_DIVISOR: 100,
|
|
573
575
|
EDGE_FADE_PIXELS: 2,
|
|
@@ -803,7 +805,7 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
803
805
|
// Silently handle errors
|
|
804
806
|
}
|
|
805
807
|
return CONSTANTS$2.DEFAULT_CORNER_RADIUS;
|
|
806
|
-
}, getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
808
|
+
}, 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) => {
|
|
807
809
|
switch (mode) {
|
|
808
810
|
case "standard":
|
|
809
811
|
return displacementMap;
|
|
@@ -1164,20 +1166,12 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
1164
1166
|
onClick: onClick,
|
|
1165
1167
|
children: jsxs("div", {
|
|
1166
1168
|
className: ATOMIX_GLASS.INNER_CLASS,
|
|
1167
|
-
style: {
|
|
1168
|
-
padding: "var(--atomix-glass-container-padding)",
|
|
1169
|
-
boxShadow: "var(--atomix-glass-container-box-shadow)"
|
|
1170
|
-
},
|
|
1171
1169
|
onMouseEnter: onMouseEnter,
|
|
1172
1170
|
onMouseLeave: onMouseLeave,
|
|
1173
1171
|
onMouseDown: onMouseDown,
|
|
1174
1172
|
onMouseUp: onMouseUp,
|
|
1175
1173
|
children: [ jsxs("div", {
|
|
1176
1174
|
className: ATOMIX_GLASS.FILTER_CLASS,
|
|
1177
|
-
style: {
|
|
1178
|
-
position: "absolute",
|
|
1179
|
-
inset: 0
|
|
1180
|
-
},
|
|
1181
1175
|
children: [ jsx(GlassFilter, {
|
|
1182
1176
|
blurAmount: blurAmount,
|
|
1183
1177
|
mode: mode,
|
|
@@ -1192,26 +1186,14 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
1192
1186
|
},
|
|
1193
1187
|
className: ATOMIX_GLASS.FILTER_OVERLAY_CLASS,
|
|
1194
1188
|
style: {
|
|
1195
|
-
filter: `url(#${filterId})
|
|
1196
|
-
backdropFilter: "var(--atomix-glass-container-backdrop)",
|
|
1197
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
1189
|
+
filter: `url(#${filterId})`
|
|
1198
1190
|
}
|
|
1199
1191
|
}), jsx("div", {
|
|
1200
|
-
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
1201
|
-
style: {
|
|
1202
|
-
boxShadow: "var(--atomix-glass-container-shadow)",
|
|
1203
|
-
opacity: "var(--atomix-glass-container-shadow-opacity)",
|
|
1204
|
-
background: "var(--atomix-glass-container-bg)",
|
|
1205
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
1206
|
-
}
|
|
1192
|
+
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
1207
1193
|
}) ]
|
|
1208
1194
|
}), jsx("div", {
|
|
1209
1195
|
ref: contentRef,
|
|
1210
1196
|
className: ATOMIX_GLASS.CONTENT_CLASS,
|
|
1211
|
-
style: {
|
|
1212
|
-
position: "relative",
|
|
1213
|
-
textShadow: "var(--atomix-glass-container-text-shadow)"
|
|
1214
|
-
},
|
|
1215
1197
|
children: children
|
|
1216
1198
|
}) ]
|
|
1217
1199
|
})
|
|
@@ -1315,31 +1297,39 @@ class {
|
|
|
1315
1297
|
saturationBoost: baseOverLightConfig.saturationBoost
|
|
1316
1298
|
};
|
|
1317
1299
|
// Calculate mouse influence
|
|
1318
|
-
|
|
1319
|
-
let elasticTranslation = {
|
|
1300
|
+
let computedDirectionalScale = directionalScale, elasticTranslation = {
|
|
1320
1301
|
x: 0,
|
|
1321
1302
|
y: 0
|
|
1322
1303
|
};
|
|
1323
|
-
|
|
1304
|
+
// Calculate elastic translation and directional scale
|
|
1305
|
+
if (!effectiveWithoutEffects && wrapperElement) {
|
|
1324
1306
|
const rect = wrapperElement.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
1325
|
-
//
|
|
1326
|
-
let fadeInFactor = 0;
|
|
1307
|
+
// Mouse presence and edge distance logic
|
|
1327
1308
|
if (globalMousePosition.x && globalMousePosition.y && validateGlassSize(glassSize)) {
|
|
1328
|
-
const edgeDistanceX = Math.max(0, Math.abs(
|
|
1309
|
+
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({
|
|
1329
1310
|
x: edgeDistanceX,
|
|
1330
1311
|
y: edgeDistanceY
|
|
1331
1312
|
}, {
|
|
1332
1313
|
x: 0,
|
|
1333
1314
|
y: 0
|
|
1334
|
-
})
|
|
1335
|
-
|
|
1315
|
+
}), rawT = edgeDistance > ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE, fadeInFactor = (t => {
|
|
1316
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
1317
|
+
return clamped * clamped * (3 - 2 * clamped);
|
|
1318
|
+
})(rawT);
|
|
1319
|
+
// Directional scale
|
|
1320
|
+
if (elasticTranslation = {
|
|
1321
|
+
x: deltaX * elasticity * .1 * fadeInFactor,
|
|
1322
|
+
y: deltaY * elasticity * .1 * fadeInFactor
|
|
1323
|
+
}, !isOverLight && edgeDistance <= ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE) {
|
|
1324
|
+
const centerDistance = calculateDistance(globalMousePosition, center);
|
|
1325
|
+
if (centerDistance > 0) {
|
|
1326
|
+
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);
|
|
1327
|
+
computedDirectionalScale = `scaleX(${Math.max(.85, softScaleX)}) scaleY(${Math.max(.85, softScaleY)})`;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1336
1330
|
}
|
|
1337
|
-
elasticTranslation = {
|
|
1338
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
1339
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
1340
|
-
};
|
|
1341
1331
|
}
|
|
1342
|
-
const transformStyle = effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" :
|
|
1332
|
+
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}`;
|
|
1343
1333
|
// Update Wrapper Styles (glassVars)
|
|
1344
1334
|
if (wrapperElement) {
|
|
1345
1335
|
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 = {
|
|
@@ -1446,7 +1436,13 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1446
1436
|
}), internalMouseOffsetRef = useRef({
|
|
1447
1437
|
x: 0,
|
|
1448
1438
|
y: 0
|
|
1449
|
-
}),
|
|
1439
|
+
}), targetMouseOffsetRef = useRef({
|
|
1440
|
+
x: 0,
|
|
1441
|
+
y: 0
|
|
1442
|
+
}), targetGlobalMousePositionRef = useRef({
|
|
1443
|
+
x: 0,
|
|
1444
|
+
y: 0
|
|
1445
|
+
}), 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}) {
|
|
1450
1446
|
const [glassSize, setGlassSize] = useState({
|
|
1451
1447
|
width: 270,
|
|
1452
1448
|
height: 69
|
|
@@ -1543,7 +1539,23 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1543
1539
|
const timeoutId = setTimeout(extractRadius, 100);
|
|
1544
1540
|
return () => clearTimeout(timeoutId);
|
|
1545
1541
|
}), [ children, debugBorderRadius, contentRef ]),
|
|
1546
|
-
// Media query
|
|
1542
|
+
// Media query detection for reduced motion and high contrast
|
|
1543
|
+
useEffect((() => {
|
|
1544
|
+
if ("undefined" == typeof window || "function" != typeof window.matchMedia) return;
|
|
1545
|
+
const mediaQueryReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)"), mediaQueryHighContrast = window.matchMedia("(prefers-contrast: high)");
|
|
1546
|
+
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
1547
|
+
const handleReducedMotionChange = e => {
|
|
1548
|
+
setUserPrefersReducedMotion(e.matches);
|
|
1549
|
+
}, handleHighContrastChange = e => {
|
|
1550
|
+
setUserPrefersHighContrast(e.matches);
|
|
1551
|
+
};
|
|
1552
|
+
return mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
1553
|
+
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange), () => {
|
|
1554
|
+
mediaQueryReducedMotion.removeEventListener("change", handleReducedMotionChange),
|
|
1555
|
+
mediaQueryHighContrast.removeEventListener("change", handleHighContrastChange);
|
|
1556
|
+
};
|
|
1557
|
+
}), []),
|
|
1558
|
+
// Background detection for overLight auto-detect
|
|
1547
1559
|
useEffect((() => {
|
|
1548
1560
|
if (("auto" === overLight || "object" == typeof overLight && null !== overLight) && glassRef.current) {
|
|
1549
1561
|
const element = glassRef.current, cachedResult = ((parentElement, overLightConfig) => {
|
|
@@ -1643,102 +1655,36 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1643
1655
|
}), 150);
|
|
1644
1656
|
return () => clearTimeout(timeoutId);
|
|
1645
1657
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
1649
|
-
const handleReducedMotionChange = e => {
|
|
1650
|
-
setUserPrefersReducedMotion(e.matches);
|
|
1651
|
-
}, handleHighContrastChange = e => {
|
|
1652
|
-
setUserPrefersHighContrast(e.matches);
|
|
1653
|
-
};
|
|
1654
|
-
return mediaQueryReducedMotion.addEventListener ? (mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
1655
|
-
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange)) : mediaQueryReducedMotion.addListener && (mediaQueryReducedMotion.addListener(handleReducedMotionChange),
|
|
1656
|
-
mediaQueryHighContrast.addListener(handleHighContrastChange)), () => {
|
|
1657
|
-
// ignore
|
|
1658
|
-
};
|
|
1659
|
-
} catch (error) {
|
|
1660
|
-
return;
|
|
1661
|
-
}
|
|
1662
|
-
}), [ overLight, glassRef, debugOverLight ]);
|
|
1658
|
+
"boolean" == typeof overLight && setDetectedOverLight(!1);
|
|
1659
|
+
}), [ overLight, glassRef ]);
|
|
1663
1660
|
/**
|
|
1664
1661
|
* Get effective overLight value based on configuration
|
|
1665
1662
|
*/
|
|
1666
|
-
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))), []),
|
|
1667
|
-
const isOverLight = getEffectiveOverLight(), baseConfig = {
|
|
1663
|
+
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((() => {
|
|
1664
|
+
const isOverLight = getEffectiveOverLight(), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1, baseConfig = {
|
|
1668
1665
|
isOverLight: isOverLight,
|
|
1669
1666
|
threshold: .7,
|
|
1670
|
-
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5)) : 0,
|
|
1671
|
-
contrast: 1,
|
|
1672
|
-
|
|
1673
|
-
brightness: 1,
|
|
1674
|
-
// Base brightness
|
|
1667
|
+
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5 * hoverIntensity * activeIntensity)) : 0,
|
|
1668
|
+
contrast: 1.4,
|
|
1669
|
+
brightness: .9,
|
|
1675
1670
|
saturationBoost: 1.3,
|
|
1671
|
+
// Fixed value — dynamic saturation amplifies perceived displacement
|
|
1676
1672
|
shadowIntensity: .9,
|
|
1677
1673
|
borderOpacity: .7
|
|
1678
1674
|
};
|
|
1679
1675
|
if ("object" == typeof overLight && null !== overLight) {
|
|
1680
|
-
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)
|
|
1681
|
-
return {
|
|
1676
|
+
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 = {
|
|
1682
1677
|
...baseConfig,
|
|
1683
1678
|
threshold: validatedThreshold,
|
|
1684
|
-
opacity: validatedOpacity,
|
|
1679
|
+
opacity: validatedOpacity * hoverIntensity * activeIntensity,
|
|
1685
1680
|
contrast: validatedContrast,
|
|
1686
1681
|
brightness: validatedBrightness,
|
|
1687
1682
|
saturationBoost: validatedSaturationBoost
|
|
1688
1683
|
};
|
|
1684
|
+
return "undefined" == typeof process || process.env, finalConfig;
|
|
1689
1685
|
}
|
|
1690
|
-
return baseConfig;
|
|
1691
|
-
}), [ overLight, getEffectiveOverLight, validateConfigValue ]),
|
|
1692
|
-
const mouseInfluence = calculateMouseInfluence(mouseOffset), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1;
|
|
1693
|
-
return {
|
|
1694
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
1695
|
-
threshold: baseOverLightConfig.threshold,
|
|
1696
|
-
opacity: baseOverLightConfig.opacity * hoverIntensity * activeIntensity,
|
|
1697
|
-
contrast: Math.min(1.6, baseOverLightConfig.contrast + .1 * mouseInfluence),
|
|
1698
|
-
brightness: Math.min(1.1, baseOverLightConfig.brightness + .05 * mouseInfluence),
|
|
1699
|
-
saturationBoost: baseOverLightConfig.saturationBoost,
|
|
1700
|
-
shadowIntensity: Math.min(1.2, Math.max(.5, baseOverLightConfig.shadowIntensity + .2 * mouseInfluence)),
|
|
1701
|
-
borderOpacity: Math.min(1, Math.max(.3, baseOverLightConfig.borderOpacity + .1 * mouseInfluence))
|
|
1702
|
-
};
|
|
1703
|
-
}), [ baseOverLightConfig, mouseOffset, isHovered, isActive ]), updateRectRef = useRef(null), calculateDirectionalScale = useCallback((() => {
|
|
1704
|
-
if (baseOverLightConfig.isOverLight) return "scale(1)";
|
|
1705
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return "scale(1)";
|
|
1706
|
-
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({
|
|
1707
|
-
x: edgeDistanceX,
|
|
1708
|
-
y: edgeDistanceY
|
|
1709
|
-
}, {
|
|
1710
|
-
x: 0,
|
|
1711
|
-
y: 0
|
|
1712
|
-
});
|
|
1713
|
-
if (edgeDistance > CONSTANTS.ACTIVATION_ZONE) return "scale(1)";
|
|
1714
|
-
const fadeInFactor = 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE, centerDistance = calculateDistance(globalMousePosition, center);
|
|
1715
|
-
if (0 === centerDistance) return "scale(1)";
|
|
1716
|
-
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;
|
|
1717
|
-
return `scaleX(${Math.max(.8, scaleX)}) scaleY(${Math.max(.8, scaleY)})`;
|
|
1718
|
-
}), [ globalMousePosition, elasticity, glassSize, glassRef, baseOverLightConfig ]), calculateFadeInFactor = useCallback((() => {
|
|
1719
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return 0;
|
|
1720
|
-
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({
|
|
1721
|
-
x: edgeDistanceX,
|
|
1722
|
-
y: edgeDistanceY
|
|
1723
|
-
}, {
|
|
1724
|
-
x: 0,
|
|
1725
|
-
y: 0
|
|
1726
|
-
});
|
|
1727
|
-
return edgeDistance > CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE;
|
|
1728
|
-
}), [ globalMousePosition, glassSize, glassRef ]), calculateElasticTranslation = useCallback((() => {
|
|
1729
|
-
if (!glassRef.current) return {
|
|
1730
|
-
x: 0,
|
|
1731
|
-
y: 0
|
|
1732
|
-
};
|
|
1733
|
-
const fadeInFactor = calculateFadeInFactor(), rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
1734
|
-
return {
|
|
1735
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
1736
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
1737
|
-
};
|
|
1738
|
-
}), [ globalMousePosition, elasticity, calculateFadeInFactor, glassRef ]), elasticTranslation = useMemo((() => effectiveWithoutEffects ? {
|
|
1739
|
-
x: 0,
|
|
1740
|
-
y: 0
|
|
1741
|
-
} : 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 => {
|
|
1686
|
+
return "undefined" == typeof process || process.env, baseConfig;
|
|
1687
|
+
}), [ 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 => {
|
|
1742
1688
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
1743
1689
|
if (effectiveWithoutEffects) return;
|
|
1744
1690
|
const container = mouseContainer?.current || glassRef.current;
|
|
@@ -1747,35 +1693,61 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1747
1693
|
let rect = cachedRectRef.current;
|
|
1748
1694
|
if (rect && 0 !== rect.width && 0 !== rect.height || (rect = container.getBoundingClientRect(),
|
|
1749
1695
|
cachedRectRef.current = rect), 0 === rect.width || 0 === rect.height) return;
|
|
1750
|
-
const center = calculateElementCenter(rect)
|
|
1696
|
+
const center = calculateElementCenter(rect);
|
|
1697
|
+
// Write raw target — the lerp loop will smoothly pursue it
|
|
1698
|
+
targetMouseOffsetRef.current = {
|
|
1751
1699
|
x: (globalPos.x - center.x) / rect.width * 100,
|
|
1752
1700
|
y: (globalPos.y - center.y) / rect.height * 100
|
|
1701
|
+
}, targetGlobalMousePositionRef.current = globalPos;
|
|
1702
|
+
}), [ mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]), startLerpLoop = useCallback((() => {
|
|
1703
|
+
if (lerpActiveRef.current) return;
|
|
1704
|
+
lerpActiveRef.current = !0;
|
|
1705
|
+
const LERP_T = CONSTANTS.LERP_FACTOR, tick = () => {
|
|
1706
|
+
if (!lerpActiveRef.current) return;
|
|
1707
|
+
const cur = internalMouseOffsetRef.current, tgt = targetMouseOffsetRef.current, dx = tgt.x - cur.x, dy = tgt.y - cur.y;
|
|
1708
|
+
// If we're close enough, snap and park
|
|
1709
|
+
if (Math.abs(dx) < .05 && Math.abs(dy) < .05) internalMouseOffsetRef.current = {
|
|
1710
|
+
...tgt
|
|
1711
|
+
}, internalGlobalMousePositionRef.current = {
|
|
1712
|
+
...targetGlobalMousePositionRef.current
|
|
1713
|
+
}; else {
|
|
1714
|
+
internalMouseOffsetRef.current = {
|
|
1715
|
+
x: lerp(cur.x, tgt.x, LERP_T),
|
|
1716
|
+
y: lerp(cur.y, tgt.y, LERP_T)
|
|
1717
|
+
};
|
|
1718
|
+
const curG = internalGlobalMousePositionRef.current, tgtG = targetGlobalMousePositionRef.current;
|
|
1719
|
+
internalGlobalMousePositionRef.current = {
|
|
1720
|
+
x: lerp(curG.x, tgtG.x, LERP_T),
|
|
1721
|
+
y: lerp(curG.y, tgtG.y, LERP_T)
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
// Imperative style update with the smoothed values
|
|
1725
|
+
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
1726
|
+
mouseOffset: internalMouseOffsetRef.current,
|
|
1727
|
+
globalMousePosition: internalGlobalMousePositionRef.current,
|
|
1728
|
+
glassSize: glassSize,
|
|
1729
|
+
isHovered: isHovered,
|
|
1730
|
+
isActive: isActive,
|
|
1731
|
+
isOverLight: overLightConfig.isOverLight,
|
|
1732
|
+
baseOverLightConfig: overLightConfig,
|
|
1733
|
+
effectiveBorderRadius: effectiveBorderRadius,
|
|
1734
|
+
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1735
|
+
effectiveReducedMotion: effectiveReducedMotion,
|
|
1736
|
+
elasticity: elasticity,
|
|
1737
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
1738
|
+
onClick: onClick,
|
|
1739
|
+
withLiquidBlur: withLiquidBlur,
|
|
1740
|
+
blurAmount: blurAmount,
|
|
1741
|
+
saturation: saturation,
|
|
1742
|
+
padding: padding
|
|
1743
|
+
}), lerpRafRef.current = requestAnimationFrame(tick);
|
|
1753
1744
|
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
globalMousePosition: globalPos,
|
|
1761
|
-
glassSize: glassSize,
|
|
1762
|
-
isHovered: isHovered,
|
|
1763
|
-
isActive: isActive,
|
|
1764
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
1765
|
-
baseOverLightConfig: baseOverLightConfig,
|
|
1766
|
-
effectiveBorderRadius: effectiveBorderRadius,
|
|
1767
|
-
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1768
|
-
effectiveReducedMotion: effectiveReducedMotion,
|
|
1769
|
-
elasticity: elasticity,
|
|
1770
|
-
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
1771
|
-
// Simplified directional scale for fast path
|
|
1772
|
-
onClick: onClick,
|
|
1773
|
-
withLiquidBlur: withLiquidBlur,
|
|
1774
|
-
blurAmount: blurAmount,
|
|
1775
|
-
saturation: saturation,
|
|
1776
|
-
padding: padding
|
|
1777
|
-
});
|
|
1778
|
-
}), [ mouseContainer, glassRef, wrapperRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects, glassSize, isHovered, isActive, baseOverLightConfig, effectiveBorderRadius, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]);
|
|
1745
|
+
// 0.08 – lower = more viscous
|
|
1746
|
+
lerpRafRef.current = requestAnimationFrame(tick);
|
|
1747
|
+
}), [ glassRef, wrapperRef, glassSize, isHovered, isActive, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]), stopLerpLoop = useCallback((() => {
|
|
1748
|
+
lerpActiveRef.current = !1, null !== lerpRafRef.current && (cancelAnimationFrame(lerpRafRef.current),
|
|
1749
|
+
lerpRafRef.current = null);
|
|
1750
|
+
}), []);
|
|
1779
1751
|
/**
|
|
1780
1752
|
* Validate and clamp a numeric config value
|
|
1781
1753
|
*/
|
|
@@ -1783,7 +1755,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1783
1755
|
useEffect((() => {
|
|
1784
1756
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
1785
1757
|
if (effectiveWithoutEffects) return;
|
|
1786
|
-
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition)
|
|
1758
|
+
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition);
|
|
1759
|
+
// Start the lerp loop — it will smoothly chase the target
|
|
1760
|
+
startLerpLoop();
|
|
1761
|
+
const container = mouseContainer?.current || glassRef.current;
|
|
1787
1762
|
let resizeObserver = null;
|
|
1788
1763
|
return container && "undefined" != typeof ResizeObserver && (resizeObserver = new ResizeObserver((() => {
|
|
1789
1764
|
null !== updateRectRef.current && cancelAnimationFrame(updateRectRef.current), updateRectRef.current = requestAnimationFrame((() => {
|
|
@@ -1791,10 +1766,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1791
1766
|
container && (cachedRectRef.current = container.getBoundingClientRect()), updateRectRef.current = null;
|
|
1792
1767
|
}));
|
|
1793
1768
|
})), resizeObserver.observe(container)), () => {
|
|
1794
|
-
unsubscribe(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
1769
|
+
unsubscribe(), stopLerpLoop(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
1795
1770
|
updateRectRef.current = null), resizeObserver && resizeObserver.disconnect();
|
|
1796
1771
|
};
|
|
1797
|
-
}), [ handleGlobalMousePosition, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
1772
|
+
}), [ handleGlobalMousePosition, startLerpLoop, stopLerpLoop, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
1798
1773
|
// Also call updateStyles on other state changes (hover, active, etc)
|
|
1799
1774
|
useEffect((() => {
|
|
1800
1775
|
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
@@ -1803,22 +1778,22 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1803
1778
|
glassSize: glassSize,
|
|
1804
1779
|
isHovered: isHovered,
|
|
1805
1780
|
isActive: isActive,
|
|
1806
|
-
isOverLight:
|
|
1807
|
-
baseOverLightConfig:
|
|
1781
|
+
isOverLight: overLightConfig.isOverLight,
|
|
1782
|
+
baseOverLightConfig: overLightConfig,
|
|
1808
1783
|
effectiveBorderRadius: effectiveBorderRadius,
|
|
1809
1784
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
1810
1785
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
1811
1786
|
elasticity: elasticity,
|
|
1812
|
-
directionalScale:
|
|
1787
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
1813
1788
|
onClick: onClick,
|
|
1814
1789
|
withLiquidBlur: withLiquidBlur,
|
|
1815
1790
|
blurAmount: blurAmount,
|
|
1816
1791
|
saturation: saturation,
|
|
1817
1792
|
padding: padding
|
|
1818
1793
|
});
|
|
1819
|
-
}), [ isHovered, isActive, glassSize,
|
|
1794
|
+
}), [ isHovered, isActive, glassSize, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, wrapperRef, glassRef, externalMouseOffset, externalGlobalMousePosition, withLiquidBlur, blurAmount, saturation, padding, onClick ]);
|
|
1820
1795
|
// Event handlers
|
|
1821
|
-
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []),
|
|
1796
|
+
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []), handleKeyDown = useCallback((e => {
|
|
1822
1797
|
!onClick || "Enter" !== e.key && " " !== e.key || (e.preventDefault(), onClick());
|
|
1823
1798
|
}), [ onClick ]);
|
|
1824
1799
|
return {
|
|
@@ -1836,14 +1811,11 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1836
1811
|
mouseOffset: mouseOffset,
|
|
1837
1812
|
// This is now static (refs or props) unless prop changes
|
|
1838
1813
|
overLightConfig: overLightConfig,
|
|
1839
|
-
elasticTranslation: elasticTranslation,
|
|
1840
|
-
directionalScale: directionalScale,
|
|
1841
1814
|
transformStyle: transformStyle,
|
|
1842
1815
|
handleMouseEnter: handleMouseEnter,
|
|
1843
1816
|
handleMouseLeave: handleMouseLeave,
|
|
1844
1817
|
handleMouseDown: handleMouseDown,
|
|
1845
1818
|
handleMouseUp: handleMouseUp,
|
|
1846
|
-
handleMouseMove: handleMouseMove,
|
|
1847
1819
|
handleKeyDown: handleKeyDown
|
|
1848
1820
|
};
|
|
1849
1821
|
}
|
|
@@ -1941,25 +1913,56 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
1941
1913
|
withLiquidBlur: withLiquidBlur,
|
|
1942
1914
|
padding: padding,
|
|
1943
1915
|
style: style
|
|
1944
|
-
}), isOverLight = useMemo((() => overLightConfig
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1916
|
+
}), isOverLight = useMemo((() => overLightConfig.isOverLight), [ overLightConfig.isOverLight ]), shouldRenderOverLightLayers = withOverLightLayers && isOverLight, {zIndex: customZIndex, ...restStyle} = style, isFixedOrSticky = "fixed" === restStyle.position || "sticky" === restStyle.position, rootLayoutStyle = useMemo((() => {
|
|
1917
|
+
if (!isFixedOrSticky) return {};
|
|
1918
|
+
const {position: p, top: t, left: l, right: r, bottom: b} = restStyle;
|
|
1919
|
+
return {
|
|
1920
|
+
...p && {
|
|
1921
|
+
position: p
|
|
1922
|
+
},
|
|
1923
|
+
...void 0 !== t && {
|
|
1924
|
+
top: t
|
|
1925
|
+
},
|
|
1926
|
+
...void 0 !== l && {
|
|
1927
|
+
left: l
|
|
1928
|
+
},
|
|
1929
|
+
...void 0 !== r && {
|
|
1930
|
+
right: r
|
|
1931
|
+
},
|
|
1932
|
+
...void 0 !== b && {
|
|
1933
|
+
bottom: b
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
}), [ isFixedOrSticky, restStyle ]), baseStyle = useMemo((() => {
|
|
1937
|
+
if (isFixedOrSticky) {
|
|
1938
|
+
const {position: _p, top: _t, left: _l, right: _r, bottom: _b, ...visualStyle} = restStyle;
|
|
1939
|
+
return {
|
|
1940
|
+
...visualStyle,
|
|
1941
|
+
...!effectiveWithoutEffects && {
|
|
1942
|
+
transform: transformStyle
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1948
1945
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1946
|
+
return {
|
|
1947
|
+
...restStyle,
|
|
1948
|
+
...!effectiveWithoutEffects && {
|
|
1949
|
+
transform: transformStyle
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
}), [ 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((() => ({
|
|
1953
|
+
position: isFixedOrSticky ? "absolute" : restStyle.position || "absolute",
|
|
1954
|
+
top: isFixedOrSticky ? 0 : restStyle.top || 0,
|
|
1955
|
+
left: isFixedOrSticky ? 0 : restStyle.left || 0
|
|
1956
|
+
})), [ isFixedOrSticky, restStyle.position, restStyle.top, restStyle.left ]), adjustedSize = useMemo((() => {
|
|
1954
1957
|
const resolveSize = (propValue, styleValue, measuredSize) => {
|
|
1955
1958
|
const explicitSize = propValue ?? styleValue;
|
|
1956
1959
|
return void 0 !== explicitSize ? "number" == typeof explicitSize ? `${explicitSize}px` : explicitSize : "fixed" === positionStyles.position ? `${Math.max(measuredSize, 0)}px` : "100%";
|
|
1957
1960
|
};
|
|
1958
1961
|
return {
|
|
1959
|
-
width: resolveSize(width,
|
|
1960
|
-
height: resolveSize(height,
|
|
1962
|
+
width: resolveSize(width, restStyle.width, glassSize.width),
|
|
1963
|
+
height: resolveSize(height, restStyle.height, glassSize.height)
|
|
1961
1964
|
};
|
|
1962
|
-
}), [ width, height,
|
|
1965
|
+
}), [ width, height, restStyle.width, restStyle.height, positionStyles.position, glassSize.width, glassSize.height ]), gradientValues = useMemo((() => {
|
|
1963
1966
|
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT;
|
|
1964
1967
|
return {
|
|
1965
1968
|
borderGradientAngle: GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER,
|
|
@@ -2001,6 +2004,9 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2001
2004
|
}), [ isHovered, isActive, isOverLight, overLightConfig.opacity ]), glassVars = useMemo((() => {
|
|
2002
2005
|
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;
|
|
2003
2006
|
return {
|
|
2007
|
+
...void 0 !== customZIndex && {
|
|
2008
|
+
"--atomix-glass-base-z-index": customZIndex
|
|
2009
|
+
},
|
|
2004
2010
|
"--atomix-glass-radius": `${effectiveBorderRadius}px`,
|
|
2005
2011
|
"--atomix-glass-transform": transformStyle || "none",
|
|
2006
2012
|
"--atomix-glass-position": positionStyles.position,
|
|
@@ -2021,22 +2027,19 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2021
2027
|
"--atomix-glass-base-opacity": opacityValues.base,
|
|
2022
2028
|
"--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})`,
|
|
2023
2029
|
"--atomix-glass-overlay-opacity": opacityValues.over,
|
|
2024
|
-
"--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})
|
|
2030
|
+
"--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})`,
|
|
2031
|
+
"--atomix-glass-overlay-highlight-opacity": opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
2032
|
+
"--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}%)`
|
|
2025
2033
|
};
|
|
2026
|
-
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
2027
|
-
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(" ")
|
|
2028
|
-
style: {
|
|
2029
|
-
...positionStyles,
|
|
2030
|
-
height: adjustedSize.height,
|
|
2031
|
-
width: adjustedSize.width,
|
|
2032
|
-
borderRadius: `${effectiveBorderRadius}px`,
|
|
2033
|
-
transform: baseStyle.transform
|
|
2034
|
-
}
|
|
2034
|
+
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity, customZIndex ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
2035
|
+
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(" ")
|
|
2035
2036
|
});
|
|
2036
2037
|
return jsxs("div", {
|
|
2037
2038
|
...rest,
|
|
2038
2039
|
className: componentClassName,
|
|
2039
|
-
style:
|
|
2040
|
+
style: {
|
|
2041
|
+
...glassVars
|
|
2042
|
+
},
|
|
2040
2043
|
role: role || (onClick ? "button" : void 0),
|
|
2041
2044
|
tabIndex: onClick ? tabIndex ?? 0 : tabIndex,
|
|
2042
2045
|
"aria-label": ariaLabel,
|
|
@@ -2048,7 +2051,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2048
2051
|
ref: glassRef,
|
|
2049
2052
|
contentRef: contentRef,
|
|
2050
2053
|
className: className,
|
|
2051
|
-
style:
|
|
2054
|
+
style: rootLayoutStyle,
|
|
2052
2055
|
borderRadius: effectiveBorderRadius,
|
|
2053
2056
|
displacementScale: effectiveWithoutEffects ? 0 : "shader" === mode ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.SHADER_DISPLACEMENT : isOverLight ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.OVER_LIGHT_DISPLACEMENT : displacementScale,
|
|
2054
2057
|
blurAmount: effectiveWithoutEffects ? 0 : blurAmount,
|
|
@@ -2099,11 +2102,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2099
2102
|
}), jsx("div", {
|
|
2100
2103
|
className: ATOMIX_GLASS.OVERLAY_LAYER_CLASS
|
|
2101
2104
|
}), jsx("div", {
|
|
2102
|
-
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
2103
|
-
style: {
|
|
2104
|
-
opacity: opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
2105
|
-
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}%)`
|
|
2106
|
-
}
|
|
2105
|
+
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
2107
2106
|
}) ]
|
|
2108
2107
|
}), withBorder && jsxs(Fragment, {
|
|
2109
2108
|
children: [ jsx("span", {
|