@shohojdhara/atomix 0.3.5 → 0.3.7
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 +101 -199
- package/atomix.config.ts +241 -0
- package/dist/atomix.css +260 -179
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +250 -179
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.js +69 -166
- package/dist/charts.js.map +1 -1
- package/dist/core.js +184 -263
- package/dist/core.js.map +1 -1
- package/dist/forms.js +55 -131
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +184 -263
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +1831 -1657
- package/dist/index.esm.js +4497 -4318
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4510 -4328
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +1431 -1472
- package/dist/theme.js +4175 -4138
- package/dist/theme.js.map +1 -1
- package/package.json +6 -20
- package/src/components/Accordion/Accordion.stories.tsx +50 -17
- package/src/components/AtomixGlass/AtomixGlass.tsx +128 -322
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +12 -5
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -32
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +2 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +0 -31
- package/src/components/Avatar/Avatar.stories.tsx +7 -0
- package/src/components/Badge/Badge.stories.tsx +91 -13
- package/src/components/Block/Block.stories.tsx +7 -23
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +7 -0
- package/src/components/Button/Button.stories.tsx +141 -22
- package/src/components/Button/Button.tsx +85 -167
- package/src/components/Button/ButtonGroup.stories.tsx +315 -0
- package/src/components/Button/ButtonGroup.tsx +67 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Callout/Callout.stories.tsx +8 -6
- package/src/components/Card/Card.stories.tsx +82 -28
- package/src/components/Chart/AnimatedChart.tsx +0 -1
- package/src/components/Chart/AreaChart.tsx +0 -1
- package/src/components/Chart/BarChart.tsx +0 -1
- package/src/components/Chart/BubbleChart.tsx +0 -1
- package/src/components/Chart/CandlestickChart.tsx +0 -1
- package/src/components/Chart/Chart.stories.tsx +5 -7
- package/src/components/Chart/Chart.tsx +0 -16
- package/src/components/Chart/ChartRenderer.tsx +1 -1
- package/src/components/Chart/DonutChart.tsx +0 -1
- package/src/components/Chart/FunnelChart.tsx +0 -1
- package/src/components/Chart/GaugeChart.tsx +0 -1
- package/src/components/Chart/HeatmapChart.tsx +0 -1
- package/src/components/Chart/LineChart.tsx +0 -1
- package/src/components/Chart/MultiAxisChart.tsx +0 -1
- package/src/components/Chart/PieChart.tsx +0 -1
- package/src/components/Chart/RadarChart.tsx +0 -1
- package/src/components/Chart/ScatterChart.tsx +0 -1
- package/src/components/Chart/WaterfallChart.tsx +0 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +7 -0
- package/src/components/DataTable/DataTable.stories.tsx +23 -16
- package/src/components/DatePicker/DatePicker.stories.tsx +27 -19
- package/src/components/Dropdown/Dropdown.stories.tsx +11 -19
- package/src/components/EdgePanel/EdgePanel.stories.tsx +1 -0
- package/src/components/Footer/Footer.stories.tsx +8 -6
- package/src/components/Footer/FooterLink.tsx +9 -2
- package/src/components/Form/Checkbox.stories.tsx +7 -0
- package/src/components/Form/Form.stories.tsx +7 -0
- package/src/components/Form/FormGroup.stories.tsx +9 -1
- package/src/components/Form/Input.stories.tsx +69 -16
- package/src/components/Form/Radio.stories.tsx +9 -1
- package/src/components/Form/Select.stories.tsx +9 -1
- package/src/components/Form/Textarea.stories.tsx +10 -2
- package/src/components/Hero/Hero.stories.tsx +7 -0
- package/src/components/List/List.stories.tsx +7 -0
- package/src/components/Messages/Messages.stories.tsx +8 -7
- package/src/components/Modal/Modal.stories.tsx +17 -6
- package/src/components/Navigation/Menu/Menu.stories.tsx +7 -0
- package/src/components/Navigation/Nav/Nav.stories.tsx +7 -0
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +1 -0
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +188 -111
- package/src/components/Pagination/Pagination.tsx +83 -3
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -5
- package/src/components/Popover/Popover.stories.tsx +191 -115
- package/src/components/ProductReview/ProductReview.stories.tsx +80 -58
- package/src/components/Progress/Progress.stories.tsx +79 -49
- package/src/components/Rating/Rating.stories.tsx +109 -84
- package/src/components/River/River.stories.tsx +194 -114
- package/src/components/SectionIntro/SectionIntro.stories.tsx +19 -9
- package/src/components/Slider/Slider.stories.tsx +7 -0
- package/src/components/Spinner/Spinner.stories.tsx +15 -11
- package/src/components/Steps/Steps.stories.tsx +132 -98
- package/src/components/Tabs/Tabs.stories.tsx +163 -112
- package/src/components/Testimonial/Testimonial.stories.tsx +114 -68
- package/src/components/Todo/Todo.stories.tsx +38 -12
- package/src/components/Toggle/Toggle.stories.tsx +61 -28
- package/src/components/Tooltip/Tooltip.stories.tsx +318 -200
- package/src/components/Upload/Upload.stories.tsx +122 -84
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +7 -24
- package/src/components/index.ts +1 -0
- package/src/lib/composables/useAtomixGlass.ts +9 -10
- package/src/lib/composables/useNavbar.ts +0 -10
- package/src/lib/config/loader.ts +4 -4
- package/src/lib/constants/components.ts +17 -0
- package/src/lib/hooks/useComponentCustomization.ts +1 -1
- package/src/lib/hooks/usePerformanceMonitor.ts +1 -1
- package/src/lib/hooks/useThemeTokens.ts +105 -0
- package/src/lib/theme/README.md +174 -0
- package/src/lib/theme/adapters/index.ts +31 -0
- package/src/lib/theme/adapters/themeAdapter.ts +287 -0
- package/src/lib/theme/config/__tests__/configLoader.test.ts +207 -0
- package/src/lib/theme/config/configLoader.ts +95 -0
- package/src/lib/theme/config/loader.ts +37 -54
- package/src/lib/theme/config/types.ts +2 -2
- package/src/lib/theme/config/validator.ts +15 -91
- package/src/lib/theme/{constants.ts → constants/constants.ts} +1 -19
- package/src/lib/theme/constants/index.ts +8 -0
- package/src/lib/theme/core/ThemeRegistry.ts +75 -266
- package/src/lib/theme/core/__tests__/createTheme.test.ts +132 -0
- package/src/lib/theme/core/composeTheme.ts +105 -0
- package/src/lib/theme/core/createTheme.ts +108 -0
- package/src/lib/theme/{createTheme.ts → core/createThemeObject.ts} +12 -8
- package/src/lib/theme/core/index.ts +19 -19
- package/src/lib/theme/devtools/Comparator.tsx +346 -22
- package/src/lib/theme/devtools/IMPROVEMENTS.md +139 -38
- package/src/lib/theme/devtools/Inspector.tsx +335 -51
- package/src/lib/theme/devtools/LiveEditor.tsx +478 -107
- package/src/lib/theme/devtools/Preview.tsx +471 -221
- package/src/lib/theme/{core → devtools}/ThemeValidator.ts +1 -1
- package/src/lib/theme/devtools/index.ts +14 -4
- package/src/lib/theme/devtools/useHistory.ts +130 -0
- package/src/lib/theme/{errors.ts → errors/errors.ts} +1 -1
- package/src/lib/theme/errors/index.ts +12 -0
- package/src/lib/theme/generators/cssFile.ts +79 -0
- package/src/lib/theme/generators/generateCSS.ts +89 -0
- package/src/lib/theme/generators/generateCSSNested.ts +130 -0
- package/src/lib/theme/{generateCSSVariables.ts → generators/generateCSSVariables.ts} +3 -13
- package/src/lib/theme/generators/index.ts +25 -0
- package/src/lib/theme/i18n/rtl.ts +5 -6
- package/src/lib/theme/index.ts +149 -19
- package/src/lib/theme/runtime/ThemeApplicator.ts +53 -112
- package/src/lib/theme/{ThemeContext.tsx → runtime/ThemeContext.tsx} +1 -1
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +5 -5
- package/src/lib/theme/runtime/ThemeProvider.tsx +266 -282
- package/src/lib/theme/runtime/index.ts +2 -2
- package/src/lib/theme/runtime/useTheme.ts +1 -2
- package/src/lib/theme/runtime/useThemeTokens.ts +131 -0
- package/src/lib/theme/test/testTheme.ts +385 -0
- package/src/lib/theme/tokens/index.ts +12 -0
- package/src/lib/theme/tokens/tokens.ts +721 -0
- package/src/lib/theme/types.ts +6 -42
- package/src/lib/theme/utils/componentTheming.ts +132 -0
- package/src/lib/theme/{utils.ts → utils/domUtils.ts} +2 -2
- package/src/lib/theme/utils/index.ts +11 -0
- package/src/lib/theme/utils/injectCSS.ts +90 -0
- package/src/lib/theme/utils/naming.ts +100 -0
- package/src/lib/theme/utils/themeHelpers.ts +78 -0
- package/src/lib/theme/{themeUtils.ts → utils/themeUtils.ts} +7 -7
- package/src/lib/theme-tools.ts +7 -8
- package/src/lib/types/components.ts +40 -130
- package/src/lib/utils/componentUtils.ts +2 -2
- package/src/lib/utils/memoryMonitor.ts +3 -3
- package/src/lib/utils/themeNaming.ts +135 -0
- package/src/styles/01-settings/_settings.design-tokens.scss +4 -1
- package/src/styles/02-tools/_tools.button.scss +66 -79
- package/src/styles/06-components/_components.atomix-glass.scss +13 -3
- package/src/styles/06-components/_components.pagination.scss +88 -0
- package/scripts/sync-theme-config.js +0 -309
- package/src/lib/theme/composeTheme.ts +0 -370
- package/src/lib/theme/core/ThemeCache.ts +0 -283
- package/src/lib/theme/core/ThemeEngine.test.ts +0 -146
- package/src/lib/theme/core/ThemeEngine.ts +0 -665
- package/src/lib/theme/createThemeFromConfig.ts +0 -132
- package/src/lib/theme/devtools/CLI.ts +0 -364
- package/src/lib/theme/runtime/ThemeManager.test.ts +0 -192
- package/src/lib/theme/runtime/ThemeManager.ts +0 -446
- package/src/styles/03-generic/_generated-root.css +0 -26
- package/src/themes/README.md +0 -442
- package/src/themes/themes.config.js +0 -68
- /package/src/lib/theme/{cssVariableMapper.ts → adapters/cssVariableMapper.ts} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { ElementType, forwardRef, useCallback
|
|
1
|
+
import React, { ElementType, forwardRef, useCallback } from 'react';
|
|
2
2
|
import { useButton } from '../../lib/composables/useButton';
|
|
3
3
|
import { ButtonProps } from '../../lib/types/components';
|
|
4
4
|
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
5
5
|
import { Spinner } from '../Spinner/Spinner';
|
|
6
6
|
import { Icon, type PhosphorIconsType } from '../Icon/Icon';
|
|
7
|
-
import { BUTTON } from '../../lib/constants/components';
|
|
7
|
+
import { BUTTON, THEME_NAMING } from '../../lib/constants/components';
|
|
8
|
+
import { ThemeNaming } from '../../lib/utils/themeNaming';
|
|
8
9
|
|
|
9
10
|
export type ButtonAsProp = {
|
|
10
11
|
as?: ElementType;
|
|
@@ -62,13 +63,7 @@ export const Button = React.memo(
|
|
|
62
63
|
const shouldRenderAsLink = Boolean(href && !isDisabled);
|
|
63
64
|
|
|
64
65
|
// Resolve icon element - support both icon (ReactNode) and iconName (string)
|
|
65
|
-
const iconElement =
|
|
66
|
-
if (loading) return null;
|
|
67
|
-
if (iconName) {
|
|
68
|
-
return <Icon name={iconName as PhosphorIconsType} size={iconSize} />;
|
|
69
|
-
}
|
|
70
|
-
return icon;
|
|
71
|
-
}, [icon, iconName, iconSize, loading]);
|
|
66
|
+
const iconElement = iconName ? <Icon name={iconName as PhosphorIconsType} size={iconSize} /> : icon;
|
|
72
67
|
|
|
73
68
|
const { generateButtonClass, handleClick } = useButton({
|
|
74
69
|
variant,
|
|
@@ -83,24 +78,23 @@ export const Button = React.memo(
|
|
|
83
78
|
selected,
|
|
84
79
|
});
|
|
85
80
|
|
|
86
|
-
const buttonClass =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
81
|
+
const buttonClass = [
|
|
82
|
+
BUTTON.BASE_CLASS,
|
|
83
|
+
ThemeNaming.variantClass(THEME_NAMING.BUTTON_PREFIX, variant),
|
|
84
|
+
size !== 'md' ? ThemeNaming.sizeClass(THEME_NAMING.BUTTON_PREFIX, size) : '',
|
|
85
|
+
iconOnly ? ThemeNaming.stateClass(THEME_NAMING.BUTTON_PREFIX, THEME_NAMING.ICON_ELEMENT) : '',
|
|
86
|
+
rounded ? ThemeNaming.stateClass(THEME_NAMING.BUTTON_PREFIX, 'rounded') : '',
|
|
87
|
+
isDisabled ? ThemeNaming.stateClass(THEME_NAMING.BUTTON_PREFIX, 'disabled') : '',
|
|
88
|
+
glass ? ThemeNaming.stateClass(THEME_NAMING.BUTTON_PREFIX, 'glass') : '',
|
|
89
|
+
loading ? BUTTON.CLASSES.LOADING : '',
|
|
90
|
+
fullWidth ? BUTTON.CLASSES.FULL_WIDTH : '',
|
|
91
|
+
block ? BUTTON.CLASSES.BLOCK : '',
|
|
92
|
+
active ? BUTTON.CLASSES.ACTIVE : '',
|
|
93
|
+
selected ? BUTTON.CLASSES.SELECTED : '',
|
|
94
|
+
className,
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(' ');
|
|
104
98
|
|
|
105
99
|
// Handle click with loading check
|
|
106
100
|
const handleClickEvent = useCallback(
|
|
@@ -145,117 +139,76 @@ export const Button = React.memo(
|
|
|
145
139
|
);
|
|
146
140
|
|
|
147
141
|
// Determine button text
|
|
148
|
-
const buttonText =
|
|
149
|
-
if (loading && loadingText) return loadingText;
|
|
150
|
-
if (loading && !loadingText) return label || children;
|
|
151
|
-
return label || children;
|
|
152
|
-
}, [loading, loadingText, label, children]);
|
|
142
|
+
const buttonText = loading && loadingText ? loadingText : label || children;
|
|
153
143
|
|
|
154
144
|
// Determine spinner size based on button size
|
|
155
|
-
const spinnerSize =
|
|
156
|
-
if (size === 'sm') return 'sm';
|
|
157
|
-
if (size === 'lg') return 'md';
|
|
158
|
-
return 'sm';
|
|
159
|
-
}, [size]);
|
|
145
|
+
const spinnerSize = size === 'sm' ? 'sm' : size === 'lg' ? 'md' : 'sm';
|
|
160
146
|
|
|
161
147
|
// Button content with icon positioning
|
|
162
|
-
const buttonContent =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (iconPosition === 'end') {
|
|
187
|
-
return (
|
|
188
|
-
<>
|
|
189
|
-
{labelElement}
|
|
190
|
-
{spinnerElement}
|
|
191
|
-
{iconSpan}
|
|
192
|
-
</>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return (
|
|
197
|
-
<>
|
|
198
|
-
{spinnerElement}
|
|
199
|
-
{iconSpan}
|
|
200
|
-
{labelElement}
|
|
201
|
-
</>
|
|
202
|
-
);
|
|
203
|
-
}, [iconElement, iconPosition, iconOnly, buttonText, loading, spinnerSize, variant]);
|
|
148
|
+
const buttonContent = (
|
|
149
|
+
<>
|
|
150
|
+
{loading && (
|
|
151
|
+
<span className={ThemeNaming.bemClass(THEME_NAMING.BUTTON_PREFIX, THEME_NAMING.SPINNER_ELEMENT)} aria-hidden="true">
|
|
152
|
+
<Spinner
|
|
153
|
+
size={spinnerSize}
|
|
154
|
+
variant={
|
|
155
|
+
variant === 'link' || (typeof variant === 'string' && variant.startsWith('outline-'))
|
|
156
|
+
? 'primary'
|
|
157
|
+
: (variant === 'danger' ? 'error' : (variant as any))
|
|
158
|
+
}
|
|
159
|
+
/>
|
|
160
|
+
</span>
|
|
161
|
+
)}
|
|
162
|
+
{iconElement && !loading && (
|
|
163
|
+
<span className={ThemeNaming.bemClass(THEME_NAMING.BUTTON_PREFIX, THEME_NAMING.ICON_ELEMENT)} aria-hidden="true">
|
|
164
|
+
{iconElement}
|
|
165
|
+
</span>
|
|
166
|
+
)}
|
|
167
|
+
{!iconOnly && buttonText && (
|
|
168
|
+
<span className={ThemeNaming.bemClass(THEME_NAMING.BUTTON_PREFIX, THEME_NAMING.LABEL_ELEMENT)}>{buttonText}</span>
|
|
169
|
+
)}
|
|
170
|
+
</>
|
|
171
|
+
);
|
|
204
172
|
|
|
205
173
|
// Button props
|
|
206
|
-
const buttonProps =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
handleBlurEvent,
|
|
235
|
-
isDisabled,
|
|
236
|
-
loading,
|
|
237
|
-
ariaLabel,
|
|
238
|
-
iconOnly,
|
|
239
|
-
label,
|
|
240
|
-
children,
|
|
241
|
-
ariaDescribedBy,
|
|
242
|
-
ariaExpanded,
|
|
243
|
-
ariaControls,
|
|
244
|
-
tabIndex,
|
|
245
|
-
style,
|
|
246
|
-
props,
|
|
247
|
-
]
|
|
248
|
-
);
|
|
174
|
+
const buttonProps = {
|
|
175
|
+
ref,
|
|
176
|
+
className: buttonClass,
|
|
177
|
+
type: Component === 'button' && !shouldRenderAsLink ? type : undefined,
|
|
178
|
+
onClick: handleClickEvent,
|
|
179
|
+
onMouseEnter: onHover ? handleMouseEnter : undefined,
|
|
180
|
+
onFocus: onFocus ? handleFocusEvent : undefined,
|
|
181
|
+
onBlur: onBlur ? handleBlurEvent : undefined,
|
|
182
|
+
disabled: isDisabled && Component === 'button' && !shouldRenderAsLink,
|
|
183
|
+
'aria-disabled': isDisabled,
|
|
184
|
+
'aria-busy': loading,
|
|
185
|
+
'aria-label': ariaLabel || (iconOnly ? label || children : undefined),
|
|
186
|
+
'aria-describedby': ariaDescribedBy,
|
|
187
|
+
'aria-expanded': ariaExpanded,
|
|
188
|
+
'aria-controls': ariaControls,
|
|
189
|
+
tabIndex: tabIndex !== undefined ? tabIndex : (isDisabled ? -1 : 0),
|
|
190
|
+
style,
|
|
191
|
+
...props,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// Default glass props
|
|
195
|
+
const defaultGlassProps = {
|
|
196
|
+
displacementScale: 20,
|
|
197
|
+
blurAmount: 0,
|
|
198
|
+
saturation: 200,
|
|
199
|
+
elasticity: 0,
|
|
200
|
+
};
|
|
201
|
+
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
249
202
|
|
|
250
203
|
// Render as anchor if href is provided
|
|
251
204
|
if (shouldRenderAsLink) {
|
|
252
205
|
const { ref: _, ...buttonPropsWithoutRef } = buttonProps;
|
|
253
206
|
const anchorButtonProps = {
|
|
254
207
|
...buttonPropsWithoutRef,
|
|
255
|
-
type: undefined,
|
|
208
|
+
type: undefined,
|
|
256
209
|
disabled: undefined,
|
|
257
210
|
};
|
|
258
|
-
|
|
211
|
+
|
|
259
212
|
// Use custom LinkComponent if provided (e.g., Next.js Link)
|
|
260
213
|
if (LinkComponent) {
|
|
261
214
|
const LinkComp = LinkComponent as React.ComponentType<any>;
|
|
@@ -266,25 +219,14 @@ export const Button = React.memo(
|
|
|
266
219
|
target,
|
|
267
220
|
rel: target === '_blank' ? 'noopener noreferrer' : undefined,
|
|
268
221
|
};
|
|
269
|
-
|
|
222
|
+
|
|
270
223
|
const linkElement = (
|
|
271
224
|
<LinkComp {...linkProps}>
|
|
272
225
|
{buttonContent}
|
|
273
226
|
</LinkComp>
|
|
274
227
|
);
|
|
275
228
|
|
|
276
|
-
|
|
277
|
-
const defaultGlassProps = {
|
|
278
|
-
displacementScale: 20,
|
|
279
|
-
blurAmount: 0,
|
|
280
|
-
saturation: 200,
|
|
281
|
-
elasticity: 0,
|
|
282
|
-
};
|
|
283
|
-
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
284
|
-
return <AtomixGlass {...glassProps}>{linkElement}</AtomixGlass>;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return linkElement;
|
|
229
|
+
return glass ? <AtomixGlass {...glassProps}>{linkElement}</AtomixGlass> : linkElement;
|
|
288
230
|
}
|
|
289
231
|
|
|
290
232
|
// Fallback to regular anchor tag
|
|
@@ -294,39 +236,15 @@ export const Button = React.memo(
|
|
|
294
236
|
</a>
|
|
295
237
|
);
|
|
296
238
|
|
|
297
|
-
|
|
298
|
-
const defaultGlassProps = {
|
|
299
|
-
displacementScale: 20,
|
|
300
|
-
blurAmount: 0,
|
|
301
|
-
saturation: 200,
|
|
302
|
-
elasticity: 0,
|
|
303
|
-
};
|
|
304
|
-
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
305
|
-
return <AtomixGlass {...glassProps}>{anchorElement}</AtomixGlass>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return anchorElement;
|
|
239
|
+
return glass ? <AtomixGlass {...glassProps}>{anchorElement}</AtomixGlass> : anchorElement;
|
|
309
240
|
}
|
|
310
241
|
|
|
311
242
|
// Default button rendering
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
blurAmount: 0,
|
|
316
|
-
saturation: 200,
|
|
317
|
-
elasticity: 0,
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
321
|
-
|
|
322
|
-
return (
|
|
323
|
-
<AtomixGlass {...glassProps}>
|
|
324
|
-
<Component {...buttonProps}>{buttonContent}</Component>
|
|
325
|
-
</AtomixGlass>
|
|
326
|
-
);
|
|
327
|
-
}
|
|
243
|
+
const buttonElement = (
|
|
244
|
+
<Component {...buttonProps}>{buttonContent}</Component>
|
|
245
|
+
);
|
|
328
246
|
|
|
329
|
-
return <
|
|
247
|
+
return glass ? <AtomixGlass {...glassProps}>{buttonElement}</AtomixGlass> : buttonElement;
|
|
330
248
|
}
|
|
331
249
|
)
|
|
332
250
|
);
|
|
@@ -335,4 +253,4 @@ Button.displayName = 'Button';
|
|
|
335
253
|
|
|
336
254
|
export type { ButtonProps };
|
|
337
255
|
|
|
338
|
-
export default Button;
|
|
256
|
+
export default Button;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ButtonGroup } from './ButtonGroup';
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
import { SIZES } from '../../lib/constants/components';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/ButtonGroup',
|
|
8
|
+
component: ButtonGroup,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
'The ButtonGroup component groups multiple buttons together, creating a visually connected set of buttons with proper border radius handling. Buttons in a group share borders and have rounded corners only on the outer edges.',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
argTypes: {
|
|
20
|
+
className: {
|
|
21
|
+
control: 'text',
|
|
22
|
+
description: 'Additional CSS class names',
|
|
23
|
+
},
|
|
24
|
+
'aria-label': {
|
|
25
|
+
control: 'text',
|
|
26
|
+
description: 'ARIA label for accessibility',
|
|
27
|
+
},
|
|
28
|
+
role: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description: 'ARIA role for the button group',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
} satisfies Meta<typeof ButtonGroup>;
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
37
|
+
|
|
38
|
+
// Basic Button Groups
|
|
39
|
+
export const Basic: Story = {
|
|
40
|
+
render: () => (
|
|
41
|
+
<ButtonGroup>
|
|
42
|
+
<Button label="Left" />
|
|
43
|
+
<Button label="Middle" />
|
|
44
|
+
<Button label="Right" />
|
|
45
|
+
</ButtonGroup>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const TwoButtons: Story = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<ButtonGroup>
|
|
52
|
+
<Button label="Cancel" variant="secondary" />
|
|
53
|
+
<Button label="Save" variant="primary" />
|
|
54
|
+
</ButtonGroup>
|
|
55
|
+
),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const ThreeButtons: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<ButtonGroup>
|
|
61
|
+
<Button label="Previous" variant="secondary" />
|
|
62
|
+
<Button label="Next" variant="primary" />
|
|
63
|
+
<Button label="Finish" variant="success" />
|
|
64
|
+
</ButtonGroup>
|
|
65
|
+
),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Variant Combinations
|
|
69
|
+
export const PrimaryGroup: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<ButtonGroup>
|
|
72
|
+
<Button label="One" variant="primary" />
|
|
73
|
+
<Button label="Two" variant="primary" />
|
|
74
|
+
<Button label="Three" variant="primary" />
|
|
75
|
+
</ButtonGroup>
|
|
76
|
+
),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const SecondaryGroup: Story = {
|
|
80
|
+
render: () => (
|
|
81
|
+
<ButtonGroup>
|
|
82
|
+
<Button label="One" variant="secondary" />
|
|
83
|
+
<Button label="Two" variant="secondary" />
|
|
84
|
+
<Button label="Three" variant="secondary" />
|
|
85
|
+
</ButtonGroup>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const OutlineGroup: Story = {
|
|
90
|
+
render: () => (
|
|
91
|
+
<ButtonGroup>
|
|
92
|
+
<Button label="One" variant="outline-primary" />
|
|
93
|
+
<Button label="Two" variant="outline-primary" />
|
|
94
|
+
<Button label="Three" variant="outline-primary" />
|
|
95
|
+
</ButtonGroup>
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const MixedVariants: Story = {
|
|
100
|
+
render: () => (
|
|
101
|
+
<ButtonGroup>
|
|
102
|
+
<Button label="Cancel" variant="secondary" />
|
|
103
|
+
<Button label="Save Draft" variant="outline-primary" />
|
|
104
|
+
<Button label="Publish" variant="primary" />
|
|
105
|
+
</ButtonGroup>
|
|
106
|
+
),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Size Variants
|
|
110
|
+
export const SmallSize: Story = {
|
|
111
|
+
render: () => (
|
|
112
|
+
<ButtonGroup>
|
|
113
|
+
<Button label="Small" size="sm" />
|
|
114
|
+
<Button label="Buttons" size="sm" />
|
|
115
|
+
<Button label="Group" size="sm" />
|
|
116
|
+
</ButtonGroup>
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const MediumSize: Story = {
|
|
121
|
+
render: () => (
|
|
122
|
+
<ButtonGroup>
|
|
123
|
+
<Button label="Medium" size="md" />
|
|
124
|
+
<Button label="Buttons" size="md" />
|
|
125
|
+
<Button label="Group" size="md" />
|
|
126
|
+
</ButtonGroup>
|
|
127
|
+
),
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const LargeSize: Story = {
|
|
131
|
+
render: () => (
|
|
132
|
+
<ButtonGroup>
|
|
133
|
+
<Button label="Large" size="lg" />
|
|
134
|
+
<Button label="Buttons" size="lg" />
|
|
135
|
+
<Button label="Group" size="lg" />
|
|
136
|
+
</ButtonGroup>
|
|
137
|
+
),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// With Icons
|
|
141
|
+
export const WithIcons: Story = {
|
|
142
|
+
render: () => (
|
|
143
|
+
<ButtonGroup>
|
|
144
|
+
<Button label="Previous" iconName="ArrowLeft" iconPosition="start" />
|
|
145
|
+
<Button label="Next" iconName="ArrowRight" iconPosition="end" />
|
|
146
|
+
</ButtonGroup>
|
|
147
|
+
),
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const IconOnly: Story = {
|
|
151
|
+
render: () => (
|
|
152
|
+
<ButtonGroup>
|
|
153
|
+
<Button iconName="CaretLeft" iconOnly ariaLabel="Previous" />
|
|
154
|
+
<Button iconName="CaretRight" iconOnly ariaLabel="Next" />
|
|
155
|
+
</ButtonGroup>
|
|
156
|
+
),
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// States
|
|
160
|
+
export const WithDisabled: Story = {
|
|
161
|
+
render: () => (
|
|
162
|
+
<ButtonGroup>
|
|
163
|
+
<Button label="Enabled" />
|
|
164
|
+
<Button label="Disabled" disabled />
|
|
165
|
+
<Button label="Enabled" />
|
|
166
|
+
</ButtonGroup>
|
|
167
|
+
),
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const WithLoading: Story = {
|
|
171
|
+
render: () => (
|
|
172
|
+
<ButtonGroup>
|
|
173
|
+
<Button label="Normal" />
|
|
174
|
+
<Button label="Loading" loading />
|
|
175
|
+
<Button label="Normal" />
|
|
176
|
+
</ButtonGroup>
|
|
177
|
+
),
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const WithActive: Story = {
|
|
181
|
+
render: () => (
|
|
182
|
+
<ButtonGroup>
|
|
183
|
+
<Button label="Inactive" />
|
|
184
|
+
<Button label="Active" active />
|
|
185
|
+
<Button label="Inactive" />
|
|
186
|
+
</ButtonGroup>
|
|
187
|
+
),
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const WithSelected: Story = {
|
|
191
|
+
render: () => (
|
|
192
|
+
<ButtonGroup>
|
|
193
|
+
<Button label="Option 1" selected />
|
|
194
|
+
<Button label="Option 2" />
|
|
195
|
+
<Button label="Option 3" />
|
|
196
|
+
</ButtonGroup>
|
|
197
|
+
),
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// Action Examples
|
|
201
|
+
export const ActionButtons: Story = {
|
|
202
|
+
render: () => (
|
|
203
|
+
<ButtonGroup>
|
|
204
|
+
<Button label="Delete" variant="danger" />
|
|
205
|
+
<Button label="Edit" variant="warning" />
|
|
206
|
+
<Button label="View" variant="info" />
|
|
207
|
+
</ButtonGroup>
|
|
208
|
+
),
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const NavigationButtons: Story = {
|
|
212
|
+
render: () => (
|
|
213
|
+
<ButtonGroup>
|
|
214
|
+
<Button label="First" variant="outline-secondary" />
|
|
215
|
+
<Button label="Previous" variant="outline-secondary" />
|
|
216
|
+
<Button label="Next" variant="outline-secondary" />
|
|
217
|
+
<Button label="Last" variant="outline-secondary" />
|
|
218
|
+
</ButtonGroup>
|
|
219
|
+
),
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const FilterButtons: Story = {
|
|
223
|
+
render: () => (
|
|
224
|
+
<ButtonGroup>
|
|
225
|
+
<Button label="All" selected />
|
|
226
|
+
<Button label="Active" />
|
|
227
|
+
<Button label="Completed" />
|
|
228
|
+
</ButtonGroup>
|
|
229
|
+
),
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// Multiple Groups
|
|
233
|
+
export const MultipleGroups: Story = {
|
|
234
|
+
render: () => (
|
|
235
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
236
|
+
<ButtonGroup>
|
|
237
|
+
<Button label="Group 1 - Button 1" />
|
|
238
|
+
<Button label="Group 1 - Button 2" />
|
|
239
|
+
<Button label="Group 1 - Button 3" />
|
|
240
|
+
</ButtonGroup>
|
|
241
|
+
<ButtonGroup>
|
|
242
|
+
<Button label="Group 2 - Button 1" variant="secondary" />
|
|
243
|
+
<Button label="Group 2 - Button 2" variant="secondary" />
|
|
244
|
+
</ButtonGroup>
|
|
245
|
+
</div>
|
|
246
|
+
),
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Accessibility
|
|
250
|
+
export const WithAriaLabel: Story = {
|
|
251
|
+
render: () => (
|
|
252
|
+
<ButtonGroup aria-label="Navigation controls">
|
|
253
|
+
<Button label="Previous" />
|
|
254
|
+
<Button label="Next" />
|
|
255
|
+
</ButtonGroup>
|
|
256
|
+
),
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// Custom Styling
|
|
260
|
+
export const CustomClassName: Story = {
|
|
261
|
+
render: () => (
|
|
262
|
+
<ButtonGroup className="custom-button-group">
|
|
263
|
+
<Button label="Custom" />
|
|
264
|
+
<Button label="Styled" />
|
|
265
|
+
<Button label="Group" />
|
|
266
|
+
</ButtonGroup>
|
|
267
|
+
),
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// Edge Cases
|
|
271
|
+
export const SingleButton: Story = {
|
|
272
|
+
render: () => (
|
|
273
|
+
<ButtonGroup>
|
|
274
|
+
<Button label="Single Button" />
|
|
275
|
+
</ButtonGroup>
|
|
276
|
+
),
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export const ManyButtons: Story = {
|
|
280
|
+
render: () => (
|
|
281
|
+
<ButtonGroup>
|
|
282
|
+
<Button label="1" />
|
|
283
|
+
<Button label="2" />
|
|
284
|
+
<Button label="3" />
|
|
285
|
+
<Button label="4" />
|
|
286
|
+
<Button label="5" />
|
|
287
|
+
<Button label="6" />
|
|
288
|
+
</ButtonGroup>
|
|
289
|
+
),
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// Rounded Buttons
|
|
293
|
+
export const RoundedButtons: Story = {
|
|
294
|
+
render: () => (
|
|
295
|
+
<ButtonGroup>
|
|
296
|
+
<Button label="Rounded" rounded />
|
|
297
|
+
<Button label="Buttons" rounded />
|
|
298
|
+
<Button label="Group" rounded />
|
|
299
|
+
</ButtonGroup>
|
|
300
|
+
),
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// Full Width
|
|
304
|
+
export const FullWidth: Story = {
|
|
305
|
+
render: () => (
|
|
306
|
+
<div style={{ width: '100%', maxWidth: '600px' }}>
|
|
307
|
+
<ButtonGroup>
|
|
308
|
+
<Button label="Full" fullWidth />
|
|
309
|
+
<Button label="Width" fullWidth />
|
|
310
|
+
<Button label="Group" fullWidth />
|
|
311
|
+
</ButtonGroup>
|
|
312
|
+
</div>
|
|
313
|
+
),
|
|
314
|
+
};
|
|
315
|
+
|