@shohojdhara/atomix 0.6.4 → 0.6.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.
Files changed (83) hide show
  1. package/dist/atomix.css +117 -38
  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/atomix.umd.js +1 -1
  6. package/dist/atomix.umd.js.map +1 -1
  7. package/dist/atomix.umd.min.js +1 -1
  8. package/dist/charts.d.ts +30 -1
  9. package/dist/charts.js +625 -846
  10. package/dist/charts.js.map +1 -1
  11. package/dist/core.d.ts +30 -1
  12. package/dist/core.js +659 -873
  13. package/dist/core.js.map +1 -1
  14. package/dist/forms.d.ts +30 -1
  15. package/dist/forms.js +1171 -1402
  16. package/dist/forms.js.map +1 -1
  17. package/dist/heavy.d.ts +31 -89
  18. package/dist/heavy.js +975 -1195
  19. package/dist/heavy.js.map +1 -1
  20. package/dist/index.d.ts +383 -140
  21. package/dist/index.esm.js +1567 -1679
  22. package/dist/index.esm.js.map +1 -1
  23. package/dist/index.js +1556 -1667
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.min.js +1 -1
  26. package/dist/index.min.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/components/Accordion/Accordion.tsx +2 -5
  29. package/src/components/AtomixGlass/AtomixGlass.test.tsx +14 -16
  30. package/src/components/AtomixGlass/AtomixGlass.tsx +137 -364
  31. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +32 -251
  32. package/src/components/AtomixGlass/GlassFilter.tsx +62 -68
  33. package/src/components/AtomixGlass/README.md +2 -1
  34. package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +19 -18
  35. package/src/components/AtomixGlass/glass-border-styles.test.ts +58 -0
  36. package/src/components/AtomixGlass/glass-border-styles.ts +136 -0
  37. package/src/components/AtomixGlass/glass-utils.ts +456 -22
  38. package/src/components/AtomixGlass/shader-utils.ts +19 -77
  39. package/src/components/AtomixGlass/stories/AnimationFeatures.stories.tsx +158 -537
  40. package/src/components/AtomixGlass/stories/Border.stories.tsx +149 -0
  41. package/src/components/AtomixGlass/stories/Examples.stories.tsx +229 -89
  42. package/src/components/AtomixGlass/stories/Playground.stories.tsx +29 -340
  43. package/src/components/AtomixGlass/stories/argTypes.ts +30 -13
  44. package/src/components/AtomixGlass/stories/premium-presets.ts +206 -0
  45. package/src/components/AtomixGlass/stories/shared-components.tsx +52 -8
  46. package/src/components/Badge/Badge.tsx +4 -4
  47. package/src/components/Button/Button.tsx +2 -6
  48. package/src/components/Callout/Callout.test.tsx +4 -3
  49. package/src/components/Callout/Callout.tsx +2 -5
  50. package/src/components/Dropdown/Dropdown.tsx +3 -7
  51. package/src/components/Form/Checkbox.tsx +2 -8
  52. package/src/components/Form/Input.tsx +2 -9
  53. package/src/components/Form/Radio.tsx +2 -9
  54. package/src/components/Form/Select.test.tsx +6 -6
  55. package/src/components/Form/Select.tsx +2 -7
  56. package/src/components/Form/Textarea.stories.tsx +5 -5
  57. package/src/components/Form/Textarea.tsx +2 -9
  58. package/src/components/Messages/Messages.tsx +2 -8
  59. package/src/components/Modal/Modal.tsx +4 -5
  60. package/src/components/Navigation/Nav/Nav.tsx +2 -6
  61. package/src/components/Navigation/Navbar/Navbar.tsx +2 -9
  62. package/src/components/Navigation/SideMenu/SideMenu.tsx +2 -6
  63. package/src/components/Pagination/Pagination.tsx +2 -10
  64. package/src/components/Popover/Popover.tsx +2 -9
  65. package/src/components/Progress/Progress.tsx +2 -7
  66. package/src/components/Rating/Rating.tsx +2 -10
  67. package/src/components/Spinner/Spinner.tsx +2 -7
  68. package/src/components/Steps/Steps.tsx +2 -10
  69. package/src/components/Tabs/Tabs.tsx +2 -9
  70. package/src/components/Toggle/Toggle.tsx +2 -10
  71. package/src/components/Tooltip/Tooltip.tsx +2 -5
  72. package/src/lib/composables/useAtomixGlass.ts +42 -143
  73. package/src/lib/composables/useAtomixGlassStyles.ts +61 -77
  74. package/src/lib/composables/usePerformanceMonitor.ts +5 -66
  75. package/src/lib/constants/components.ts +363 -46
  76. package/src/lib/types/components.ts +33 -1
  77. package/src/styles/01-settings/_settings.atomix-glass.scss +66 -28
  78. package/src/styles/02-tools/_tools.button.scss +51 -42
  79. package/src/styles/02-tools/_tools.glass.scss +45 -3
  80. package/src/styles/06-components/_components.atomix-glass.scss +116 -79
  81. package/src/components/AtomixGlass/PerformanceDashboard.tsx +0 -171
  82. package/src/components/AtomixGlass/animation-system.ts +0 -578
  83. package/src/components/AtomixGlass/deprecated/AtomixGlass.deprecated.tsx +0 -390
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Premium / Apple liquid-glass presets for AtomixGlass Storybook stories.
3
+ * Centralizes tuned displacement, blur, and saturation so previews stay consistent.
4
+ */
5
+ import type { AtomixGlassProps } from '../../../lib/types/components';
6
+
7
+ /** Curated backgrounds that show frost, tint, and depth well */
8
+ export const premiumBackgrounds = [
9
+ 'https://images.unsplash.com/photo-1614188973043-4ed7d383de37?ixlib=rb-4.1.0&auto=format&fit=crop&q=80&w=2000',
10
+ 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?ixlib=rb-4.1.0&auto=format&fit=crop&q=80&w=2128',
11
+ 'https://images.unsplash.com/photo-1593433073755-4233a78ee359?q=80&w=1600&auto=format&fit=crop',
12
+ 'https://images.unsplash.com/photo-1637825891028-564f672aa42c?ixlib=rb-4.1.0&auto=format&fit=crop&q=80&w=2000',
13
+ 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?q=80&w=2000&auto=format&fit=crop',
14
+ 'https://images.unsplash.com/photo-1519681393784-d120267933ba?ixlib=rb-4.1.0&auto=format&fit=crop&q=80&w=2000',
15
+ ] as const;
16
+
17
+ /** Apple Music–style dark canvas when no photo is needed */
18
+ export const premiumDarkCanvas =
19
+ 'radial-gradient(ellipse 110% 90% at 65% 15%, #5c1030 0%, #1a0a12 42%, #0a0a0c 100%)';
20
+
21
+ export type PremiumGlassPreset = Pick<
22
+ AtomixGlassProps,
23
+ | 'displacementScale'
24
+ | 'blurAmount'
25
+ | 'saturation'
26
+ | 'aberrationIntensity'
27
+ | 'elasticity'
28
+ | 'borderRadius'
29
+ | 'mode'
30
+ | 'withLiquidBlur'
31
+ | 'withTimeAnimation'
32
+ | 'withMultiLayerDistortion'
33
+ | 'distortionQuality'
34
+ | 'animationSpeed'
35
+ | 'shaderVariant'
36
+ >;
37
+
38
+ /** Production-tuned glass recipes */
39
+ export const PREMIUM_GLASS = {
40
+ /** Sidebar, nav bar, player chrome — minimal warp, deep blur */
41
+ chrome: {
42
+ displacementScale: 24,
43
+ blurAmount: 24,
44
+ saturation: 180,
45
+ aberrationIntensity: 0.4,
46
+ elasticity: 0,
47
+ borderRadius: 12,
48
+ },
49
+ /** Cards, modals, panels */
50
+ card: {
51
+ displacementScale: 28,
52
+ blurAmount: 20,
53
+ saturation: 180,
54
+ aberrationIntensity: 0.56,
55
+ elasticity: 0.05,
56
+ borderRadius: 16,
57
+ },
58
+ /** Floating pills, toolbars */
59
+ pill: {
60
+ displacementScale: 22,
61
+ blurAmount: 22,
62
+ saturation: 180,
63
+ aberrationIntensity: 0.35,
64
+ elasticity: 0,
65
+ borderRadius: 999,
66
+ },
67
+ /** Marketing hero — more presence, still refined */
68
+ hero: {
69
+ displacementScale: 48,
70
+ blurAmount: 28,
71
+ saturation: 185,
72
+ aberrationIntensity: 1.2,
73
+ elasticity: 0.08,
74
+ borderRadius: 24,
75
+ mode: 'prominent' as const,
76
+ withLiquidBlur: true,
77
+ withTimeAnimation: true,
78
+ withMultiLayerDistortion: true,
79
+ distortionQuality: 'high' as const,
80
+ },
81
+ /** Shader + FBM demos */
82
+ liquid: {
83
+ displacementScale: 40,
84
+ blurAmount: 26,
85
+ saturation: 185,
86
+ aberrationIntensity: 1,
87
+ elasticity: 0.06,
88
+ borderRadius: 22,
89
+ mode: 'shader' as const,
90
+ withTimeAnimation: true,
91
+ withMultiLayerDistortion: true,
92
+ withLiquidBlur: true,
93
+ distortionQuality: 'high' as const,
94
+ animationSpeed: 1,
95
+ shaderVariant: 'liquidGlass' as const,
96
+ },
97
+ /** Cinematic / showcase */
98
+ cinematic: {
99
+ displacementScale: 56,
100
+ blurAmount: 32,
101
+ saturation: 190,
102
+ aberrationIntensity: 1.4,
103
+ elasticity: 0.1,
104
+ borderRadius: 28,
105
+ mode: 'shader' as const,
106
+ withTimeAnimation: true,
107
+ withMultiLayerDistortion: true,
108
+ withLiquidBlur: true,
109
+ distortionQuality: 'ultra' as const,
110
+ animationSpeed: 1.1,
111
+ shaderVariant: 'appleFluid' as const,
112
+ },
113
+ } satisfies Record<string, PremiumGlassPreset>;
114
+
115
+ export const premiumTypography = {
116
+ fontFamily:
117
+ '-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif',
118
+ titleGradient:
119
+ 'linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.72) 100%)',
120
+ muted: 'rgba(255,255,255,0.72)',
121
+ dim: 'rgba(255,255,255,0.45)',
122
+ } as const;
123
+
124
+ /** Playground sidebar preset bundle (settings object shape) */
125
+ export const createPlaygroundPresetSettings = (
126
+ glass: PremiumGlassPreset,
127
+ extras: Record<string, unknown> = {}
128
+ ) => ({
129
+ displacementScale: glass.displacementScale ?? 28,
130
+ blurAmount: glass.blurAmount ?? 20,
131
+ saturation: glass.saturation ?? 180,
132
+ aberrationIntensity: glass.aberrationIntensity ?? 0.56,
133
+ elasticity: glass.elasticity ?? 0,
134
+ borderRadius: glass.borderRadius ?? 16,
135
+ overLight: false,
136
+ reducedMotion: false,
137
+ highContrast: false,
138
+ withoutEffects: false,
139
+ withLiquidBlur: Boolean(glass.withLiquidBlur),
140
+ withBorder: true,
141
+ withTimeAnimation: Boolean(glass.withTimeAnimation),
142
+ animationSpeed: glass.animationSpeed ?? 1,
143
+ withMultiLayerDistortion: Boolean(glass.withMultiLayerDistortion),
144
+ distortionOctaves: 5,
145
+ distortionLacunarity: 2,
146
+ distortionGain: 0.5,
147
+ distortionQuality: (glass.distortionQuality ?? 'high') as 'low' | 'medium' | 'high' | 'ultra',
148
+ devicePreset: 'quality' as const,
149
+ disableResponsiveBreakpoints: false,
150
+ debugPerformance: false,
151
+ debugOverLight: false,
152
+ ...extras,
153
+ });
154
+
155
+ export const PLAYGROUND_PRESETS = {
156
+ apple: {
157
+ name: 'Apple Chrome',
158
+ icon: '',
159
+ settings: createPlaygroundPresetSettings(PREMIUM_GLASS.chrome, {
160
+ withTimeAnimation: false,
161
+ devicePreset: 'balanced' as const,
162
+ }),
163
+ mode: 'standard' as const,
164
+ shader: 'liquidGlass' as const,
165
+ },
166
+ card: {
167
+ name: 'Premium Card',
168
+ icon: '💎',
169
+ settings: createPlaygroundPresetSettings(PREMIUM_GLASS.card),
170
+ mode: 'standard' as const,
171
+ shader: 'liquidGlass' as const,
172
+ },
173
+ liquid: {
174
+ name: 'Liquid Glass',
175
+ icon: '💧',
176
+ settings: createPlaygroundPresetSettings(PREMIUM_GLASS.liquid, {
177
+ animationSpeed: 1.1,
178
+ distortionOctaves: 5,
179
+ }),
180
+ mode: 'shader' as const,
181
+ shader: 'appleFluid' as const,
182
+ },
183
+ hero: {
184
+ name: 'Hero',
185
+ icon: '✨',
186
+ settings: createPlaygroundPresetSettings(PREMIUM_GLASS.hero, {
187
+ distortionOctaves: 4,
188
+ }),
189
+ mode: 'prominent' as const,
190
+ shader: 'liquidGlass' as const,
191
+ },
192
+ cinematic: {
193
+ name: 'Cinematic',
194
+ icon: '🎬',
195
+ settings: createPlaygroundPresetSettings(PREMIUM_GLASS.cinematic, {
196
+ animationSpeed: 1.2,
197
+ distortionOctaves: 6,
198
+ distortionLacunarity: 2.2,
199
+ }),
200
+ mode: 'shader' as const,
201
+ shader: 'appleFluid' as const,
202
+ },
203
+ } as const;
204
+
205
+ /** Default playground starting point */
206
+ export const PLAYGROUND_DEFAULT_SETTINGS = PLAYGROUND_PRESETS.apple.settings;
@@ -12,6 +12,7 @@
12
12
  import React, { useState, useEffect, useCallback, useRef } from 'react';
13
13
  import type { RefObject, ErrorInfo } from 'react';
14
14
  import type { StoryErrorBoundaryProps } from './types';
15
+ import { premiumBackgrounds, premiumDarkCanvas } from './premium-presets';
15
16
 
16
17
  /**
17
18
  * Enhanced BackgroundWrapper Component
@@ -197,14 +198,57 @@ export const StoryContainer: React.FC<StoryContainerProps> = ({
197
198
  /**
198
199
  * Collection of high-quality background images for different moods and scenarios
199
200
  */
200
- export const backgroundImages = [
201
- 'https://images.unsplash.com/photo-1593433073755-4233a78ee359?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
202
- 'https://images.unsplash.com/photo-1637825891028-564f672aa42c?ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&q=80&w=2670',
203
- 'https://images.unsplash.com/photo-1773062278803-0643c4782445?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
204
- 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
205
- 'https://images.unsplash.com/photo-1519681393784-d120267933ba?ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&q=80&w=2670',
206
- 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
207
- ];
201
+ /** @deprecated Use premiumBackgrounds — kept for backward compatibility */
202
+ export const backgroundImages = [...premiumBackgrounds];
203
+
204
+ export interface PremiumSceneProps {
205
+ children: React.ReactNode;
206
+ variant?: 'photo' | 'dark';
207
+ photoIndex?: number;
208
+ height?: string;
209
+ overlay?: boolean;
210
+ }
211
+
212
+ /**
213
+ * Premium story backdrop — Apple-style dark gradient or rich photography.
214
+ */
215
+ export const PremiumScene: React.FC<PremiumSceneProps> = ({
216
+ children,
217
+ variant = 'photo',
218
+ photoIndex = 0,
219
+ height = '100vh',
220
+ overlay = true,
221
+ }) => {
222
+ if (variant === 'dark') {
223
+ return (
224
+ <div
225
+ className="u-relative u-flex u-items-center u-justify-center u-overflow-hidden"
226
+ style={{
227
+ minHeight: height,
228
+ width: '100%',
229
+ background: premiumDarkCanvas,
230
+ }}
231
+ >
232
+ <div className="u-relative u-z-10 u-w-100 u-flex u-items-center u-justify-center u-p-6">
233
+ {children}
234
+ </div>
235
+ </div>
236
+ );
237
+ }
238
+
239
+ return (
240
+ <BackgroundWrapper
241
+ backgroundImage={premiumBackgrounds[photoIndex % premiumBackgrounds.length]}
242
+ height={height}
243
+ overlay={overlay}
244
+ overlayColor="rgba(0, 0, 0, 0.35)"
245
+ overlayOpacity={0.45}
246
+ padding="2rem"
247
+ >
248
+ {children}
249
+ </BackgroundWrapper>
250
+ );
251
+ };
208
252
 
209
253
  /**
210
254
  * StoryErrorBoundary Component
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, memo } from 'react';
2
2
  import { useBadge } from '../../lib/composables/useBadge';
3
- import { BADGE } from '../../lib/constants/components';
3
+ import { BADGE, GLASS_DEFAULTS } from '../../lib/constants/components';
4
4
  import { BadgeProps } from '../../lib/types/components';
5
5
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
6
6
 
@@ -59,12 +59,12 @@ export const Badge: React.FC<BadgeProps> = memo(
59
59
  if (glass) {
60
60
  // Default glass settings for badges
61
61
  const defaultGlassProps = {
62
- displacementScale: 20,
62
+ ...GLASS_DEFAULTS.BADGE,
63
+ // Override borderRadius dynamically if the ref is available
63
64
  borderRadius: ref.current?.getBoundingClientRect().width
64
65
  ? ref.current?.getBoundingClientRect().width / 2
65
- : 16,
66
+ : GLASS_DEFAULTS.BADGE.borderRadius,
66
67
  className: 'c-badge--glass',
67
- elasticity: 0,
68
68
  };
69
69
 
70
70
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
@@ -3,7 +3,7 @@ import { ButtonProps } from '../../lib/types/components';
3
3
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
4
4
  import { Spinner } from '../Spinner/Spinner';
5
5
  import { Icon, type PhosphorIconsType } from '../Icon/Icon';
6
- import { BUTTON, THEME_NAMING } from '../../lib/constants/components';
6
+ import { BUTTON, THEME_NAMING, GLASS_DEFAULTS } from '../../lib/constants/components';
7
7
  import { ThemeNaming } from '../../lib/utils/themeNaming';
8
8
  import { renderSlot } from '../../lib/patterns';
9
9
 
@@ -321,11 +321,7 @@ export const Button = React.memo(
321
321
 
322
322
  if (glass) {
323
323
  // Default glass props
324
- const defaultGlassProps = {
325
- displacementScale: 20,
326
- blurAmount: 0,
327
- saturation: 200,
328
- };
324
+ const defaultGlassProps = GLASS_DEFAULTS.BUTTON;
329
325
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
330
326
  return <AtomixGlass {...glassProps}>{buttonChildren}</AtomixGlass>;
331
327
  }
@@ -1,6 +1,7 @@
1
1
  import { render, screen, fireEvent } from '@testing-library/react';
2
2
  import { describe, it, expect, vi } from 'vitest';
3
3
  import { Callout } from './Callout';
4
+ import { GLASS_DEFAULTS } from '../../lib/constants/components';
4
5
 
5
6
  // Mock AtomixGlass component since it has complex WebGL dependencies
6
7
  vi.mock('../AtomixGlass/AtomixGlass', () => ({
@@ -151,9 +152,9 @@ describe('Callout Component', () => {
151
152
  const glassProps = JSON.parse(glassElement.getAttribute('data-glass-props') || '{}');
152
153
 
153
154
  expect(glassProps).toMatchObject({
154
- displacementScale: 30,
155
- borderRadius: 8,
156
- elasticity: 0,
155
+ displacementScale: GLASS_DEFAULTS.CALLOUT.displacementScale,
156
+ borderRadius: GLASS_DEFAULTS.CALLOUT.borderRadius,
157
+ elasticity: GLASS_DEFAULTS.CALLOUT.elasticity,
157
158
  });
158
159
  });
159
160
 
@@ -3,6 +3,7 @@ import { CalloutProps } from '../../lib/types/components';
3
3
  import { useCallout } from '../../lib/composables/useCallout';
4
4
  import { Icon } from '../Icon/Icon';
5
5
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
6
+ import { GLASS_DEFAULTS } from '../../lib/constants/components';
6
7
 
7
8
  // Type-safe interface for compound component detection
8
9
  type ExtendedComponentType<P = {}> = ComponentType<P> & {
@@ -176,11 +177,7 @@ const CalloutComponentBase = ({
176
177
 
177
178
  if (glass) {
178
179
  // Default glass settings for callouts
179
- const defaultGlassProps = {
180
- displacementScale: 30,
181
- borderRadius: 8,
182
- elasticity: 0,
183
- };
180
+ const defaultGlassProps = GLASS_DEFAULTS.CALLOUT;
184
181
 
185
182
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
186
183
 
@@ -10,7 +10,7 @@ import React, {
10
10
  ReactNode,
11
11
  ComponentType,
12
12
  } from 'react';
13
- import { DROPDOWN } from '../../lib/constants/components';
13
+ import { DROPDOWN, GLASS_DEFAULTS } from '../../lib/constants/components';
14
14
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
15
15
  import type {
16
16
  DropdownProps,
@@ -504,12 +504,8 @@ export const Dropdown: DropdownComponent = memo(function DropdownBase({
504
504
  onKeyDown={handleKeyDown}
505
505
  >
506
506
  {glass
507
- ? // Default glass settings for dropdowns
508
- (() => {
509
- const defaultGlassProps = {
510
- displacementScale: 20,
511
- elasticity: 0,
512
- };
507
+ ? (() => {
508
+ const defaultGlassProps = GLASS_DEFAULTS.DROPDOWN;
513
509
 
514
510
  const glassProps =
515
511
  glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
@@ -1,6 +1,7 @@
1
1
  import React, { memo, forwardRef, useRef, useEffect, useImperativeHandle } from 'react';
2
2
  import { CheckboxProps } from '../../lib/types/components';
3
3
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
4
+ import { GLASS_DEFAULTS } from '../../lib/constants/components';
4
5
 
5
6
  const CHECKBOX_CLASSES = {
6
7
  BASE: 'c-checkbox',
@@ -112,14 +113,7 @@ export const Checkbox = React.memo(
112
113
  }
113
114
 
114
115
  if (glass) {
115
- const defaultGlassProps = {
116
- displacementScale: 40,
117
- blurAmount: 1,
118
- saturation: 160,
119
- aberrationIntensity: 0.3,
120
- borderRadius: 6,
121
- mode: 'shader' as const,
122
- };
116
+ const defaultGlassProps = GLASS_DEFAULTS.CHECKBOX;
123
117
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
124
118
  return <AtomixGlass {...glassProps}>{content}</AtomixGlass>;
125
119
  }
@@ -2,6 +2,7 @@ import React, { forwardRef, memo } from 'react';
2
2
  import { InputProps } from '../../lib/types/components';
3
3
  import { useInput } from '../../lib/composables/useInput';
4
4
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
5
+ import { GLASS_DEFAULTS } from '../../lib/constants/components';
5
6
 
6
7
  /**
7
8
  * Input - A component for text input fields
@@ -95,15 +96,7 @@ export const Input = memo(
95
96
  );
96
97
 
97
98
  if (glass) {
98
- // Default glass settings for inputs
99
- const defaultGlassProps = {
100
- displacementScale: 60,
101
- blurAmount: 1,
102
- saturation: 180,
103
- aberrationIntensity: 0.2,
104
- borderRadius: 12,
105
- mode: 'shader' as const,
106
- };
99
+ const defaultGlassProps = GLASS_DEFAULTS.INPUT;
107
100
 
108
101
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
109
102
 
@@ -2,6 +2,7 @@ import React, { memo } from 'react';
2
2
  import { RadioProps } from '../../lib/types/components';
3
3
  import { useRadio } from '../../lib/composables/useRadio';
4
4
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
5
+ import { GLASS_DEFAULTS } from '../../lib/constants/components';
5
6
 
6
7
  /**
7
8
  * Radio - A component for radio button inputs
@@ -62,15 +63,7 @@ export const Radio: React.FC<RadioProps> = memo(
62
63
  );
63
64
 
64
65
  if (glass) {
65
- // Default glass settings for radio buttons
66
- const defaultGlassProps = {
67
- displacementScale: 40,
68
- blurAmount: 1,
69
- saturation: 160,
70
- aberrationIntensity: 0.3,
71
- borderRadius: 6,
72
- mode: 'shader' as const,
73
- };
66
+ const defaultGlassProps = GLASS_DEFAULTS.RADIO;
74
67
 
75
68
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
76
69
 
@@ -20,9 +20,9 @@ describe('Select Component', () => {
20
20
  // Check native select options
21
21
  const select = document.querySelector('select');
22
22
  expect(select).not.toBeNull();
23
- expect(select?.options).toHaveLength(3); // Placeholder + 2
24
- expect(select?.options[1].value).toBe('1');
25
- expect(select?.options[2].value).toBe('2');
23
+ expect(select!.options).toHaveLength(3); // Placeholder + 2
24
+ expect(select!.options[1]!.value).toBe('1');
25
+ expect(select!.options[2]!.value).toBe('2');
26
26
  });
27
27
 
28
28
  it('renders compound options correctly', async () => {
@@ -43,9 +43,9 @@ describe('Select Component', () => {
43
43
  await waitFor(() => {
44
44
  const select = document.querySelector('select');
45
45
  expect(select).not.toBeNull();
46
- expect(select?.options).toHaveLength(3); // Placeholder + 2
47
- expect(select?.options[1].value).toBe('1');
48
- expect(select?.options[2].value).toBe('2');
46
+ expect(select!.options).toHaveLength(3); // Placeholder + 2
47
+ expect(select!.options[1]!.value).toBe('1');
48
+ expect(select!.options[2]!.value).toBe('2');
49
49
  });
50
50
  });
51
51
 
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useEffect, useState, memo, useCallback, useMemo } from 'react';
2
2
  import { SelectProps, SelectOption as SelectOptionType } from '../../lib/types/components';
3
3
  import { useSelect } from '../../lib/composables';
4
- import { SELECT } from '../../lib/constants/components';
4
+ import { SELECT, GLASS_DEFAULTS } from '../../lib/constants/components';
5
5
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
6
6
  import { SelectContext, SelectOption } from './SelectOption';
7
7
 
@@ -396,12 +396,7 @@ const SelectComponentBase = ({
396
396
  );
397
397
 
398
398
  if (glass) {
399
- // Default glass settings for select components
400
- const defaultGlassProps = {
401
- displacementScale: 60,
402
- blurAmount: 10,
403
- mode: 'shader' as const,
404
- };
399
+ const defaultGlassProps = GLASS_DEFAULTS.SELECT;
405
400
 
406
401
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
407
402
 
@@ -104,7 +104,7 @@ Textarea component provides a multi-line text input field for longer content. It
104
104
  description: 'Number of visible text lines',
105
105
  table: {
106
106
  type: { summary: 'number' },
107
- defaultValue: { summary: 2 },
107
+ defaultValue: { summary: '2' },
108
108
  },
109
109
  },
110
110
  cols: {
@@ -138,7 +138,7 @@ Textarea component provides a multi-line text input field for longer content. It
138
138
  description: 'Whether the textarea is disabled',
139
139
  table: {
140
140
  type: { summary: 'boolean' },
141
- defaultValue: { summary: false },
141
+ defaultValue: { summary: 'false' },
142
142
  },
143
143
  },
144
144
  invalid: {
@@ -146,7 +146,7 @@ Textarea component provides a multi-line text input field for longer content. It
146
146
  description: 'Whether the textarea is invalid',
147
147
  table: {
148
148
  type: { summary: 'boolean' },
149
- defaultValue: { summary: false },
149
+ defaultValue: { summary: 'false' },
150
150
  },
151
151
  },
152
152
  valid: {
@@ -154,7 +154,7 @@ Textarea component provides a multi-line text input field for longer content. It
154
154
  description: 'Whether the textarea is valid',
155
155
  table: {
156
156
  type: { summary: 'boolean' },
157
- defaultValue: { summary: false },
157
+ defaultValue: { summary: 'false' },
158
158
  },
159
159
  },
160
160
  glass: {
@@ -162,7 +162,7 @@ Textarea component provides a multi-line text input field for longer content. It
162
162
  description: 'Enable glass morphism effect',
163
163
  table: {
164
164
  type: { summary: 'boolean' },
165
- defaultValue: { summary: false },
165
+ defaultValue: { summary: 'false' },
166
166
  },
167
167
  },
168
168
  defaultValue: {
@@ -2,6 +2,7 @@ import React, { forwardRef, memo } from 'react';
2
2
  import { TextareaProps } from '../../lib/types/components';
3
3
  import { useTextarea } from '../../lib/composables/useTextarea';
4
4
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
5
+ import { GLASS_DEFAULTS } from '../../lib/constants/components';
5
6
 
6
7
  /**
7
8
  * Textarea - A component for multiline text input
@@ -86,15 +87,7 @@ export const Textarea = memo(
86
87
  );
87
88
 
88
89
  if (glass) {
89
- // Default glass settings for textareas
90
- const defaultGlassProps = {
91
- displacementScale: 60,
92
- blurAmount: 1,
93
- saturation: 180,
94
- aberrationIntensity: 1,
95
- borderRadius: 8,
96
- mode: 'shader' as const,
97
- };
90
+ const defaultGlassProps = GLASS_DEFAULTS.TEXTAREA;
98
91
 
99
92
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
100
93
 
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Icon } from '../Icon/Icon';
3
3
  import { Avatar } from '../Avatar/Avatar';
4
4
  import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
5
- import { MESSAGES } from '../../lib/constants/components';
5
+ import { MESSAGES, GLASS_DEFAULTS } from '../../lib/constants/components';
6
6
  import { MessagesProps } from '../../lib/types/components';
7
7
  import { useMessages } from '../../lib/composables/useMessages';
8
8
 
@@ -32,13 +32,7 @@ export const Messages: React.FC<MessagesProps> = ({
32
32
  const messagesId = id || `messages-${Math.random().toString(36).substr(2, 9)}`;
33
33
  const inputId = `${messagesId}-input`;
34
34
 
35
- // Default glass settings for messages
36
- const defaultGlassProps = {
37
- displacementScale: 150,
38
- borderRadius: 12,
39
- elasticity: 0,
40
- aberrationIntensity: 2,
41
- };
35
+ const defaultGlassProps = GLASS_DEFAULTS.MESSAGES;
42
36
 
43
37
  const messagesClasses = `${MESSAGES.CLASSES.BASE} ${glass ? 'c-messages--glass' : ''} ${disabled ? 'is-disabled' : ''} ${className}`;
44
38
 
@@ -10,7 +10,7 @@ import React, {
10
10
  ComponentType,
11
11
  } from 'react';
12
12
  import { ModalProps } from '../../lib/types/components';
13
- import { MODAL } from '../../lib/constants/components';
13
+ import { MODAL, GLASS_DEFAULTS } from '../../lib/constants/components';
14
14
 
15
15
  // Define ExtendedComponentType as a type alias instead of an interface to avoid TS2312 error
16
16
  type ExtendedComponentType<P = {}> = ComponentType<P> & {
@@ -299,13 +299,12 @@ const ModalImpl = memo(
299
299
  {glass
300
300
  ? // Default glass settings for modals
301
301
  (() => {
302
+ // Default glass settings for modals
302
303
  const defaultGlassProps = {
304
+ ...GLASS_DEFAULTS.MODAL,
305
+ // displacementScale driven by modal content height at runtime
303
306
  displacementScale: document.querySelector('.c-modal---glass .c-modal__content')
304
307
  ?.clientHeight,
305
- blurAmount: 2.2,
306
- elasticity: 0,
307
- mode: 'shader' as const,
308
- shaderMode: 'premiumGlass',
309
308
  };
310
309
 
311
310
  const glassProps =
@@ -1,6 +1,7 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import { NavProps } from '../../../lib/types/components';
3
3
  import { useNav } from '../../../lib/composables/useNavbar';
4
+ import { GLASS_DEFAULTS } from '../../../lib/constants/components';
4
5
  import { AtomixGlass } from '../../AtomixGlass/AtomixGlass';
5
6
 
6
7
  /**
@@ -48,12 +49,7 @@ export const Nav = forwardRef<HTMLUListElement, NavProps>(
48
49
  );
49
50
 
50
51
  if (glass) {
51
- const defaultGlassProps = {
52
- displacementScale: 60,
53
- blurAmount: 1.5,
54
- borderRadius: 8,
55
- mode: 'shader' as const,
56
- };
52
+ const defaultGlassProps = GLASS_DEFAULTS.NAV;
57
53
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
58
54
  return <AtomixGlass {...glassProps}>{navContent}</AtomixGlass>;
59
55
  }