@shohojdhara/atomix 0.2.4 → 0.2.5
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/README.md +19 -0
- package/dist/atomix.css +1266 -1412
- package/dist/atomix.min.css +3 -3
- package/dist/index.d.ts +1232 -876
- package/dist/index.esm.js +16212 -26364
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15652 -22298
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/applemix.css +15008 -0
- package/dist/themes/applemix.min.css +72 -0
- package/dist/themes/boomdevs.css +1266 -1413
- package/dist/themes/boomdevs.min.css +3 -3
- package/dist/themes/esrar.css +1267 -1413
- package/dist/themes/esrar.min.css +3 -3
- package/dist/themes/flashtrade.css +15159 -0
- package/dist/themes/flashtrade.min.css +86 -0
- package/dist/themes/mashroom.css +1264 -1410
- package/dist/themes/mashroom.min.css +5 -5
- package/dist/themes/shaj-default.css +1266 -1412
- package/dist/themes/shaj-default.min.css +3 -3
- package/package.json +6 -17
- package/src/components/Accordion/Accordion.stories.tsx +4 -26
- package/src/components/Accordion/Accordion.tsx +21 -12
- package/src/components/AtomixGlass/AtomixGlass.test.tsx +106 -72
- package/src/components/AtomixGlass/AtomixGlass.tsx +487 -1215
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +400 -0
- package/src/components/AtomixGlass/GlassFilter.tsx +156 -0
- package/src/components/AtomixGlass/README.md +124 -2
- package/src/components/AtomixGlass/atomixGLass.old.tsx +1266 -0
- package/src/components/AtomixGlass/glass-utils.ts +263 -0
- package/src/components/AtomixGlass/shader-utils.ts +404 -236
- package/src/components/AtomixGlass/{AtomixGlass.stories.tsx → stories/AtomixGlass.stories.tsx} +55 -35
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +57 -89
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +149 -149
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +95 -32
- package/src/components/AtomixGlass/stories/ShaderVariants.stories.tsx +0 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +9 -18
- package/src/components/AtomixGlass/utils.ts +3 -3
- package/src/components/Avatar/Avatar.tsx +3 -0
- package/src/components/Avatar/AvatarGroup.tsx +2 -1
- package/src/components/Badge/Badge.stories.tsx +74 -54
- package/src/components/Badge/Badge.tsx +8 -12
- package/src/components/Breadcrumb/Breadcrumb.tsx +23 -4
- package/src/components/Button/Button.tsx +3 -5
- package/src/components/Callout/Callout.stories.tsx +86 -35
- package/src/components/Callout/Callout.tsx +4 -0
- package/src/components/Card/Card.stories.tsx +89 -85
- package/src/components/Card/Card.tsx +15 -4
- package/src/components/Card/ElevationCard.tsx +2 -0
- package/src/components/Chart/AnimatedChart.tsx +179 -156
- package/src/components/Chart/AreaChart.tsx +123 -12
- package/src/components/Chart/BarChart.tsx +91 -100
- package/src/components/Chart/BaseChart.tsx +80 -0
- package/src/components/Chart/BubbleChart.tsx +114 -290
- package/src/components/Chart/CandlestickChart.tsx +282 -622
- package/src/components/Chart/Chart.stories.tsx +576 -179
- package/src/components/Chart/Chart.tsx +374 -75
- package/src/components/Chart/ChartRenderer.tsx +371 -220
- package/src/components/Chart/ChartToolbar.tsx +372 -61
- package/src/components/Chart/ChartTooltip.tsx +33 -18
- package/src/components/Chart/DonutChart.tsx +172 -254
- package/src/components/Chart/FunnelChart.tsx +169 -240
- package/src/components/Chart/GaugeChart.tsx +224 -392
- package/src/components/Chart/HeatmapChart.tsx +302 -440
- package/src/components/Chart/LineChart.tsx +148 -103
- package/src/components/Chart/MultiAxisChart.tsx +267 -395
- package/src/components/Chart/PieChart.tsx +114 -64
- package/src/components/Chart/RadarChart.tsx +202 -218
- package/src/components/Chart/ScatterChart.tsx +111 -97
- package/src/components/Chart/TreemapChart.tsx +147 -222
- package/src/components/Chart/WaterfallChart.tsx +253 -291
- package/src/components/Chart/index.ts +11 -9
- package/src/components/Chart/types.ts +85 -9
- package/src/components/Chart/utils.ts +66 -0
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +6 -3
- package/src/components/Countdown/Countdown.tsx +4 -0
- package/src/components/DataTable/DataTable.tsx +2 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -11
- package/src/components/DatePicker/DatePicker.tsx +3 -9
- package/src/components/DatePicker/types.ts +5 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +32 -25
- package/src/components/Dropdown/Dropdown.tsx +26 -28
- package/src/components/EdgePanel/EdgePanel.stories.tsx +13 -15
- package/src/components/EdgePanel/EdgePanel.tsx +20 -5
- package/src/components/Footer/Footer.stories.tsx +187 -60
- package/src/components/Footer/Footer.test.tsx +134 -0
- package/src/components/Footer/Footer.tsx +133 -34
- package/src/components/Footer/FooterLink.tsx +1 -1
- package/src/components/Footer/FooterSection.tsx +53 -36
- package/src/components/Footer/FooterSocialLink.tsx +32 -29
- package/src/components/Footer/README.md +82 -3
- package/src/components/Footer/index.ts +1 -1
- package/src/components/Form/Checkbox.stories.tsx +13 -5
- package/src/components/Form/Checkbox.tsx +3 -6
- package/src/components/Form/Form.stories.tsx +10 -3
- package/src/components/Form/Form.tsx +2 -0
- package/src/components/Form/FormGroup.tsx +2 -1
- package/src/components/Form/Input.stories.tsx +12 -11
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +22 -7
- package/src/components/Form/Radio.tsx +3 -6
- package/src/components/Form/Select.stories.tsx +21 -6
- package/src/components/Form/Select.tsx +3 -5
- package/src/components/Form/Textarea.stories.tsx +13 -11
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/Hero/Hero.stories.tsx +2 -3
- package/src/components/Hero/Hero.tsx +5 -6
- package/src/components/Icon/Icon.tsx +12 -1
- package/src/components/List/List.tsx +2 -1
- package/src/components/List/ListGroup.tsx +2 -1
- package/src/components/Messages/Messages.tsx +3 -2
- package/src/components/Modal/Modal.stories.tsx +48 -34
- package/src/components/Modal/Modal.tsx +19 -23
- package/src/components/Navigation/Menu/MegaMenu.tsx +2 -2
- package/src/components/Navigation/Menu/Menu.tsx +2 -2
- package/src/components/Navigation/Nav/Nav.tsx +6 -1
- package/src/components/Navigation/Nav/NavDropdown.tsx +10 -1
- package/src/components/Navigation/Navbar/Navbar.tsx +4 -1
- package/src/components/Navigation/SideMenu/SideMenu.tsx +3 -2
- package/src/components/Pagination/Pagination.stories.tsx +13 -6
- package/src/components/Pagination/Pagination.tsx +7 -6
- package/src/components/PhotoViewer/PhotoViewer.tsx +2 -1
- package/src/components/Popover/Popover.stories.tsx +32 -24
- package/src/components/Popover/Popover.tsx +4 -1
- package/src/components/ProductReview/ProductReview.tsx +8 -2
- package/src/components/Progress/Progress.tsx +2 -1
- package/src/components/Rating/Rating.stories.tsx +11 -6
- package/src/components/Rating/Rating.tsx +3 -5
- package/src/components/River/River.tsx +5 -5
- package/src/components/SectionIntro/SectionIntro.tsx +8 -2
- package/src/components/Slider/Slider.stories.tsx +4 -4
- package/src/components/Slider/Slider.tsx +4 -3
- package/src/components/Spinner/Spinner.tsx +2 -1
- package/src/components/Steps/Steps.stories.tsx +5 -4
- package/src/components/Steps/Steps.tsx +8 -5
- package/src/components/Tab/Tab.stories.tsx +4 -3
- package/src/components/Tab/Tab.tsx +8 -6
- package/src/components/Testimonial/Testimonial.tsx +8 -2
- package/src/components/Todo/Todo.tsx +2 -1
- package/src/components/Toggle/Toggle.stories.tsx +5 -4
- package/src/components/Toggle/Toggle.tsx +8 -5
- package/src/components/Tooltip/Tooltip.stories.tsx +40 -30
- package/src/components/Tooltip/Tooltip.tsx +9 -2
- package/src/components/Upload/Upload.stories.tsx +252 -0
- package/src/components/Upload/Upload.tsx +92 -53
- package/src/components/VideoPlayer/VideoPlayer.tsx +3 -1
- package/src/components/index.ts +0 -4
- package/src/layouts/Grid/Grid.stories.tsx +10 -23
- package/src/layouts/Grid/Grid.tsx +20 -1
- package/src/layouts/Grid/GridCol.tsx +76 -48
- package/src/lib/composables/useAtomixGlass.ts +861 -44
- package/src/lib/composables/useBarChart.ts +13 -6
- package/src/lib/composables/useChart.ts +17 -13
- package/src/lib/composables/useChartExport.ts +19 -78
- package/src/lib/composables/useChartToolbar.ts +0 -1
- package/src/lib/composables/useEdgePanel.ts +111 -103
- package/src/lib/composables/useFooter.ts +3 -3
- package/src/lib/composables/useGlassContainer.ts +16 -7
- package/src/lib/composables/useLineChart.ts +8 -1
- package/src/lib/composables/useRiver.ts +5 -0
- package/src/lib/composables/useSlider.ts +62 -24
- package/src/lib/composables/useVideoPlayer.ts +60 -63
- package/src/lib/constants/components.ts +146 -32
- package/src/lib/types/components.ts +258 -10
- package/src/lib/utils/displacement-generator.ts +55 -49
- package/src/lib/utils/icons.ts +1 -1
- package/src/lib/utils/index.ts +16 -10
- package/src/styles/01-settings/_settings.accordion.scss +19 -19
- package/src/styles/01-settings/_settings.animations.scss +5 -5
- package/src/styles/01-settings/_settings.avatar-group.scss +1 -1
- package/src/styles/01-settings/_settings.avatar.scss +17 -17
- package/src/styles/01-settings/_settings.background.scss +1 -4
- package/src/styles/01-settings/_settings.badge.scss +1 -1
- package/src/styles/01-settings/_settings.breadcrumb.scss +1 -1
- package/src/styles/01-settings/_settings.card.scss +1 -1
- package/src/styles/01-settings/_settings.chart.scss +65 -2
- package/src/styles/01-settings/_settings.dropdown.scss +1 -1
- package/src/styles/01-settings/_settings.footer.scss +35 -42
- package/src/styles/01-settings/_settings.input.scss +1 -1
- package/src/styles/01-settings/_settings.list.scss +1 -1
- package/src/styles/01-settings/_settings.rating.scss +1 -1
- package/src/styles/01-settings/_settings.tabs.scss +1 -1
- package/src/styles/01-settings/_settings.upload.scss +6 -5
- package/src/styles/02-tools/_tools.animations.scss +4 -5
- package/src/styles/02-tools/_tools.background.scss +1 -13
- package/src/styles/02-tools/_tools.glass.scss +0 -1
- package/src/styles/02-tools/_tools.utility-api.scss +42 -34
- package/src/styles/03-generic/_generic.root.scss +1 -4
- package/src/styles/04-elements/_elements.body.scss +0 -1
- package/src/styles/06-components/_components.atomix-glass.scss +216 -39
- package/src/styles/06-components/_components.badge.scss +6 -8
- package/src/styles/06-components/_components.button.scss +8 -3
- package/src/styles/06-components/_components.card.scss +2 -14
- package/src/styles/06-components/_components.chart.scss +969 -1449
- package/src/styles/06-components/_components.dropdown.scss +19 -7
- package/src/styles/06-components/_components.edge-panel.scss +4 -2
- package/src/styles/06-components/_components.footer.scss +166 -85
- package/src/styles/06-components/_components.input.scss +8 -9
- package/src/styles/06-components/_components.list.scss +1 -0
- package/src/styles/06-components/_components.modal.scss +5 -3
- package/src/styles/06-components/_components.skeleton.scss +8 -6
- package/src/styles/06-components/_components.upload.scss +219 -4
- package/src/styles/06-components/old.chart.styles.scss +1 -30
- package/src/styles/99-utilities/_utilities.opacity.scss +1 -1
- package/src/styles/99-utilities/_utilities.scss +1 -1
- package/src/components/Chart/AdvancedChart.tsx +0 -624
- package/src/components/Chart/LineChartNew.tsx +0 -167
- package/src/components/Chart/RealTimeChart.tsx +0 -436
- package/src/components/DatePicker/DatePicker copy.tsx +0 -551
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { MousePosition, GlassSize } from '../../lib/types/components';
|
|
4
|
+
import { ATOMIX_GLASS } from '../../lib/constants/components';
|
|
5
|
+
|
|
6
|
+
const { CONSTANTS } = ATOMIX_GLASS;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Calculate distance between two points
|
|
10
|
+
*/
|
|
11
|
+
export const calculateDistance = (pos1: MousePosition, pos2: MousePosition): number => {
|
|
12
|
+
if (
|
|
13
|
+
!pos1 ||
|
|
14
|
+
!pos2 ||
|
|
15
|
+
typeof pos1.x !== 'number' ||
|
|
16
|
+
typeof pos1.y !== 'number' ||
|
|
17
|
+
typeof pos2.x !== 'number' ||
|
|
18
|
+
typeof pos2.y !== 'number'
|
|
19
|
+
) {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
const deltaX = pos1.x - pos2.x;
|
|
23
|
+
const deltaY = pos1.y - pos2.y;
|
|
24
|
+
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Calculate element center from bounding rect
|
|
29
|
+
*/
|
|
30
|
+
export const calculateElementCenter = (rect: DOMRect | null): MousePosition => {
|
|
31
|
+
if (!rect) {
|
|
32
|
+
return { x: 0, y: 0 };
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
x: rect.left + rect.width / 2,
|
|
36
|
+
y: rect.top + rect.height / 2,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Calculate mouse influence on glass effect with enhanced overlight support
|
|
42
|
+
*/
|
|
43
|
+
export const calculateMouseInfluence = (mouseOffset: MousePosition): number => {
|
|
44
|
+
if (!mouseOffset || typeof mouseOffset.x !== 'number' || typeof mouseOffset.y !== 'number') {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
// More responsive calculation for overlight effects
|
|
48
|
+
const influence = Math.sqrt(mouseOffset.x * mouseOffset.x + mouseOffset.y * mouseOffset.y) / CONSTANTS.MOUSE_INFLUENCE_DIVISOR;
|
|
49
|
+
return Math.min(1.5, influence); // Cap influence for better control
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Calculate overlight intensity based on background and mouse position
|
|
54
|
+
*/
|
|
55
|
+
export const calculateOverLightIntensity = (
|
|
56
|
+
mouseOffset: MousePosition,
|
|
57
|
+
baseIntensity: number
|
|
58
|
+
): number => {
|
|
59
|
+
if (!mouseOffset || typeof mouseOffset.x !== 'number' || typeof mouseOffset.y !== 'number') {
|
|
60
|
+
return baseIntensity;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Calculate additional intensity based on mouse position
|
|
64
|
+
const mouseInfluence = calculateMouseInfluence(mouseOffset);
|
|
65
|
+
return Math.min(1.0, baseIntensity * (1 + mouseInfluence * 0.3));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Clamp blur value to minimum and maximum with overlight consideration
|
|
70
|
+
*/
|
|
71
|
+
export const clampBlur = (value: number): number => {
|
|
72
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
73
|
+
return CONSTANTS.MIN_BLUR;
|
|
74
|
+
}
|
|
75
|
+
// Allow slightly higher blur for overlight effects
|
|
76
|
+
return Math.max(CONSTANTS.MIN_BLUR, Math.min(50, value));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Validate glass size dimensions
|
|
81
|
+
*/
|
|
82
|
+
export const validateGlassSize = (size: GlassSize): boolean => {
|
|
83
|
+
return (
|
|
84
|
+
size &&
|
|
85
|
+
typeof size.width === 'number' &&
|
|
86
|
+
typeof size.height === 'number' &&
|
|
87
|
+
size.width > 0 &&
|
|
88
|
+
size.height > 0 &&
|
|
89
|
+
size.width <= CONSTANTS.MAX_SIZE &&
|
|
90
|
+
size.height <= CONSTANTS.MAX_SIZE
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Parse border-radius value from string or number
|
|
96
|
+
*/
|
|
97
|
+
export const parseBorderRadiusValue = (value: string | number | undefined): number => {
|
|
98
|
+
if (typeof value === 'number') return Math.max(0, value);
|
|
99
|
+
if (typeof value !== 'string' || !value.trim()) return CONSTANTS.DEFAULT_CORNER_RADIUS;
|
|
100
|
+
|
|
101
|
+
const trimmedValue = value.trim();
|
|
102
|
+
|
|
103
|
+
// Handle px values
|
|
104
|
+
if (trimmedValue.endsWith('px')) {
|
|
105
|
+
const parsed = parseFloat(trimmedValue);
|
|
106
|
+
return isNaN(parsed) ? CONSTANTS.DEFAULT_CORNER_RADIUS : Math.max(0, parsed);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Handle rem values (assume 16px = 1rem)
|
|
110
|
+
if (trimmedValue.endsWith('rem')) {
|
|
111
|
+
const parsed = parseFloat(trimmedValue);
|
|
112
|
+
return isNaN(parsed) ? CONSTANTS.DEFAULT_CORNER_RADIUS : Math.max(0, parsed * 16);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Handle em values (assume 16px = 1em for simplicity)
|
|
116
|
+
if (trimmedValue.endsWith('em')) {
|
|
117
|
+
const parsed = parseFloat(trimmedValue);
|
|
118
|
+
return isNaN(parsed) ? CONSTANTS.DEFAULT_CORNER_RADIUS : Math.max(0, parsed * 16);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Handle percentage (convert to approximate px value, assuming 200px container)
|
|
122
|
+
if (trimmedValue.endsWith('%')) {
|
|
123
|
+
const parsed = parseFloat(trimmedValue);
|
|
124
|
+
return isNaN(parsed) ? CONSTANTS.DEFAULT_CORNER_RADIUS : Math.max(0, (parsed / 100) * 200);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Handle unitless numbers
|
|
128
|
+
const numValue = parseFloat(trimmedValue);
|
|
129
|
+
return isNaN(numValue) ? CONSTANTS.DEFAULT_CORNER_RADIUS : Math.max(0, numValue);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Extract border-radius from CSS style object
|
|
134
|
+
*/
|
|
135
|
+
export const extractBorderRadiusFromStyle = (style: CSSProperties | undefined): number | null => {
|
|
136
|
+
if (!style) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Check various border-radius properties
|
|
141
|
+
const borderRadius =
|
|
142
|
+
style.borderRadius ||
|
|
143
|
+
style.borderTopLeftRadius ||
|
|
144
|
+
style.borderTopRightRadius ||
|
|
145
|
+
style.borderBottomLeftRadius ||
|
|
146
|
+
style.borderBottomRightRadius;
|
|
147
|
+
|
|
148
|
+
if (borderRadius !== undefined) {
|
|
149
|
+
const parsed = parseBorderRadiusValue(borderRadius);
|
|
150
|
+
return parsed;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return null;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Extract border-radius from DOM element computed styles
|
|
158
|
+
*/
|
|
159
|
+
export const extractBorderRadiusFromDOMElement = (element: HTMLElement | null): number | null => {
|
|
160
|
+
if (!element || typeof window === 'undefined') {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
const computedStyles = window.getComputedStyle(element);
|
|
166
|
+
const borderRadius =
|
|
167
|
+
computedStyles.borderRadius ||
|
|
168
|
+
computedStyles.borderTopLeftRadius ||
|
|
169
|
+
computedStyles.borderTopRightRadius ||
|
|
170
|
+
computedStyles.borderBottomLeftRadius ||
|
|
171
|
+
computedStyles.borderBottomRightRadius;
|
|
172
|
+
|
|
173
|
+
if (borderRadius && borderRadius !== '0px' && borderRadius !== 'auto') {
|
|
174
|
+
const parsed = parseBorderRadiusValue(borderRadius);
|
|
175
|
+
return parsed > 0 ? parsed : null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return null;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Extract border-radius from React element
|
|
186
|
+
*/
|
|
187
|
+
export const extractBorderRadiusFromElement = (element: React.ReactElement): number | null => {
|
|
188
|
+
if (!element || !element.props) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Check inline styles first (highest priority)
|
|
193
|
+
if (element.props.style) {
|
|
194
|
+
const radiusFromStyle = extractBorderRadiusFromStyle(element.props.style);
|
|
195
|
+
if (radiusFromStyle !== null && radiusFromStyle > 0) {
|
|
196
|
+
return radiusFromStyle;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// If element has children, recursively check them
|
|
201
|
+
if (element.props.children) {
|
|
202
|
+
const childRadius = extractBorderRadiusFromChildren(element.props.children);
|
|
203
|
+
if (childRadius > 0 && childRadius !== CONSTANTS.DEFAULT_CORNER_RADIUS) {
|
|
204
|
+
return childRadius;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return null;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Extract border-radius from React children
|
|
213
|
+
*/
|
|
214
|
+
export const extractBorderRadiusFromChildren = (children: React.ReactNode): number => {
|
|
215
|
+
if (!children) {
|
|
216
|
+
return CONSTANTS.DEFAULT_CORNER_RADIUS;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
const childArray = React.Children.toArray(children);
|
|
221
|
+
|
|
222
|
+
for (let i = 0; i < childArray.length; i++) {
|
|
223
|
+
const child = childArray[i];
|
|
224
|
+
|
|
225
|
+
if (React.isValidElement(child)) {
|
|
226
|
+
const radius = extractBorderRadiusFromElement(child);
|
|
227
|
+
if (radius !== null) {
|
|
228
|
+
return radius;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
// Silently handle errors
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return CONSTANTS.DEFAULT_CORNER_RADIUS;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Get displacement map URL based on mode
|
|
241
|
+
*/
|
|
242
|
+
export const getDisplacementMap = (
|
|
243
|
+
mode: 'standard' | 'polar' | 'prominent' | 'shader',
|
|
244
|
+
displacementMap: string,
|
|
245
|
+
polarDisplacementMap: string,
|
|
246
|
+
prominentDisplacementMap: string,
|
|
247
|
+
shaderMapUrl?: string
|
|
248
|
+
): string => {
|
|
249
|
+
switch (mode) {
|
|
250
|
+
case 'standard':
|
|
251
|
+
return displacementMap;
|
|
252
|
+
case 'polar':
|
|
253
|
+
return polarDisplacementMap;
|
|
254
|
+
case 'prominent':
|
|
255
|
+
return prominentDisplacementMap;
|
|
256
|
+
case 'shader':
|
|
257
|
+
return shaderMapUrl || displacementMap;
|
|
258
|
+
default:
|
|
259
|
+
console.warn('AtomixGlass: Invalid displacement mode');
|
|
260
|
+
return displacementMap;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|