@shohojdhara/atomix 0.2.3 → 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 +1703 -1544
- package/dist/atomix.min.css +4 -4
- package/dist/index.d.ts +1465 -963
- package/dist/index.esm.js +16289 -25908
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15650 -21780
- 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 +1608 -1450
- package/dist/themes/boomdevs.min.css +5 -5
- package/dist/themes/esrar.css +1702 -1543
- package/dist/themes/esrar.min.css +4 -4
- package/dist/themes/flashtrade.css +15159 -0
- package/dist/themes/flashtrade.min.css +86 -0
- package/dist/themes/mashroom.css +1699 -1540
- package/dist/themes/mashroom.min.css +7 -7
- package/dist/themes/shaj-default.css +1693 -1534
- package/dist/themes/shaj-default.min.css +4 -4
- package/package.json +6 -17
- package/src/components/Accordion/Accordion.stories.tsx +662 -21
- package/src/components/Accordion/Accordion.tsx +21 -14
- package/src/components/AtomixGlass/AtomixGlass.test.tsx +106 -72
- package/src/components/AtomixGlass/AtomixGlass.tsx +529 -1195
- 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 +792 -68
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1250 -0
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +5768 -0
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +1065 -0
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +1129 -0
- package/src/components/AtomixGlass/stories/ShaderVariants.stories.tsx +395 -0
- package/src/components/AtomixGlass/stories/shared-components.tsx +301 -0
- 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 +76 -55
- package/src/components/Badge/Badge.tsx +12 -14
- package/src/components/Breadcrumb/Breadcrumb.tsx +23 -4
- package/src/components/Button/Button.stories.tsx +501 -20
- package/src/components/Button/Button.tsx +5 -8
- package/src/components/Callout/Callout.stories.tsx +86 -35
- package/src/components/Callout/Callout.tsx +31 -9
- package/src/components/Card/Card.stories.tsx +565 -2
- 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 +689 -12
- 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 +473 -2
- package/src/components/EdgePanel/EdgePanel.tsx +101 -13
- 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.stories.tsx +113 -0
- package/src/components/Messages/Messages.tsx +52 -9
- package/src/components/Modal/Modal.stories.tsx +48 -32
- package/src/components/Modal/Modal.tsx +19 -24
- package/src/components/Navigation/Menu/MegaMenu.tsx +2 -2
- package/src/components/Navigation/Menu/Menu.tsx +2 -2
- package/src/components/Navigation/Nav/Nav.stories.tsx +469 -0
- package/src/components/Navigation/Nav/Nav.tsx +22 -4
- package/src/components/Navigation/Nav/NavDropdown.tsx +10 -1
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +413 -0
- package/src/components/Navigation/Navbar/Navbar.tsx +70 -29
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +340 -0
- package/src/components/Navigation/SideMenu/SideMenu.tsx +29 -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 +19 -3
- 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 +19 -3
- 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 +21 -4
- package/src/lib/composables/useChart.ts +227 -370
- package/src/lib/composables/useChartExport.ts +19 -78
- package/src/lib/composables/useChartToolbar.ts +11 -21
- package/src/lib/composables/useEdgePanel.ts +125 -71
- package/src/lib/composables/useFooter.ts +3 -3
- package/src/lib/composables/useGlassContainer.ts +16 -7
- package/src/lib/composables/useLineChart.ts +11 -2
- package/src/lib/composables/usePieChart.ts +4 -14
- 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 +147 -32
- package/src/lib/types/components.ts +355 -25
- 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 +0 -3
- 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.edge-panel.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 +91 -48
- 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 +249 -0
- package/src/styles/06-components/_components.badge.scss +8 -23
- package/src/styles/06-components/_components.button.scss +8 -3
- package/src/styles/06-components/_components.callout.scss +10 -5
- 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 +103 -0
- 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.messages.scss +176 -0
- package/src/styles/06-components/_components.modal.scss +16 -4
- package/src/styles/06-components/_components.navbar.scss +12 -1
- package/src/styles/06-components/_components.side-menu.scss +5 -0
- 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/_index.scss +1 -0
- package/src/styles/99-utilities/_utilities.glass-fixes.scss +1 -0
- package/src/styles/99-utilities/_utilities.scss +1 -1
- package/src/components/AtomixGlass/AtomixGlass.stories.tsx +0 -3011
- package/src/components/AtomixGlass/AtomixGlassComprehensivePreview.stories.tsx +0 -1369
- 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
|
@@ -48,6 +48,11 @@ export interface AccordionProps extends BaseComponentProps {
|
|
|
48
48
|
* Can be a boolean to enable with default settings, or an object with AtomixGlassProps to customize the effect
|
|
49
49
|
*/
|
|
50
50
|
glass?: AtomixGlassProps | boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Custom style for the accordion
|
|
54
|
+
*/
|
|
55
|
+
style?: React.CSSProperties;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
export const Accordion: React.FC<AccordionProps> = ({
|
|
@@ -60,6 +65,7 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
60
65
|
iconPosition = 'right',
|
|
61
66
|
icon,
|
|
62
67
|
className = '',
|
|
68
|
+
style,
|
|
63
69
|
glass,
|
|
64
70
|
}) => {
|
|
65
71
|
// Generate unique IDs for accessibility
|
|
@@ -86,7 +92,7 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
86
92
|
|
|
87
93
|
// Default icon
|
|
88
94
|
const defaultIcon = (
|
|
89
|
-
<i className="c-accordion__icon">
|
|
95
|
+
<i className="c-accordion__icon" aria-hidden="true">
|
|
90
96
|
<svg
|
|
91
97
|
xmlns="http://www.w3.org/2000/svg"
|
|
92
98
|
width="24"
|
|
@@ -97,6 +103,8 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
97
103
|
strokeWidth="2"
|
|
98
104
|
strokeLinecap="round"
|
|
99
105
|
strokeLinejoin="round"
|
|
106
|
+
aria-hidden="true"
|
|
107
|
+
focusable="false"
|
|
100
108
|
>
|
|
101
109
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
102
110
|
</svg>
|
|
@@ -104,13 +112,17 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
104
112
|
);
|
|
105
113
|
|
|
106
114
|
const accordionContent = (
|
|
107
|
-
<div
|
|
115
|
+
<div
|
|
116
|
+
className={generateClassNames(className) + (glass ? ' c-accordion--glass' : '')}
|
|
117
|
+
style={style}
|
|
118
|
+
>
|
|
108
119
|
<button
|
|
109
120
|
id={buttonId}
|
|
110
121
|
className={generateHeaderClassNames()}
|
|
111
122
|
onClick={toggle}
|
|
112
123
|
aria-expanded={state.isOpen}
|
|
113
124
|
aria-controls={panelId}
|
|
125
|
+
aria-disabled={disabled}
|
|
114
126
|
disabled={disabled}
|
|
115
127
|
type="button"
|
|
116
128
|
>
|
|
@@ -120,11 +132,14 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
120
132
|
<div
|
|
121
133
|
id={panelId}
|
|
122
134
|
className={ACCORDION.SELECTORS.PANEL.replace('.', '')}
|
|
123
|
-
ref={panelRef}
|
|
135
|
+
ref={panelRef as React.RefObject<HTMLDivElement>}
|
|
124
136
|
role="region"
|
|
125
137
|
aria-labelledby={buttonId}
|
|
126
138
|
>
|
|
127
|
-
<div
|
|
139
|
+
<div
|
|
140
|
+
className={ACCORDION.SELECTORS.BODY.replace('.', '')}
|
|
141
|
+
ref={contentRef as React.RefObject<HTMLDivElement>}
|
|
142
|
+
>
|
|
128
143
|
{children}
|
|
129
144
|
</div>
|
|
130
145
|
</div>
|
|
@@ -135,20 +150,12 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
135
150
|
// Default glass settings for accordions
|
|
136
151
|
const defaultGlassProps = {
|
|
137
152
|
displacementScale: 20,
|
|
138
|
-
|
|
139
|
-
saturation: 140,
|
|
140
|
-
aberrationIntensity: 0.5,
|
|
141
|
-
cornerRadius: 8,
|
|
142
|
-
mode: 'shader' as const,
|
|
153
|
+
elasticity: 0,
|
|
143
154
|
};
|
|
144
155
|
|
|
145
156
|
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
146
157
|
|
|
147
|
-
return
|
|
148
|
-
<AtomixGlass {...glassProps}>
|
|
149
|
-
{accordionContent}
|
|
150
|
-
</AtomixGlass>
|
|
151
|
-
);
|
|
158
|
+
return <AtomixGlass {...glassProps}>{accordionContent}</AtomixGlass>;
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
return accordionContent;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { vi } from 'vitest';
|
|
4
5
|
import AtomixGlass from './AtomixGlass';
|
|
5
6
|
|
|
6
7
|
// Mock the ShaderDisplacementGenerator since it uses browser APIs
|
|
7
|
-
|
|
8
|
+
vi.mock('./shader-utils', () => ({
|
|
8
9
|
ShaderDisplacementGenerator: class MockShaderDisplacementGenerator {
|
|
9
10
|
updateShader() {
|
|
10
11
|
return 'data:image/png;base64,mockBase64String';
|
|
@@ -12,7 +13,7 @@ jest.mock('./shader-utils', () => ({
|
|
|
12
13
|
destroy() {}
|
|
13
14
|
},
|
|
14
15
|
fragmentShaders: {
|
|
15
|
-
liquidGlass:
|
|
16
|
+
liquidGlass: vi.fn(),
|
|
16
17
|
},
|
|
17
18
|
}));
|
|
18
19
|
|
|
@@ -23,7 +24,7 @@ describe('AtomixGlass Component', () => {
|
|
|
23
24
|
<div data-testid="test-content">Test Content</div>
|
|
24
25
|
</AtomixGlass>
|
|
25
26
|
);
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
expect(screen.getByTestId('test-content')).toBeInTheDocument();
|
|
28
29
|
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
29
30
|
});
|
|
@@ -34,40 +35,42 @@ describe('AtomixGlass Component', () => {
|
|
|
34
35
|
<div>Content</div>
|
|
35
36
|
</AtomixGlass>
|
|
36
37
|
);
|
|
37
|
-
|
|
38
|
-
expect(container.querySelector('.c-
|
|
38
|
+
|
|
39
|
+
expect(container.querySelector('.c-atomix-glass__container')).toHaveClass('custom-class');
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
test('renders with showHoverEffects enabled', () => {
|
|
42
43
|
render(
|
|
43
|
-
<AtomixGlass
|
|
44
|
+
<AtomixGlass>
|
|
44
45
|
<div>Test Content</div>
|
|
45
46
|
</AtomixGlass>
|
|
46
47
|
);
|
|
47
|
-
|
|
48
|
+
|
|
48
49
|
// Check that hover effects are enabled
|
|
49
50
|
expect(screen.getByTestId('atomix-glass')).toHaveAttribute('data-hover-effects', 'true');
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
test('applies clickable class when onClick is provided', () => {
|
|
53
|
-
const handleClick =
|
|
54
|
+
const handleClick = vi.fn();
|
|
54
55
|
const { container } = render(
|
|
55
56
|
<AtomixGlass onClick={handleClick}>
|
|
56
57
|
<div>Content</div>
|
|
57
58
|
</AtomixGlass>
|
|
58
59
|
);
|
|
59
|
-
|
|
60
|
-
expect(container.querySelector('.c-
|
|
60
|
+
|
|
61
|
+
expect(container.querySelector('.c-atomix-glass__container')).toHaveClass(
|
|
62
|
+
'c-atomix-glass__container--clickable'
|
|
63
|
+
);
|
|
61
64
|
});
|
|
62
65
|
|
|
63
66
|
test('calls onClick when clicked', async () => {
|
|
64
|
-
const handleClick =
|
|
67
|
+
const handleClick = vi.fn();
|
|
65
68
|
render(
|
|
66
69
|
<AtomixGlass onClick={handleClick}>
|
|
67
70
|
<div>Content</div>
|
|
68
71
|
</AtomixGlass>
|
|
69
72
|
);
|
|
70
|
-
|
|
73
|
+
|
|
71
74
|
await userEvent.click(screen.getByText('Content'));
|
|
72
75
|
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
73
76
|
});
|
|
@@ -78,8 +81,82 @@ describe('AtomixGlass Component', () => {
|
|
|
78
81
|
<div>Content</div>
|
|
79
82
|
</AtomixGlass>
|
|
80
83
|
);
|
|
81
|
-
|
|
82
|
-
expect(container.querySelector('.c-
|
|
84
|
+
|
|
85
|
+
expect(container.querySelector('.c-atomix-glass__container')).toHaveClass(
|
|
86
|
+
'c-atomix-glass__container--over-light'
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('does not apply overLight class when overLight prop is false', () => {
|
|
91
|
+
const { container } = render(
|
|
92
|
+
<AtomixGlass overLight={false}>
|
|
93
|
+
<div>Content</div>
|
|
94
|
+
</AtomixGlass>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(container.querySelector('.c-atomix-glass__container')).not.toHaveClass(
|
|
98
|
+
'c-atomix-glass__container--over-light'
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('handles overLight="auto" mode', () => {
|
|
103
|
+
// Mock window.getComputedStyle to simulate a light background
|
|
104
|
+
const originalGetComputedStyle = window.getComputedStyle;
|
|
105
|
+
window.getComputedStyle = vi.fn(() => ({
|
|
106
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
107
|
+
backgroundImage: 'none',
|
|
108
|
+
})) as any;
|
|
109
|
+
|
|
110
|
+
const { container } = render(
|
|
111
|
+
<AtomixGlass overLight="auto">
|
|
112
|
+
<div>Content</div>
|
|
113
|
+
</AtomixGlass>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Note: Auto-detection happens asynchronously, so we can't immediately test
|
|
117
|
+
// but we can verify the component renders without errors
|
|
118
|
+
expect(container.querySelector('.c-atomix-glass__container')).toBeInTheDocument();
|
|
119
|
+
|
|
120
|
+
// Restore original
|
|
121
|
+
window.getComputedStyle = originalGetComputedStyle;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('handles overLight object config', () => {
|
|
125
|
+
const { container } = render(
|
|
126
|
+
<AtomixGlass
|
|
127
|
+
overLight={{
|
|
128
|
+
threshold: 0.8,
|
|
129
|
+
opacity: 0.5,
|
|
130
|
+
contrast: 1.5,
|
|
131
|
+
brightness: 1.1,
|
|
132
|
+
saturationBoost: 1.8,
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<div>Content</div>
|
|
136
|
+
</AtomixGlass>
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// Verify component renders with object config
|
|
140
|
+
expect(container.querySelector('.c-atomix-glass__container')).toBeInTheDocument();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('handles invalid overLight object config values gracefully', () => {
|
|
144
|
+
const { container } = render(
|
|
145
|
+
<AtomixGlass
|
|
146
|
+
overLight={{
|
|
147
|
+
threshold: NaN,
|
|
148
|
+
opacity: -1,
|
|
149
|
+
contrast: Infinity,
|
|
150
|
+
brightness: -100,
|
|
151
|
+
saturationBoost: 'invalid' as any,
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<div>Content</div>
|
|
155
|
+
</AtomixGlass>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// Should render without errors, using default/validated values
|
|
159
|
+
expect(container.querySelector('.c-atomix-glass__container')).toBeInTheDocument();
|
|
83
160
|
});
|
|
84
161
|
|
|
85
162
|
test('applies custom style', () => {
|
|
@@ -89,8 +166,8 @@ describe('AtomixGlass Component', () => {
|
|
|
89
166
|
<div>Content</div>
|
|
90
167
|
</AtomixGlass>
|
|
91
168
|
);
|
|
92
|
-
|
|
93
|
-
const glassContainer = container.querySelector('.c-
|
|
169
|
+
|
|
170
|
+
const glassContainer = container.querySelector('.c-atomix-glass__container');
|
|
94
171
|
expect(glassContainer).toHaveStyle('background-color: red');
|
|
95
172
|
});
|
|
96
173
|
|
|
@@ -100,17 +177,17 @@ describe('AtomixGlass Component', () => {
|
|
|
100
177
|
<div>Content</div>
|
|
101
178
|
</AtomixGlass>
|
|
102
179
|
);
|
|
103
|
-
|
|
180
|
+
|
|
104
181
|
// Check if the filter element exists
|
|
105
182
|
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
106
183
|
});
|
|
107
184
|
|
|
108
185
|
test('handles mouse events correctly', async () => {
|
|
109
|
-
const handleMouseEnter =
|
|
110
|
-
const handleMouseLeave =
|
|
111
|
-
const handleMouseDown =
|
|
112
|
-
const handleMouseUp =
|
|
113
|
-
|
|
186
|
+
const handleMouseEnter = vi.fn();
|
|
187
|
+
const handleMouseLeave = vi.fn();
|
|
188
|
+
const handleMouseDown = vi.fn();
|
|
189
|
+
const handleMouseUp = vi.fn();
|
|
190
|
+
|
|
114
191
|
render(
|
|
115
192
|
<AtomixGlass
|
|
116
193
|
onClick={() => {
|
|
@@ -123,25 +200,26 @@ describe('AtomixGlass Component', () => {
|
|
|
123
200
|
<div>Content</div>
|
|
124
201
|
</AtomixGlass>
|
|
125
202
|
);
|
|
126
|
-
|
|
203
|
+
|
|
127
204
|
const glassContent = screen.getByText('Content').parentElement;
|
|
128
205
|
if (!glassContent) throw new Error('Glass content not found');
|
|
129
|
-
|
|
206
|
+
|
|
130
207
|
await userEvent.hover(glassContent);
|
|
131
208
|
expect(handleMouseEnter).toHaveBeenCalledTimes(1);
|
|
132
|
-
|
|
209
|
+
|
|
133
210
|
await userEvent.unhover(glassContent);
|
|
134
211
|
expect(handleMouseLeave).toHaveBeenCalledTimes(1);
|
|
135
|
-
|
|
212
|
+
|
|
136
213
|
await userEvent.pointer([{ keys: '[MouseLeft>]', target: glassContent }]);
|
|
137
214
|
expect(handleMouseDown).toHaveBeenCalledTimes(1);
|
|
138
|
-
|
|
215
|
+
|
|
139
216
|
await userEvent.pointer([{ keys: '[/MouseLeft]', target: glassContent }]);
|
|
140
217
|
expect(handleMouseUp).toHaveBeenCalledTimes(1);
|
|
141
218
|
});
|
|
142
219
|
});
|
|
143
220
|
|
|
144
221
|
// Visual regression tests
|
|
222
|
+
// Keep only a single smoke snapshot to detect catastrophic DOM changes.
|
|
145
223
|
describe('AtomixGlass Visual Regression', () => {
|
|
146
224
|
test('matches snapshot with default props', () => {
|
|
147
225
|
const { container } = render(
|
|
@@ -149,51 +227,7 @@ describe('AtomixGlass Visual Regression', () => {
|
|
|
149
227
|
<div>Default Glass</div>
|
|
150
228
|
</AtomixGlass>
|
|
151
229
|
);
|
|
152
|
-
|
|
153
|
-
expect(container).toMatchSnapshot();
|
|
154
|
-
});
|
|
155
230
|
|
|
156
|
-
test('matches snapshot with custom props', () => {
|
|
157
|
-
const { container } = render(
|
|
158
|
-
<AtomixGlass
|
|
159
|
-
displacementScale={30}
|
|
160
|
-
blurAmount={15}
|
|
161
|
-
saturation={200}
|
|
162
|
-
aberrationIntensity={3}
|
|
163
|
-
cornerRadius={15}
|
|
164
|
-
overLight={true}
|
|
165
|
-
mode="polar"
|
|
166
|
-
>
|
|
167
|
-
<div>Custom Glass</div>
|
|
168
|
-
</AtomixGlass>
|
|
169
|
-
);
|
|
170
|
-
|
|
171
231
|
expect(container).toMatchSnapshot();
|
|
172
232
|
});
|
|
173
|
-
|
|
174
|
-
test('matches snapshot with shader mode', () => {
|
|
175
|
-
const { container } = render(
|
|
176
|
-
<AtomixGlass
|
|
177
|
-
mode="shader"
|
|
178
|
-
displacementScale={25}
|
|
179
|
-
blurAmount={12}
|
|
180
|
-
saturation={180}
|
|
181
|
-
aberrationIntensity={2}
|
|
182
|
-
>
|
|
183
|
-
<div>Shader Glass</div>
|
|
184
|
-
</AtomixGlass>
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
expect(container).toMatchSnapshot();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
test('matches snapshot with showHoverEffects', () => {
|
|
191
|
-
const { container } = render(
|
|
192
|
-
<AtomixGlass showHoverEffects={true}>
|
|
193
|
-
<div>Glass with Hover Effects</div>
|
|
194
|
-
</AtomixGlass>
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
expect(container).toMatchSnapshot();
|
|
198
|
-
});
|
|
199
|
-
});
|
|
233
|
+
});
|