@shohojdhara/atomix 0.5.0 → 0.5.1

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.
Files changed (76) hide show
  1. package/dist/atomix.css +95 -69
  2. package/dist/atomix.css.map +1 -1
  3. package/dist/atomix.min.css +1 -1
  4. package/dist/atomix.min.css.map +1 -1
  5. package/dist/charts.d.ts +1 -0
  6. package/dist/charts.js +231 -332
  7. package/dist/charts.js.map +1 -1
  8. package/dist/core.d.ts +1 -0
  9. package/dist/core.js +232 -333
  10. package/dist/core.js.map +1 -1
  11. package/dist/forms.d.ts +1 -0
  12. package/dist/forms.js +231 -332
  13. package/dist/forms.js.map +1 -1
  14. package/dist/heavy.d.ts +11 -2
  15. package/dist/heavy.js +233 -334
  16. package/dist/heavy.js.map +1 -1
  17. package/dist/index.d.ts +13 -2
  18. package/dist/index.esm.js +228 -327
  19. package/dist/index.esm.js.map +1 -1
  20. package/dist/index.js +227 -326
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.min.js +1 -1
  23. package/dist/index.min.js.map +1 -1
  24. package/package.json +11 -1
  25. package/src/components/AtomixGlass/AtomixGlass.tsx +188 -128
  26. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +62 -90
  27. package/src/components/AtomixGlass/PerformanceDashboard.tsx +153 -201
  28. package/src/components/AtomixGlass/glass-utils.ts +50 -0
  29. package/src/components/AtomixGlass/stories/AnimationFeatures.stories.tsx +52 -46
  30. package/src/components/AtomixGlass/stories/Examples.stories.tsx +573 -236
  31. package/src/components/AtomixGlass/stories/Playground.stories.tsx +88 -41
  32. package/src/components/AtomixGlass/stories/argTypes.ts +19 -19
  33. package/src/components/AtomixGlass/stories/shared-components.tsx +7 -12
  34. package/src/components/AtomixGlass/stories/types.ts +3 -3
  35. package/src/lib/composables/useAtomixGlass.ts +108 -71
  36. package/src/lib/composables/useAtomixGlassStyles.ts +0 -2
  37. package/src/lib/constants/components.ts +1 -0
  38. package/src/lib/types/components.ts +1 -0
  39. package/src/lib/utils/displacement-generator.ts +1 -1
  40. package/src/styles/06-components/_components.atomix-glass.scss +158 -97
  41. package/scripts/cli/__tests__/README.md +0 -81
  42. package/scripts/cli/__tests__/basic.test.js +0 -116
  43. package/scripts/cli/__tests__/clean.test.js +0 -278
  44. package/scripts/cli/__tests__/component-generator.test.js +0 -332
  45. package/scripts/cli/__tests__/component-validator.test.js +0 -433
  46. package/scripts/cli/__tests__/generator.test.js +0 -613
  47. package/scripts/cli/__tests__/glass-motion.test.js +0 -256
  48. package/scripts/cli/__tests__/integration.test.js +0 -938
  49. package/scripts/cli/__tests__/migrate.test.js +0 -74
  50. package/scripts/cli/__tests__/security.test.js +0 -206
  51. package/scripts/cli/__tests__/test-setup.js +0 -135
  52. package/scripts/cli/__tests__/theme-bridge.test.js +0 -507
  53. package/scripts/cli/__tests__/token-manager.test.js +0 -251
  54. package/scripts/cli/__tests__/token-provider.test.js +0 -361
  55. package/scripts/cli/__tests__/utils.test.js +0 -165
  56. package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +0 -216
  57. package/src/components/AtomixGlass/stories/AnimationTests.stories.tsx +0 -95
  58. package/src/components/AtomixGlass/stories/CardExamples.stories.tsx +0 -212
  59. package/src/components/AtomixGlass/stories/Customization.stories.tsx +0 -131
  60. package/src/components/AtomixGlass/stories/DashboardExamples.stories.tsx +0 -348
  61. package/src/components/AtomixGlass/stories/EcommerceExamples.stories.tsx +0 -410
  62. package/src/components/AtomixGlass/stories/FormExamples.stories.tsx +0 -436
  63. package/src/components/AtomixGlass/stories/HeroExamples.stories.tsx +0 -264
  64. package/src/components/AtomixGlass/stories/InteractivePlayground.stories.tsx +0 -247
  65. package/src/components/AtomixGlass/stories/MobileUIExamples.stories.tsx +0 -418
  66. package/src/components/AtomixGlass/stories/ModalExamples.stories.tsx +0 -402
  67. package/src/components/AtomixGlass/stories/Modes.stories.tsx +0 -1082
  68. package/src/components/AtomixGlass/stories/Overview.stories.tsx +0 -497
  69. package/src/components/AtomixGlass/stories/Performance.stories.tsx +0 -103
  70. package/src/components/AtomixGlass/stories/PresetGallery.stories.tsx +0 -335
  71. package/src/components/AtomixGlass/stories/Shaders.stories.tsx +0 -395
  72. package/src/components/AtomixGlass/stories/WidgetExamples.stories.tsx +0 -441
  73. package/src/components/TypedButton/TypedButton.stories.tsx +0 -59
  74. package/src/components/TypedButton/TypedButton.tsx +0 -39
  75. package/src/components/TypedButton/index.ts +0 -2
  76. package/src/lib/composables/useTypedButton.ts +0 -66
@@ -775,49 +775,14 @@ export function useAtomixGlass({
775
775
  // ── Raw mouse handler — writes to TARGET refs only ──────────────────
776
776
  // The lerp loop (below) reads the targets and incrementally
777
777
  // moves the "current" refs toward them for liquid smoothing.
778
- const handleGlobalMousePosition = useCallback(
779
- (globalPos: MousePosition) => {
780
- if (externalGlobalMousePosition && externalMouseOffset) {
781
- return;
782
- }
783
-
784
- if (effectiveWithoutEffects) {
785
- return;
786
- }
787
-
788
- const container = mouseContainer?.current || glassRef.current;
789
- if (!container) {
790
- return;
791
- }
792
-
793
- // Use cached rect if available, otherwise get new one
794
- let rect = cachedRectRef.current;
795
- if (!rect || rect.width === 0 || rect.height === 0) {
796
- rect = container.getBoundingClientRect();
797
- cachedRectRef.current = rect;
798
- }
799
778
 
800
- if (rect.width === 0 || rect.height === 0) {
801
- return;
802
- }
803
-
804
- const center = calculateElementCenter(rect);
805
-
806
- // Write raw target — the lerp loop will smoothly pursue it
807
- targetMouseOffsetRef.current = {
808
- x: ((globalPos.x - center.x) / rect.width) * 100,
809
- y: ((globalPos.y - center.y) / rect.height) * 100,
810
- };
811
- targetGlobalMousePositionRef.current = globalPos;
812
- },
813
- [
814
- mouseContainer,
815
- glassRef,
816
- externalGlobalMousePosition,
817
- externalMouseOffset,
818
- effectiveWithoutEffects,
819
- ]
820
- );
779
+ const stopLerpLoop = useCallback(() => {
780
+ lerpActiveRef.current = false;
781
+ if (lerpRafRef.current !== null) {
782
+ cancelAnimationFrame(lerpRafRef.current);
783
+ lerpRafRef.current = null;
784
+ }
785
+ }, []);
821
786
 
822
787
  // ── Lerp animation loop ─────────────────────────────────────────────
823
788
  // Continuously interpolates the current offset toward the target.
@@ -827,20 +792,18 @@ export function useAtomixGlass({
827
792
  lerpActiveRef.current = true;
828
793
 
829
794
  const LERP_T = CONSTANTS.LERP_FACTOR; // 0.08 – lower = more viscous
830
- const EPSILON = 0.05; // Stop iterating when close enough
795
+ const EPSILON = 0.01; // Snap when close enough
831
796
 
832
797
  const tick = () => {
833
798
  if (!lerpActiveRef.current) return;
834
799
 
835
- // Add ref validity check to prevent memory leaks
836
- if (!glassRef.current || !wrapperRef?.current) {
800
+ if (!glassRef.current) {
837
801
  lerpActiveRef.current = false;
838
802
  return;
839
803
  }
840
804
 
841
805
  const cur = internalMouseOffsetRef.current;
842
806
  const tgt = targetMouseOffsetRef.current;
843
-
844
807
  const dx = tgt.x - cur.x;
845
808
  const dy = tgt.y - cur.y;
846
809
 
@@ -848,22 +811,53 @@ export function useAtomixGlass({
848
811
  if (Math.abs(dx) < EPSILON && Math.abs(dy) < EPSILON) {
849
812
  internalMouseOffsetRef.current = { ...tgt };
850
813
  internalGlobalMousePositionRef.current = { ...targetGlobalMousePositionRef.current };
851
- } else {
852
- internalMouseOffsetRef.current = {
853
- x: lerp(cur.x, tgt.x, LERP_T),
854
- y: lerp(cur.y, tgt.y, LERP_T),
855
- };
856
- const curG = internalGlobalMousePositionRef.current;
857
- const tgtG = targetGlobalMousePositionRef.current;
858
- internalGlobalMousePositionRef.current = {
859
- x: lerp(curG.x, tgtG.x, LERP_T),
860
- y: lerp(curG.y, tgtG.y, LERP_T),
861
- };
814
+
815
+ // Final update and stop
816
+ updateAtomixGlassStyles(
817
+ wrapperRef?.current || null,
818
+ glassRef.current,
819
+ {
820
+ mouseOffset: internalMouseOffsetRef.current,
821
+ globalMousePosition: internalGlobalMousePositionRef.current,
822
+ glassSize,
823
+ isHovered,
824
+ isActive,
825
+ isOverLight: overLightConfig.isOverLight,
826
+ baseOverLightConfig: overLightConfig,
827
+ effectiveBorderRadius,
828
+ effectiveWithoutEffects,
829
+ effectiveReducedMotion,
830
+ elasticity,
831
+ directionalScale: isActive && Boolean(onClick) ? 'scale(0.96)' : 'scale(1)',
832
+ onClick,
833
+ withLiquidBlur,
834
+ blurAmount,
835
+ saturation,
836
+ padding,
837
+ isFixedOrSticky,
838
+ }
839
+ );
840
+
841
+ stopLerpLoop();
842
+ return;
862
843
  }
863
844
 
864
- // Imperative style update with the smoothed values
845
+ // Smooth step
846
+ internalMouseOffsetRef.current = {
847
+ x: lerp(cur.x, tgt.x, LERP_T),
848
+ y: lerp(cur.y, tgt.y, LERP_T),
849
+ };
850
+
851
+ const curG = internalGlobalMousePositionRef.current;
852
+ const tgtG = targetGlobalMousePositionRef.current;
853
+ internalGlobalMousePositionRef.current = {
854
+ x: lerp(curG.x, tgtG.x, LERP_T),
855
+ y: lerp(curG.y, tgtG.y, LERP_T),
856
+ };
857
+
858
+ // Imperative style update
865
859
  updateAtomixGlassStyles(
866
- wrapperRef.current,
860
+ wrapperRef?.current || null,
867
861
  glassRef.current,
868
862
  {
869
863
  mouseOffset: internalMouseOffsetRef.current,
@@ -908,15 +902,58 @@ export function useAtomixGlass({
908
902
  saturation,
909
903
  padding,
910
904
  isFixedOrSticky,
905
+ stopLerpLoop,
911
906
  ]);
912
907
 
913
- const stopLerpLoop = useCallback(() => {
914
- lerpActiveRef.current = false;
915
- if (lerpRafRef.current !== null) {
916
- cancelAnimationFrame(lerpRafRef.current);
917
- lerpRafRef.current = null;
918
- }
919
- }, []);
908
+ const handleGlobalMousePosition = useCallback(
909
+ (globalPos: MousePosition) => {
910
+ if (externalGlobalMousePosition && externalMouseOffset) {
911
+ return;
912
+ }
913
+
914
+ if (effectiveWithoutEffects) {
915
+ return;
916
+ }
917
+
918
+ const container = mouseContainer?.current || glassRef.current;
919
+ if (!container) {
920
+ return;
921
+ }
922
+
923
+ // Use cached rect if available, otherwise get new one
924
+ let rect = cachedRectRef.current;
925
+ if (!rect || rect.width === 0 || rect.height === 0) {
926
+ rect = container.getBoundingClientRect();
927
+ cachedRectRef.current = rect;
928
+ }
929
+
930
+ if (rect.width === 0 || rect.height === 0) {
931
+ return;
932
+ }
933
+
934
+ const center = calculateElementCenter(rect);
935
+
936
+ // Write raw target — the lerp loop will smoothly pursue it
937
+ targetMouseOffsetRef.current = {
938
+ x: ((globalPos.x - center.x) / rect.width) * 100,
939
+ y: ((globalPos.y - center.y) / rect.height) * 100,
940
+ };
941
+ targetGlobalMousePositionRef.current = globalPos;
942
+
943
+ // Ensure the lerp loop is running to smoothly chase the new target
944
+ if (!lerpActiveRef.current) {
945
+ startLerpLoop();
946
+ }
947
+ },
948
+ [
949
+ mouseContainer,
950
+ glassRef,
951
+ externalGlobalMousePosition,
952
+ externalMouseOffset,
953
+ effectiveWithoutEffects,
954
+ startLerpLoop,
955
+ ]
956
+ );
920
957
 
921
958
  // Subscribe to shared mouse tracker
922
959
  useEffect(() => {
@@ -929,8 +966,8 @@ export function useAtomixGlass({
929
966
  }
930
967
 
931
968
  const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition);
932
-
933
- // Start the lerp loop — it will smoothly chase the target
969
+
970
+ // Initial start
934
971
  startLerpLoop();
935
972
 
936
973
  const updateRect = () => {
@@ -966,14 +1003,14 @@ export function useAtomixGlass({
966
1003
  }
967
1004
  };
968
1005
  }, [
1006
+ externalGlobalMousePosition,
1007
+ externalMouseOffset,
1008
+ effectiveWithoutEffects,
969
1009
  handleGlobalMousePosition,
970
1010
  startLerpLoop,
971
1011
  stopLerpLoop,
972
1012
  mouseContainer,
973
1013
  glassRef,
974
- externalGlobalMousePosition,
975
- externalMouseOffset,
976
- effectiveWithoutEffects,
977
1014
  ]);
978
1015
 
979
1016
  // Also call updateStyles on other state changes (hover, active, etc)
@@ -298,8 +298,6 @@ export const updateAtomixGlassStyles = (
298
298
  // Container variables
299
299
  const style = containerElement.style;
300
300
 
301
- style.setProperty('--atomix-glass-container-width', !isFixedOrSticky ? '100%' : `${glassSize.width}`);
302
- style.setProperty('--atomix-glass-container-height', !isFixedOrSticky ? '100%' : `${glassSize.height}`);
303
301
  style.setProperty('--atomix-glass-container-padding', padding);
304
302
  style.setProperty('--atomix-glass-container-radius', `${effectiveBorderRadius}px`);
305
303
 
@@ -1631,6 +1631,7 @@ export const ATOMIX_GLASS = {
1631
1631
  FILTER_OVERLAY_CLASS: 'c-atomix-glass__filter-overlay',
1632
1632
  FILTER_SHADOW_CLASS: 'c-atomix-glass__filter-shadow',
1633
1633
  CONTENT_CLASS: 'c-atomix-glass__content',
1634
+ BORDER_BACKDROP_CLASS: 'c-atomix-glass__border-backdrop',
1634
1635
  BORDER_1_CLASS: 'c-atomix-glass__border-1',
1635
1636
  BORDER_2_CLASS: 'c-atomix-glass__border-2',
1636
1637
  HOVER_1_CLASS: 'c-atomix-glass__hover-1',
@@ -232,6 +232,7 @@ export interface AtomixGlassProps extends React.HTMLAttributes<HTMLDivElement> {
232
232
  overLight?: OverLightConfig;
233
233
  mode?: DisplacementMode;
234
234
  onClick?: () => void;
235
+ isFixedOrSticky?: boolean;
235
236
 
236
237
  /**
237
238
  * Shader variant for shader mode
@@ -10,7 +10,7 @@ export interface ShaderOptions {
10
10
  }
11
11
 
12
12
  function smoothStep(a: number, b: number, t: number): number {
13
- t = Math.max(0, Math.min(1, (t - a) / (b - a));
13
+ t = Math.max(0, Math.min(1, (t - a) / (b - a)));
14
14
  return t * t * (3 - 2 * t);
15
15
  }
16
16