@shohojdhara/atomix 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atomix.css +9341 -9249
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +4 -4
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.d.ts +12 -19
- package/dist/charts.js +555 -358
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +16 -23
- package/dist/core.js +418 -262
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +11 -18
- package/dist/forms.js +411 -257
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +14 -21
- package/dist/heavy.js +408 -254
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +33 -40
- package/dist/index.esm.js +663 -453
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +667 -460
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/scripts/atomix-cli.js +34 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +82 -54
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +17 -18
- package/src/components/AtomixGlass/README.md +5 -5
- package/src/components/AtomixGlass/stories/Customization.stories.tsx +2 -2
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +42 -42
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +5 -5
- package/src/components/AtomixGlass/stories/Overview.stories.tsx +3 -3
- package/src/components/AtomixGlass/stories/Performance.stories.tsx +2 -2
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +45 -45
- package/src/components/AtomixGlass/stories/Shaders.stories.tsx +3 -3
- package/src/components/Badge/Badge.stories.tsx +1 -1
- package/src/components/Badge/Badge.tsx +1 -1
- package/src/components/Breadcrumb/Breadcrumb.tsx +90 -76
- package/src/components/Breadcrumb/index.ts +2 -2
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/Button/README.md +2 -2
- package/src/components/Callout/Callout.test.tsx +3 -3
- package/src/components/Callout/Callout.tsx +2 -2
- package/src/components/Callout/README.md +2 -2
- package/src/components/Chart/Chart.stories.tsx +1 -1
- package/src/components/Chart/Chart.tsx +5 -5
- package/src/components/Chart/TreemapChart.tsx +37 -29
- package/src/components/DatePicker/readme.md +3 -3
- package/src/components/Dropdown/Dropdown.stories.tsx +1 -1
- package/src/components/EdgePanel/EdgePanel.stories.tsx +7 -7
- package/src/components/Form/Checkbox.stories.tsx +1 -1
- package/src/components/Form/Checkbox.tsx +1 -1
- package/src/components/Form/Input.stories.tsx +1 -1
- package/src/components/Form/Input.tsx +1 -1
- package/src/components/Form/Radio.stories.tsx +1 -1
- package/src/components/Form/Radio.tsx +1 -1
- package/src/components/Form/Select.stories.tsx +1 -1
- package/src/components/Form/Select.tsx +1 -1
- package/src/components/Form/Textarea.stories.tsx +1 -1
- package/src/components/Form/Textarea.tsx +1 -1
- package/src/components/Hero/Hero.stories.tsx +2 -2
- package/src/components/Hero/Hero.tsx +2 -2
- package/src/components/Messages/Messages.stories.tsx +1 -1
- package/src/components/Messages/Messages.tsx +2 -2
- package/src/components/Modal/Modal.stories.tsx +1 -1
- package/src/components/Navigation/Nav/Nav.stories.tsx +2 -2
- package/src/components/Navigation/Nav/Nav.tsx +1 -1
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +3 -3
- package/src/components/Navigation/Navbar/Navbar.tsx +1 -1
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +2 -2
- package/src/components/Navigation/SideMenu/SideMenu.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/Progress/Progress.tsx +1 -1
- package/src/components/Rating/Rating.stories.tsx +1 -1
- package/src/components/Rating/Rating.test.tsx +73 -0
- package/src/components/Rating/Rating.tsx +25 -37
- package/src/components/Spinner/Spinner.tsx +1 -1
- package/src/components/Steps/Steps.stories.tsx +1 -1
- package/src/components/Steps/Steps.tsx +2 -2
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +1 -1
- package/src/components/Todo/Todo.tsx +0 -1
- package/src/components/Toggle/Toggle.stories.tsx +1 -1
- package/src/components/Toggle/Toggle.tsx +1 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +2 -2
- package/src/lib/composables/__tests__/useAtomixGlassPerf.test.tsx +88 -0
- package/src/lib/composables/__tests__/useChart.test.ts +50 -0
- package/src/lib/composables/__tests__/useChart.test.tsx +139 -0
- package/src/lib/composables/__tests__/useHeroBackgroundSlider.test.tsx +59 -0
- package/src/lib/composables/__tests__/useSliderAutoplay.test.tsx +68 -0
- package/src/lib/composables/atomix-glass/useGlassBackgroundDetection.ts +329 -0
- package/src/lib/composables/atomix-glass/useGlassCornerRadius.ts +82 -0
- package/src/lib/composables/atomix-glass/useGlassMouseTracking.ts +153 -0
- package/src/lib/composables/atomix-glass/useGlassOverLight.ts +198 -0
- package/src/lib/composables/atomix-glass/useGlassSize.ts +117 -0
- package/src/lib/composables/atomix-glass/useGlassState.ts +112 -0
- package/src/lib/composables/atomix-glass/useGlassTransforms.ts +160 -0
- package/src/lib/composables/glass-styles.ts +302 -0
- package/src/lib/composables/index.ts +0 -4
- package/src/lib/composables/useAtomixGlass.ts +331 -522
- package/src/lib/composables/useAtomixGlassStyles.ts +307 -0
- package/src/lib/composables/useBarChart.ts +1 -1
- package/src/lib/composables/useBreadcrumb.ts +6 -6
- package/src/lib/composables/useChart.ts +104 -21
- package/src/lib/composables/useHeroBackgroundSlider.ts +16 -7
- package/src/lib/composables/useSlider.ts +66 -34
- package/src/lib/theme/devtools/CLI.ts +1 -1
- package/src/lib/theme/utils/__tests__/themeUtils.test.ts +213 -0
- package/src/lib/types/components.ts +13 -21
- package/src/lib/utils/__tests__/dom.test.ts +100 -0
- package/src/lib/utils/__tests__/fontPreloader.test.ts +102 -0
- package/src/styles/02-tools/_tools.breakpoints.scss +1 -1
- package/src/styles/02-tools/_tools.utility-api.scss +6 -6
- package/src/styles/06-components/_components.accordion.scss +0 -2
- package/src/styles/06-components/_components.chart.scss +0 -1
- package/src/styles/06-components/_components.dropdown.scss +0 -1
- package/src/styles/06-components/_components.edge-panel.scss +0 -2
- package/src/styles/06-components/_components.photoviewer.scss +0 -1
- package/src/styles/06-components/_components.river.scss +0 -1
- package/src/styles/06-components/_components.slider.scss +0 -3
- package/src/styles/99-utilities/_utilities.glass-fixes.scss +0 -1
- package/src/styles/99-utilities/_utilities.text.scss +1 -0
|
@@ -98,21 +98,25 @@ interface TreemapChartProps extends Omit<ChartProps, 'type' | 'datasets'> {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
const DEFAULT_COLOR_CONFIG: NonNullable<TreemapChartProps['colorConfig']> = { scheme: 'category' };
|
|
102
|
+
const DEFAULT_LABEL_CONFIG = {
|
|
103
|
+
showLabels: true,
|
|
104
|
+
minSize: 1000,
|
|
105
|
+
fontSize: 12,
|
|
106
|
+
textColor: 'white',
|
|
107
|
+
};
|
|
108
|
+
const DEFAULT_CONFIG = {};
|
|
109
|
+
|
|
101
110
|
const TreemapChart = memo(
|
|
102
111
|
forwardRef<HTMLDivElement, TreemapChartProps>(
|
|
103
112
|
(
|
|
104
113
|
{
|
|
105
114
|
data = [],
|
|
106
115
|
algorithm = 'squarified',
|
|
107
|
-
colorConfig =
|
|
108
|
-
labelConfig =
|
|
109
|
-
showLabels: true,
|
|
110
|
-
minSize: 1000,
|
|
111
|
-
fontSize: 12,
|
|
112
|
-
textColor: 'white',
|
|
113
|
-
},
|
|
116
|
+
colorConfig = DEFAULT_COLOR_CONFIG,
|
|
117
|
+
labelConfig = DEFAULT_LABEL_CONFIG,
|
|
114
118
|
onDataPointClick,
|
|
115
|
-
config =
|
|
119
|
+
config = DEFAULT_CONFIG,
|
|
116
120
|
...props
|
|
117
121
|
},
|
|
118
122
|
ref
|
|
@@ -122,9 +126,7 @@ const TreemapChart = memo(
|
|
|
122
126
|
const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 });
|
|
123
127
|
|
|
124
128
|
const treeData = useMemo(() => {
|
|
125
|
-
console.log('TreemapChart data:', data);
|
|
126
129
|
if (!data.length) {
|
|
127
|
-
console.log('No data provided to TreemapChart');
|
|
128
130
|
return null;
|
|
129
131
|
}
|
|
130
132
|
|
|
@@ -357,16 +359,17 @@ const TreemapChart = memo(
|
|
|
357
359
|
[]
|
|
358
360
|
);
|
|
359
361
|
|
|
360
|
-
const renderContent = (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
362
|
+
const renderContent = useCallback(
|
|
363
|
+
({
|
|
364
|
+
scales,
|
|
365
|
+
colors,
|
|
366
|
+
datasets: renderedDatasets,
|
|
367
|
+
handlers,
|
|
368
|
+
hoveredPoint,
|
|
369
|
+
}: ChartRenderContentParams) => {
|
|
370
|
+
if (!data.length) return null;
|
|
371
|
+
|
|
372
|
+
// Calculate available space with padding
|
|
370
373
|
const padding = 20;
|
|
371
374
|
const availableWidth = scales.width - padding * 2;
|
|
372
375
|
const availableHeight = scales.height - padding * 2;
|
|
@@ -467,17 +470,22 @@ const TreemapChart = memo(
|
|
|
467
470
|
</g>
|
|
468
471
|
);
|
|
469
472
|
})}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
+
</>
|
|
474
|
+
);
|
|
475
|
+
},
|
|
476
|
+
[data, algorithm, generateColor, squarify, labelConfig, hoveredNode, selectedNode]
|
|
477
|
+
);
|
|
473
478
|
|
|
474
479
|
// Convert data to datasets format for BaseChart
|
|
475
|
-
const datasets =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
480
|
+
const datasets = useMemo(
|
|
481
|
+
() => [
|
|
482
|
+
{
|
|
483
|
+
label: 'Treemap Data',
|
|
484
|
+
data: data,
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
[data]
|
|
488
|
+
);
|
|
481
489
|
|
|
482
490
|
return (
|
|
483
491
|
<BaseChart
|
|
@@ -152,7 +152,7 @@ const CustomGlassExample = () => {
|
|
|
152
152
|
blurAmount: 0,
|
|
153
153
|
saturation: 180,
|
|
154
154
|
aberrationIntensity: 2,
|
|
155
|
-
|
|
155
|
+
borderRadius: 16,
|
|
156
156
|
overLight: false,
|
|
157
157
|
mode: 'polar',
|
|
158
158
|
}}
|
|
@@ -184,7 +184,7 @@ const GlassRangeExample = () => {
|
|
|
184
184
|
blurAmount: 0,
|
|
185
185
|
saturation: 160,
|
|
186
186
|
aberrationIntensity: 1.5,
|
|
187
|
-
|
|
187
|
+
borderRadius: 14,
|
|
188
188
|
mode: 'prominent',
|
|
189
189
|
}}
|
|
190
190
|
/>
|
|
@@ -203,7 +203,7 @@ When `glass` is an object, it accepts the same props as the `AtomixGlass` compon
|
|
|
203
203
|
| `blurAmount` | `number` | `0` | Blur amount for the backdrop |
|
|
204
204
|
| `saturation` | `number` | `160` | Saturation percentage for the backdrop |
|
|
205
205
|
| `aberrationIntensity` | `number` | `1.5` | Chromatic aberration intensity |
|
|
206
|
-
| `
|
|
206
|
+
| `borderRadius` | `number` | `12` | Corner radius in pixels |
|
|
207
207
|
| `overLight` | `boolean` | `false` | Whether the glass is over a light background |
|
|
208
208
|
| `mode` | `'standard' \| 'polar' \| 'prominent' \| 'shader'` | `'standard'` | Glass effect mode |
|
|
209
209
|
|
|
@@ -627,7 +627,7 @@ export const GlassCustom: Story = {
|
|
|
627
627
|
displacementScale: 70,
|
|
628
628
|
blurAmount: 1.8,
|
|
629
629
|
saturation: 170,
|
|
630
|
-
|
|
630
|
+
borderRadius: 0,
|
|
631
631
|
} as any
|
|
632
632
|
}
|
|
633
633
|
>
|
|
@@ -693,7 +693,7 @@ export const GlassPremium: Story = {
|
|
|
693
693
|
displacementScale: 180,
|
|
694
694
|
blurAmount: 1,
|
|
695
695
|
saturation: 60,
|
|
696
|
-
|
|
696
|
+
borderRadius: 0,
|
|
697
697
|
} as any
|
|
698
698
|
}
|
|
699
699
|
>
|
|
@@ -786,7 +786,7 @@ export const GlassShowcase: Story = {
|
|
|
786
786
|
displacementScale: 25,
|
|
787
787
|
blurAmount: 1.2,
|
|
788
788
|
saturation: 140,
|
|
789
|
-
|
|
789
|
+
borderRadius: 0,
|
|
790
790
|
} as any
|
|
791
791
|
}
|
|
792
792
|
>
|
|
@@ -815,7 +815,7 @@ export const GlassShowcase: Story = {
|
|
|
815
815
|
displacementScale: 35,
|
|
816
816
|
blurAmount: 1.5,
|
|
817
817
|
saturation: 160,
|
|
818
|
-
|
|
818
|
+
borderRadius: 0,
|
|
819
819
|
} as any
|
|
820
820
|
}
|
|
821
821
|
>
|
|
@@ -844,7 +844,7 @@ export const GlassShowcase: Story = {
|
|
|
844
844
|
displacementScale: 50,
|
|
845
845
|
blurAmount: 2,
|
|
846
846
|
saturation: 180,
|
|
847
|
-
|
|
847
|
+
borderRadius: 0,
|
|
848
848
|
} as any
|
|
849
849
|
}
|
|
850
850
|
>
|
|
@@ -874,7 +874,7 @@ export const GlassShowcase: Story = {
|
|
|
874
874
|
displacementScale: 70,
|
|
875
875
|
blurAmount: 1.8,
|
|
876
876
|
saturation: 170,
|
|
877
|
-
|
|
877
|
+
borderRadius: 0,
|
|
878
878
|
} as any
|
|
879
879
|
}
|
|
880
880
|
>
|
|
@@ -907,7 +907,7 @@ export const GlassShowcase: Story = {
|
|
|
907
907
|
displacementScale: 180,
|
|
908
908
|
blurAmount: 1,
|
|
909
909
|
saturation: 60,
|
|
910
|
-
|
|
910
|
+
borderRadius: 0,
|
|
911
911
|
} as any
|
|
912
912
|
}
|
|
913
913
|
>
|
|
@@ -117,7 +117,7 @@ export const Checkbox = React.memo(
|
|
|
117
117
|
blurAmount: 1,
|
|
118
118
|
saturation: 160,
|
|
119
119
|
aberrationIntensity: 0.3,
|
|
120
|
-
|
|
120
|
+
borderRadius: 6,
|
|
121
121
|
mode: 'shader' as const,
|
|
122
122
|
};
|
|
123
123
|
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
@@ -433,7 +433,7 @@ export const WithCustomGlassEffect: Story = {
|
|
|
433
433
|
blurAmount: -0.1,
|
|
434
434
|
saturation: 130,
|
|
435
435
|
aberrationIntensity: 0,
|
|
436
|
-
|
|
436
|
+
borderRadius: 45,
|
|
437
437
|
mode: 'standard',
|
|
438
438
|
elasticity: 0.2,
|
|
439
439
|
onClick: () => {
|
|
@@ -911,7 +911,7 @@ export const PremiumShowcase: Story = {
|
|
|
911
911
|
blurAmount: 2,
|
|
912
912
|
saturation: 150,
|
|
913
913
|
aberrationIntensity: 0.5,
|
|
914
|
-
|
|
914
|
+
borderRadius: 20,
|
|
915
915
|
overLight: true,
|
|
916
916
|
mode: 'standard',
|
|
917
917
|
},
|
|
@@ -55,7 +55,7 @@ const HeroContent = ({ children, className, style, glass, ...props }: HeroConten
|
|
|
55
55
|
blurAmount: 3,
|
|
56
56
|
saturation: 180,
|
|
57
57
|
aberrationIntensity: 0,
|
|
58
|
-
|
|
58
|
+
borderRadius: 8,
|
|
59
59
|
overLight: false,
|
|
60
60
|
mode: 'standard' as const,
|
|
61
61
|
} : glass;
|
|
@@ -389,7 +389,7 @@ export const Hero: React.FC<HeroProps> & {
|
|
|
389
389
|
blurAmount={3}
|
|
390
390
|
saturation={180}
|
|
391
391
|
aberrationIntensity={0}
|
|
392
|
-
|
|
392
|
+
borderRadius={8}
|
|
393
393
|
overLight={false}
|
|
394
394
|
mode="standard"
|
|
395
395
|
>
|
|
@@ -35,7 +35,7 @@ export const Messages: React.FC<MessagesProps> = ({
|
|
|
35
35
|
// Default glass settings for messages
|
|
36
36
|
const defaultGlassProps = {
|
|
37
37
|
displacementScale: 150,
|
|
38
|
-
|
|
38
|
+
borderRadius: 12,
|
|
39
39
|
elasticity: 0,
|
|
40
40
|
aberrationIntensity: 2,
|
|
41
41
|
};
|
|
@@ -185,7 +185,7 @@ export const Messages: React.FC<MessagesProps> = ({
|
|
|
185
185
|
<AtomixGlass {...glassProps}>
|
|
186
186
|
<div
|
|
187
187
|
className="c-messages__glass-content"
|
|
188
|
-
style={{ borderRadius: glassProps.
|
|
188
|
+
style={{ borderRadius: glassProps.borderRadius }}
|
|
189
189
|
>
|
|
190
190
|
{messagesContent}
|
|
191
191
|
</div>
|
|
@@ -645,7 +645,7 @@ export const GlassCustom: Story = {
|
|
|
645
645
|
glass={{
|
|
646
646
|
displacementScale: 80,
|
|
647
647
|
blurAmount: 2.5,
|
|
648
|
-
|
|
648
|
+
borderRadius: 20,
|
|
649
649
|
mode: 'shader',
|
|
650
650
|
}}
|
|
651
651
|
>
|
|
@@ -799,7 +799,7 @@ export const GlassThemeShowcase: Story = {
|
|
|
799
799
|
glass={{
|
|
800
800
|
displacementScale: 60,
|
|
801
801
|
blurAmount: 2,
|
|
802
|
-
|
|
802
|
+
borderRadius: 16,
|
|
803
803
|
mode: 'shader',
|
|
804
804
|
}}
|
|
805
805
|
>
|
|
@@ -51,7 +51,7 @@ export const Nav = forwardRef<HTMLUListElement, NavProps>(
|
|
|
51
51
|
const defaultGlassProps = {
|
|
52
52
|
displacementScale: 60,
|
|
53
53
|
blurAmount: 1.5,
|
|
54
|
-
|
|
54
|
+
borderRadius: 8,
|
|
55
55
|
mode: 'shader' as const,
|
|
56
56
|
};
|
|
57
57
|
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
@@ -715,7 +715,7 @@ export const GlassCustom: Story = {
|
|
|
715
715
|
glass={{
|
|
716
716
|
displacementScale: 100,
|
|
717
717
|
blurAmount: 2.5,
|
|
718
|
-
|
|
718
|
+
borderRadius: 0,
|
|
719
719
|
mode: 'shader',
|
|
720
720
|
}}
|
|
721
721
|
>
|
|
@@ -773,7 +773,7 @@ export const GlassCustom: Story = {
|
|
|
773
773
|
docs: {
|
|
774
774
|
description: {
|
|
775
775
|
story:
|
|
776
|
-
'Customized glass effect with increased displacement and blur for a more pronounced visual impact. The sharp corners (
|
|
776
|
+
'Customized glass effect with increased displacement and blur for a more pronounced visual impact. The sharp corners (borderRadius: 0) create a modern, edge-to-edge aesthetic.',
|
|
777
777
|
},
|
|
778
778
|
},
|
|
779
779
|
},
|
|
@@ -942,7 +942,7 @@ export const GlassThemeShowcase: Story = {
|
|
|
942
942
|
glass={{
|
|
943
943
|
displacementScale: 60,
|
|
944
944
|
blurAmount: 2,
|
|
945
|
-
|
|
945
|
+
borderRadius: 0,
|
|
946
946
|
mode: 'shader',
|
|
947
947
|
}}
|
|
948
948
|
>
|
|
@@ -146,7 +146,7 @@ export const Navbar = forwardRef<HTMLElement, NavbarProps>(
|
|
|
146
146
|
const defaultGlassProps = {
|
|
147
147
|
displacementScale: 30,
|
|
148
148
|
blurAmount: 2,
|
|
149
|
-
|
|
149
|
+
borderRadius: 0,
|
|
150
150
|
elasticity: 0,
|
|
151
151
|
mode: 'shader' as const,
|
|
152
152
|
shaderVariant: 'premiumGlass' as const,
|
|
@@ -1140,7 +1140,7 @@ export const GlassCustom: Story = {
|
|
|
1140
1140
|
glass={{
|
|
1141
1141
|
displacementScale: 70,
|
|
1142
1142
|
blurAmount: 2,
|
|
1143
|
-
|
|
1143
|
+
borderRadius: 12,
|
|
1144
1144
|
mode: 'shader',
|
|
1145
1145
|
}}
|
|
1146
1146
|
>
|
|
@@ -1293,7 +1293,7 @@ export const GlassThemeShowcase: Story = {
|
|
|
1293
1293
|
glass={{
|
|
1294
1294
|
displacementScale: 60,
|
|
1295
1295
|
blurAmount: 1.8,
|
|
1296
|
-
|
|
1296
|
+
borderRadius: 16,
|
|
1297
1297
|
mode: 'shader',
|
|
1298
1298
|
}}
|
|
1299
1299
|
>
|
|
@@ -308,7 +308,7 @@ export const SideMenu = forwardRef<HTMLDivElement, SideMenuProps>(
|
|
|
308
308
|
const defaultGlassProps = {
|
|
309
309
|
displacementScale: 70,
|
|
310
310
|
blurAmount: 2,
|
|
311
|
-
|
|
311
|
+
borderRadius: 12,
|
|
312
312
|
mode: 'shader' as const,
|
|
313
313
|
};
|
|
314
314
|
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
@@ -46,7 +46,7 @@ export const Progress = memo(
|
|
|
46
46
|
const defaultGlassProps = {
|
|
47
47
|
displacementScale: 30,
|
|
48
48
|
blurAmount: 0.5,
|
|
49
|
-
|
|
49
|
+
borderRadius: 8,
|
|
50
50
|
mode: 'shader' as const,
|
|
51
51
|
};
|
|
52
52
|
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
4
|
+
import Rating from './Rating';
|
|
5
|
+
|
|
6
|
+
// Mock AtomixGlass since it's used in Rating
|
|
7
|
+
vi.mock('../AtomixGlass/AtomixGlass', () => ({
|
|
8
|
+
AtomixGlass: ({ children }: any) => <div data-testid="glass-wrapper">{children}</div>,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
describe('Rating', () => {
|
|
12
|
+
it('renders correctly', () => {
|
|
13
|
+
render(<Rating value={3} />);
|
|
14
|
+
const stars = screen.getAllByRole('button');
|
|
15
|
+
expect(stars).toHaveLength(5);
|
|
16
|
+
// 3 full stars, 2 empty
|
|
17
|
+
expect(stars[0]).toHaveAttribute('aria-checked', 'true');
|
|
18
|
+
expect(stars[1]).toHaveAttribute('aria-checked', 'true');
|
|
19
|
+
expect(stars[2]).toHaveAttribute('aria-checked', 'true');
|
|
20
|
+
expect(stars[3]).toHaveAttribute('aria-checked', 'false');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('calculates half star on hover when allowHalf is true', () => {
|
|
24
|
+
render(<Rating allowHalf />);
|
|
25
|
+
const stars = screen.getAllByRole('button');
|
|
26
|
+
const firstStar = stars[0];
|
|
27
|
+
|
|
28
|
+
// Mock getBoundingClientRect
|
|
29
|
+
vi.spyOn(firstStar, 'getBoundingClientRect').mockReturnValue({
|
|
30
|
+
left: 100,
|
|
31
|
+
width: 20,
|
|
32
|
+
top: 0,
|
|
33
|
+
bottom: 20,
|
|
34
|
+
right: 120,
|
|
35
|
+
height: 20,
|
|
36
|
+
x: 100,
|
|
37
|
+
y: 0,
|
|
38
|
+
toJSON: () => {},
|
|
39
|
+
} as DOMRect);
|
|
40
|
+
|
|
41
|
+
// Hover on left half (105 is < 100 + 10 = 110)
|
|
42
|
+
fireEvent.mouseEnter(firstStar, { clientX: 105 });
|
|
43
|
+
fireEvent.mouseMove(firstStar, { clientX: 105 });
|
|
44
|
+
|
|
45
|
+
// Check if the star has the half class
|
|
46
|
+
// RATING.CLASSES.HALF is 'c-rating__star--half'
|
|
47
|
+
expect(firstStar).toHaveClass('c-rating__star--half');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('calculates full star on hover right half when allowHalf is true', () => {
|
|
51
|
+
render(<Rating allowHalf />);
|
|
52
|
+
const stars = screen.getAllByRole('button');
|
|
53
|
+
const firstStar = stars[0];
|
|
54
|
+
|
|
55
|
+
vi.spyOn(firstStar, 'getBoundingClientRect').mockReturnValue({
|
|
56
|
+
left: 100,
|
|
57
|
+
width: 20,
|
|
58
|
+
top: 0,
|
|
59
|
+
bottom: 20,
|
|
60
|
+
right: 120,
|
|
61
|
+
height: 20,
|
|
62
|
+
x: 100,
|
|
63
|
+
y: 0,
|
|
64
|
+
toJSON: () => {},
|
|
65
|
+
} as DOMRect);
|
|
66
|
+
|
|
67
|
+
// Hover on right half (115 is > 100 + 10 = 110)
|
|
68
|
+
fireEvent.mouseEnter(firstStar, { clientX: 115 });
|
|
69
|
+
fireEvent.mouseMove(firstStar, { clientX: 115 });
|
|
70
|
+
|
|
71
|
+
expect(firstStar).toHaveClass('c-rating__star--full');
|
|
72
|
+
});
|
|
73
|
+
});
|