@shohojdhara/atomix 0.3.13 → 0.3.14
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/CHANGELOG.md +19 -0
- package/README.md +2 -0
- package/dist/atomix.css +95 -77
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +2 -2
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.d.ts +1 -1
- package/dist/charts.js +1 -1
- package/dist/core.d.ts +41 -11
- package/dist/core.js +39 -23
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +28 -11
- package/dist/forms.js +8 -5
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +1 -1
- package/dist/heavy.js +15 -6
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +122 -46
- package/dist/index.esm.js +849 -182
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +854 -186
- 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 +27 -2
- package/dist/theme.js +721 -108
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/scripts/atomix-cli.js +610 -1111
- package/scripts/cli/component-generator.js +610 -0
- package/scripts/cli/documentation-sync.js +542 -0
- package/scripts/cli/interactive-init.js +84 -288
- package/scripts/cli/mappings.js +211 -0
- package/scripts/cli/migration-tools.js +95 -288
- package/scripts/cli/template-manager.js +107 -0
- package/scripts/cli/templates/README.md +123 -0
- package/scripts/cli/templates/composable-templates.js +149 -0
- package/scripts/cli/templates/config-templates.js +126 -0
- package/scripts/cli/templates/index.js +95 -0
- package/scripts/cli/templates/project-templates.js +214 -0
- package/scripts/cli/templates/react-templates.js +261 -0
- package/scripts/cli/templates/scss-templates.js +156 -0
- package/scripts/cli/templates/storybook-templates.js +236 -0
- package/scripts/cli/templates/testing-templates.js +45 -0
- package/scripts/cli/templates/token-templates.js +447 -0
- package/scripts/cli/templates/types-templates.js +133 -0
- package/scripts/cli/templates-original-backup.js +1655 -0
- package/scripts/cli/templates.js +35 -0
- package/scripts/cli/templates_backup.js +684 -0
- package/scripts/cli/theme-bridge.js +20 -14
- package/scripts/cli/token-manager.js +150 -77
- package/scripts/cli/utils.js +37 -25
- package/src/components/Accordion/Accordion.stories.tsx +5 -5
- package/src/components/Accordion/Accordion.test.tsx +57 -0
- package/src/components/Accordion/Accordion.tsx +4 -0
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -1
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +37 -37
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +50 -51
- package/src/components/Avatar/Avatar.stories.tsx +26 -26
- package/src/components/Badge/Badge.stories.tsx +31 -31
- package/src/components/Badge/Badge.test.tsx +51 -0
- package/src/components/Badge/Badge.tsx +20 -1
- package/src/components/Block/Block.stories.tsx +5 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -1
- package/src/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/src/components/Button/Button.stories.tsx +13 -13
- package/src/components/Button/Button.tsx +4 -4
- package/src/components/Button/ButtonGroup.stories.tsx +2 -2
- package/src/components/Button/README.md +5 -0
- package/src/components/Callout/Callout.stories.tsx +11 -11
- package/src/components/Callout/Callout.test.tsx +10 -10
- package/src/components/Callout/Callout.tsx +7 -7
- package/src/components/Callout/README.md +9 -8
- package/src/components/Card/Card.tsx +2 -2
- package/src/components/Chart/Chart.stories.tsx +6 -6
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +1 -1
- package/src/components/DataTable/DataTable.tsx +14 -12
- package/src/components/DatePicker/DatePicker.stories.tsx +6 -6
- package/src/components/Dropdown/Dropdown.stories.tsx +4 -4
- package/src/components/Form/Checkbox.stories.tsx +3 -3
- package/src/components/Form/Checkbox.tsx +4 -2
- package/src/components/Form/Form.stories.tsx +3 -3
- package/src/components/Form/FormGroup.stories.tsx +1 -1
- package/src/components/Form/Input.stories.tsx +28 -16
- package/src/components/Form/Input.test.tsx +59 -0
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +94 -94
- package/src/components/Form/Radio.tsx +2 -2
- package/src/components/Form/Select.stories.tsx +4 -4
- package/src/components/Form/Select.tsx +2 -2
- package/src/components/Form/Textarea.stories.tsx +22 -7
- package/src/components/Form/Textarea.test.tsx +45 -0
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/List/List.stories.tsx +2 -2
- package/src/components/Modal/Modal.stories.tsx +4 -4
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +5 -5
- package/src/components/Navigation/Navbar/Navbar.tsx +1 -1
- package/src/components/Navigation/README.md +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +5 -2
- package/src/components/Pagination/Pagination.tsx +1 -1
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -10
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/ProductReview/ProductReview.tsx +1 -1
- package/src/components/Progress/Progress.tsx +46 -46
- package/src/components/Rating/Rating.stories.tsx +4 -4
- package/src/components/Rating/Rating.tsx +8 -8
- package/src/components/Slider/Slider.stories.tsx +63 -63
- package/src/components/Spinner/Spinner.stories.tsx +2 -2
- package/src/components/Spinner/Spinner.test.tsx +35 -0
- package/src/components/Spinner/Spinner.tsx +9 -2
- package/src/components/Testimonial/Testimonial.stories.tsx +1 -1
- package/src/components/Toggle/Toggle.stories.tsx +32 -9
- package/src/components/Toggle/Toggle.test.tsx +91 -0
- package/src/components/Toggle/Toggle.tsx +44 -27
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/layouts/Grid/Grid.stories.tsx +49 -49
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +2 -2
- package/src/lib/composables/useAccordion.ts +12 -3
- package/src/lib/composables/useBreadcrumb.ts +2 -2
- package/src/lib/composables/useCallout.ts +7 -7
- package/src/lib/composables/useNavbar.ts +1 -1
- package/src/lib/constants/components.ts +1 -1
- package/src/lib/storybook/InteractiveDemo.tsx +113 -0
- package/src/lib/storybook/PreviewContainer.tsx +36 -0
- package/src/lib/storybook/VariantsGrid.tsx +21 -0
- package/src/lib/storybook/index.ts +3 -0
- package/src/lib/theme/core/createThemeObject.ts +9 -5
- package/src/lib/theme/devtools/CLI.ts +155 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.stories.tsx +213 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.tsx +566 -0
- package/src/lib/theme/devtools/LiveEditor.tsx +2 -1
- package/src/lib/theme/devtools/index.ts +3 -0
- package/src/lib/theme/errors/errors.ts +8 -0
- package/src/lib/theme/runtime/ThemeProvider.tsx +117 -57
- package/src/lib/theme/runtime/__tests__/ThemeProvider.integration.test.tsx +305 -0
- package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +588 -0
- package/src/lib/theme/utils/__tests__/themeValidation.test.ts +264 -0
- package/src/lib/theme/utils/index.ts +1 -0
- package/src/lib/theme/utils/themeValidation.ts +501 -0
- package/src/lib/theme-tools.ts +32 -3
- package/src/lib/types/components.ts +81 -26
- package/src/lib/utils/themeNaming.ts +1 -1
- package/src/styles/06-components/_components.callout.scss +29 -33
- package/src/styles/06-components/_index.scss +1 -1
- package/src/styles/99-utilities/_utilities.display.scss +14 -3
- package/src/styles/99-utilities/_utilities.flex.scss +10 -10
- package/src/styles/99-utilities/_utilities.text.scss +28 -8
- package/scripts/cli/__tests__/cli-commands.test.js +0 -204
- package/scripts/cli/__tests__/utils.test.js +0 -201
- package/scripts/cli/__tests__/vitest.config.js +0 -26
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
2
|
import { TOGGLE } from '../../lib/constants/components';
|
|
3
3
|
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
4
|
-
import { AtomixGlassProps } from '../../lib/types/components';
|
|
4
|
+
import { AtomixGlassProps, BaseComponentProps } from '../../lib/types/components';
|
|
5
5
|
|
|
6
|
-
export interface ToggleProps {
|
|
6
|
+
export interface ToggleProps extends BaseComponentProps {
|
|
7
7
|
/**
|
|
8
|
-
* Whether the toggle is
|
|
8
|
+
* Whether the toggle is checked (controlled)
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
checked?: boolean;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Whether the toggle is initially checked (uncontrolled)
|
|
14
|
+
* @default false
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
defaultChecked?: boolean;
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* Callback when the toggle
|
|
19
|
+
* Callback when the toggle state changes
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
onChange?: (checked: boolean) => void;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Whether the toggle is disabled
|
|
@@ -25,14 +26,14 @@ export interface ToggleProps {
|
|
|
25
26
|
disabled?: boolean;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* Accessibility label
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
'aria-label'?: string;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
+
* Accessibility description
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
'aria-describedby'?: string;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Glass morphism effect for the toggle
|
|
@@ -45,29 +46,36 @@ export interface ToggleProps {
|
|
|
45
46
|
* Toggle component for switching between two states
|
|
46
47
|
*/
|
|
47
48
|
export const Toggle: React.FC<ToggleProps> = ({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
checked: controlledChecked,
|
|
50
|
+
defaultChecked = false,
|
|
51
|
+
onChange,
|
|
51
52
|
disabled = false,
|
|
52
53
|
className = '',
|
|
53
54
|
style,
|
|
54
55
|
glass,
|
|
56
|
+
'aria-label': ariaLabel,
|
|
57
|
+
'aria-describedby': ariaDescribedBy,
|
|
55
58
|
}) => {
|
|
56
|
-
const
|
|
59
|
+
const isControlled = controlledChecked !== undefined;
|
|
60
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
61
|
+
const isChecked = isControlled ? controlledChecked : internalChecked;
|
|
62
|
+
|
|
63
|
+
// Sync internal state with defaultChecked if it changes (standard uncontrolled behavior)
|
|
64
|
+
// Actually, standard behavior is only using defaultChecked on mount, but sometimes syncing is needed.
|
|
65
|
+
// For now, let's keep it simple.
|
|
57
66
|
|
|
58
67
|
// Handle toggle click
|
|
59
|
-
const handleClick = () => {
|
|
68
|
+
const handleClick = useCallback(() => {
|
|
60
69
|
if (disabled) return;
|
|
61
70
|
|
|
62
|
-
const
|
|
63
|
-
setIsOn(newState);
|
|
71
|
+
const nextChecked = !isChecked;
|
|
64
72
|
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
} else {
|
|
68
|
-
if (onToggleOff) onToggleOff();
|
|
73
|
+
if (!isControlled) {
|
|
74
|
+
setInternalChecked(nextChecked);
|
|
69
75
|
}
|
|
70
|
-
|
|
76
|
+
|
|
77
|
+
onChange?.(nextChecked);
|
|
78
|
+
}, [disabled, isChecked, isControlled, onChange]);
|
|
71
79
|
|
|
72
80
|
// Handle key down events
|
|
73
81
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
@@ -79,16 +87,25 @@ export const Toggle: React.FC<ToggleProps> = ({
|
|
|
79
87
|
}
|
|
80
88
|
};
|
|
81
89
|
|
|
90
|
+
const toggleClass = [
|
|
91
|
+
'c-toggle',
|
|
92
|
+
isChecked && TOGGLE.CLASSES.IS_ON,
|
|
93
|
+
disabled && 'is-disabled',
|
|
94
|
+
className,
|
|
95
|
+
].filter(Boolean).join(' ');
|
|
96
|
+
|
|
82
97
|
const toggleContent = (
|
|
83
98
|
<div
|
|
84
|
-
className={
|
|
99
|
+
className={toggleClass}
|
|
85
100
|
style={style}
|
|
86
101
|
onClick={handleClick}
|
|
87
102
|
onKeyDown={handleKeyDown}
|
|
88
103
|
role="switch"
|
|
89
|
-
aria-checked={
|
|
104
|
+
aria-checked={isChecked}
|
|
90
105
|
tabIndex={disabled ? -1 : 0}
|
|
91
106
|
aria-disabled={disabled}
|
|
107
|
+
aria-label={ariaLabel}
|
|
108
|
+
aria-describedby={ariaDescribedBy}
|
|
92
109
|
>
|
|
93
110
|
<div className="c-toggle__switch"></div>
|
|
94
111
|
</div>
|
|
@@ -59,8 +59,8 @@ const DemoCard: React.FC<{
|
|
|
59
59
|
variant === 'secondary' ? 'u-bg-success-subtle' : ''
|
|
60
60
|
} ${variant === 'accent' ? 'u-bg-info-subtle' : ''}`}
|
|
61
61
|
>
|
|
62
|
-
<div className="u-
|
|
63
|
-
<div className="u-flex-grow-1 u-
|
|
62
|
+
<div className="u-flex u-flex-column u-h-100" style={{ minHeight: heightStyles[height] }}>
|
|
63
|
+
<div className="u-flex-grow-1 u-flex u-items-center u-justify-center">
|
|
64
64
|
<div className="u-text-center">{children}</div>
|
|
65
65
|
</div>
|
|
66
66
|
</div>
|
|
@@ -71,7 +71,7 @@ const DemoCard: React.FC<{
|
|
|
71
71
|
const CodeSnippet: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
72
72
|
<Card className="u-mb-4">
|
|
73
73
|
<pre
|
|
74
|
-
className="u-bg-dark u-text-light u-p-3 u-rounded u-
|
|
74
|
+
className="u-bg-dark u-text-light u-p-3 u-rounded u-text-sm u-font-normal u-overflow-auto"
|
|
75
75
|
style={{ fontFamily: 'monospace' }}
|
|
76
76
|
>
|
|
77
77
|
{children}
|
|
@@ -90,7 +90,7 @@ export const GettingStarted: Story = {
|
|
|
90
90
|
<div className="u-mb-8">
|
|
91
91
|
<div className="u-mb-6">
|
|
92
92
|
<h1 className="u-mb-3 u-text-brand-emphasis">Grid System</h1>
|
|
93
|
-
<p className="u-mb-4 u-text-secondary-emphasis u-
|
|
93
|
+
<p className="u-mb-4 u-text-secondary-emphasis u-text-lg">
|
|
94
94
|
A responsive 12-column grid system for creating flexible layouts.
|
|
95
95
|
</p>
|
|
96
96
|
<Callout variant="info" className="u-mb-4">
|
|
@@ -181,20 +181,20 @@ export const LayoutPatterns: Story = {
|
|
|
181
181
|
<Grid className="u-mb-4">
|
|
182
182
|
<GridCol xs={12} md={3}>
|
|
183
183
|
<DemoCard variant="accent" height="lg">
|
|
184
|
-
<div className="u-
|
|
185
|
-
<div className="u-
|
|
184
|
+
<div className="u-text-lg u-font-bold">Sidebar</div>
|
|
185
|
+
<div className="u-text-sm u-mt-2">Navigation, filters, etc.</div>
|
|
186
186
|
</DemoCard>
|
|
187
187
|
</GridCol>
|
|
188
188
|
<GridCol xs={12} md={9}>
|
|
189
189
|
<DemoCard height="lg">
|
|
190
|
-
<div className="u-
|
|
191
|
-
<div className="u-
|
|
190
|
+
<div className="u-text-lg u-font-bold">Main Content</div>
|
|
191
|
+
<div className="u-text-sm u-mt-2">Primary content area</div>
|
|
192
192
|
</DemoCard>
|
|
193
193
|
</GridCol>
|
|
194
194
|
</Grid>
|
|
195
195
|
|
|
196
196
|
<Card className="u-mb-6">
|
|
197
|
-
<div className="u-
|
|
197
|
+
<div className="u-flex u-flex-wrap u-gap-2">
|
|
198
198
|
<Button variant="primary">Save Changes</Button>
|
|
199
199
|
<Button variant="secondary">Cancel</Button>
|
|
200
200
|
</div>
|
|
@@ -211,8 +211,8 @@ export const LayoutPatterns: Story = {
|
|
|
211
211
|
<Grid className="u-mb-4">
|
|
212
212
|
<GridCol xs={12}>
|
|
213
213
|
<DemoCard variant="accent" height="md">
|
|
214
|
-
<div className="u-
|
|
215
|
-
<div className="u-
|
|
214
|
+
<div className="u-text-lg u-font-bold">Hero Section</div>
|
|
215
|
+
<div className="u-text-sm u-mt-2">Full-width banner</div>
|
|
216
216
|
</DemoCard>
|
|
217
217
|
</GridCol>
|
|
218
218
|
</Grid>
|
|
@@ -220,20 +220,20 @@ export const LayoutPatterns: Story = {
|
|
|
220
220
|
<Grid className="u-mb-4">
|
|
221
221
|
<GridCol xs={12} sm={6} lg={4}>
|
|
222
222
|
<DemoCard variant="secondary">
|
|
223
|
-
<div className="u-
|
|
224
|
-
<div className="u-
|
|
223
|
+
<div className="u-text-md u-font-bold">Feature 1</div>
|
|
224
|
+
<div className="u-text-sm u-mt-2">Description of feature 1</div>
|
|
225
225
|
</DemoCard>
|
|
226
226
|
</GridCol>
|
|
227
227
|
<GridCol xs={12} sm={6} lg={4}>
|
|
228
228
|
<DemoCard variant="secondary">
|
|
229
|
-
<div className="u-
|
|
230
|
-
<div className="u-
|
|
229
|
+
<div className="u-text-md u-font-bold">Feature 2</div>
|
|
230
|
+
<div className="u-text-sm u-mt-2">Description of feature 2</div>
|
|
231
231
|
</DemoCard>
|
|
232
232
|
</GridCol>
|
|
233
233
|
<GridCol xs={12} sm={12} lg={4}>
|
|
234
234
|
<DemoCard variant="secondary">
|
|
235
|
-
<div className="u-
|
|
236
|
-
<div className="u-
|
|
235
|
+
<div className="u-text-md u-font-bold">Feature 3</div>
|
|
236
|
+
<div className="u-text-sm u-mt-2">Description of feature 3</div>
|
|
237
237
|
</DemoCard>
|
|
238
238
|
</GridCol>
|
|
239
239
|
</Grid>
|
|
@@ -247,8 +247,8 @@ export const LayoutPatterns: Story = {
|
|
|
247
247
|
<Grid className="u-mb-4">
|
|
248
248
|
<GridCol xs={12} md={8} offsetMd={2}>
|
|
249
249
|
<DemoCard height="lg">
|
|
250
|
-
<div className="u-
|
|
251
|
-
<div className="u-
|
|
250
|
+
<div className="u-text-lg u-font-bold">Article Content</div>
|
|
251
|
+
<div className="u-text-sm u-text-secondary-emphasis u-mt-2">
|
|
252
252
|
Centered, readable width
|
|
253
253
|
</div>
|
|
254
254
|
</DemoCard>
|
|
@@ -345,19 +345,19 @@ export const ColumnSizing: Story = {
|
|
|
345
345
|
<GridCol xs={12} sm={6} md={4} lg="auto">
|
|
346
346
|
<DemoCard variant="secondary">
|
|
347
347
|
<div>Responsive</div>
|
|
348
|
-
<div className="u-
|
|
348
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=auto</div>
|
|
349
349
|
</DemoCard>
|
|
350
350
|
</GridCol>
|
|
351
351
|
<GridCol xs={12} sm={6} md={4} lg="auto">
|
|
352
352
|
<DemoCard variant="secondary">
|
|
353
353
|
<div>Responsive</div>
|
|
354
|
-
<div className="u-
|
|
354
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=auto</div>
|
|
355
355
|
</DemoCard>
|
|
356
356
|
</GridCol>
|
|
357
357
|
<GridCol xs={12} sm={12} md={4} lg="auto">
|
|
358
358
|
<DemoCard variant="secondary">
|
|
359
359
|
<div>Responsive</div>
|
|
360
|
-
<div className="u-
|
|
360
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=12, md=4, lg=auto</div>
|
|
361
361
|
</DemoCard>
|
|
362
362
|
</GridCol>
|
|
363
363
|
</Grid>
|
|
@@ -428,8 +428,8 @@ export const ColumnOffsets: Story = {
|
|
|
428
428
|
<Grid className="u-mb-4">
|
|
429
429
|
<GridCol xs={12} sm={6} offsetSm={3} md={4} offsetMd={4} lg={3} offsetLg={3}>
|
|
430
430
|
<DemoCard variant="secondary">
|
|
431
|
-
<div className="u-
|
|
432
|
-
<div className="u-
|
|
431
|
+
<div className="u-text-md u-font-bold">Responsive Offsets</div>
|
|
432
|
+
<div className="u-text-sm u-mt-2">Changes at each breakpoint</div>
|
|
433
433
|
</DemoCard>
|
|
434
434
|
</GridCol>
|
|
435
435
|
</Grid>
|
|
@@ -457,8 +457,8 @@ export const Containers: Story = {
|
|
|
457
457
|
|
|
458
458
|
<Container className="u-mb-4">
|
|
459
459
|
<DemoCard variant="accent" height="md">
|
|
460
|
-
<div className="u-
|
|
461
|
-
<div className="u-
|
|
460
|
+
<div className="u-text-lg u-font-bold">Default Container</div>
|
|
461
|
+
<div className="u-text-sm u-text-secondary-emphasis u-mt-2">
|
|
462
462
|
Responsive max-width, centered
|
|
463
463
|
</div>
|
|
464
464
|
</DemoCard>
|
|
@@ -474,8 +474,8 @@ export const Containers: Story = {
|
|
|
474
474
|
|
|
475
475
|
<Container type="fluid" className="u-mb-4">
|
|
476
476
|
<DemoCard variant="secondary" height="md">
|
|
477
|
-
<div className="u-
|
|
478
|
-
<div className="u-
|
|
477
|
+
<div className="u-text-lg u-font-bold">Fluid Container</div>
|
|
478
|
+
<div className="u-text-sm u-text-secondary-emphasis u-mt-2">Full viewport width</div>
|
|
479
479
|
</DemoCard>
|
|
480
480
|
</Container>
|
|
481
481
|
</div>
|
|
@@ -549,7 +549,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
549
549
|
</p>
|
|
550
550
|
|
|
551
551
|
<div className="u-mb-6">
|
|
552
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
552
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">justify-content="start"</h3>
|
|
553
553
|
<Row justifyContent="start" className="u-mb-4 u-p-3 u-bg-brand-subtle u-rounded">
|
|
554
554
|
<GridCol xs={3}>
|
|
555
555
|
<DemoCard variant="secondary">Col 1</DemoCard>
|
|
@@ -561,7 +561,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
561
561
|
</div>
|
|
562
562
|
|
|
563
563
|
<div className="u-mb-6">
|
|
564
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
564
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">justify-content="center"</h3>
|
|
565
565
|
<Row justifyContent="center" className="u-mb-4 u-p-3 u-bg-brand-subtle u-rounded">
|
|
566
566
|
<GridCol xs={3}>
|
|
567
567
|
<DemoCard variant="secondary">Col 1</DemoCard>
|
|
@@ -573,7 +573,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
573
573
|
</div>
|
|
574
574
|
|
|
575
575
|
<div className="u-mb-6">
|
|
576
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
576
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">
|
|
577
577
|
justify-content="between"
|
|
578
578
|
</h3>
|
|
579
579
|
<Row justifyContent="between" className="u-mb-4 u-p-3 u-bg-brand-subtle u-rounded">
|
|
@@ -587,7 +587,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
587
587
|
</div>
|
|
588
588
|
|
|
589
589
|
<div className="u-mb-6">
|
|
590
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
590
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">justify-content="around"</h3>
|
|
591
591
|
<Row justifyContent="around" className="u-mb-4 u-p-3 u-bg-brand-subtle u-rounded">
|
|
592
592
|
<GridCol xs={3}>
|
|
593
593
|
<DemoCard variant="secondary">Col 1</DemoCard>
|
|
@@ -607,7 +607,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
607
607
|
</p>
|
|
608
608
|
|
|
609
609
|
<div className="u-mb-6">
|
|
610
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
610
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">align-items="start"</h3>
|
|
611
611
|
<Row
|
|
612
612
|
alignItems="start"
|
|
613
613
|
className="u-mb-4 u-bg-brand-subtle u-rounded u-p-3"
|
|
@@ -626,7 +626,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
626
626
|
</div>
|
|
627
627
|
|
|
628
628
|
<div className="u-mb-6">
|
|
629
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
629
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">align-items="center"</h3>
|
|
630
630
|
<Row
|
|
631
631
|
alignItems="center"
|
|
632
632
|
className="u-mb-4 u-bg-brand-subtle u-rounded u-p-3"
|
|
@@ -645,7 +645,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
645
645
|
</div>
|
|
646
646
|
|
|
647
647
|
<div className="u-mb-6">
|
|
648
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
648
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">align-items="end"</h3>
|
|
649
649
|
<Row
|
|
650
650
|
alignItems="end"
|
|
651
651
|
className="u-mb-4 u-bg-brand-subtle u-rounded u-p-3"
|
|
@@ -670,7 +670,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
670
670
|
<p className="u-mb-4 u-text-secondary-emphasis">Remove spacing between columns:</p>
|
|
671
671
|
|
|
672
672
|
<div className="u-mb-6">
|
|
673
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
673
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">With gutters (default)</h3>
|
|
674
674
|
<Row className="u-mb-4 u-p-3 u-bg-brand-subtle u-rounded">
|
|
675
675
|
<GridCol xs={4}>
|
|
676
676
|
<DemoCard variant="secondary">Column 1</DemoCard>
|
|
@@ -685,7 +685,7 @@ export const AlignmentAndSpacing: Story = {
|
|
|
685
685
|
</div>
|
|
686
686
|
|
|
687
687
|
<div className="u-mb-6">
|
|
688
|
-
<h3 className="u-mb-3 u-text-secondary-emphasis u-
|
|
688
|
+
<h3 className="u-mb-3 u-text-secondary-emphasis u-font-medium">No gutters</h3>
|
|
689
689
|
<Row noGutters className="u-mb-4 u-p-3 u-bg-brand-subtle u-rounded">
|
|
690
690
|
<GridCol xs={4}>
|
|
691
691
|
<DemoCard variant="accent">Column 1</DemoCard>
|
|
@@ -867,38 +867,38 @@ export const BreakpointReference: Story = {
|
|
|
867
867
|
<Grid className="u-mb-6">
|
|
868
868
|
<GridCol xs={12} sm={6} md={4} lg={3} xl={2}>
|
|
869
869
|
<DemoCard variant="secondary">
|
|
870
|
-
<div className="u-
|
|
871
|
-
<div className="u-
|
|
870
|
+
<div className="u-font-bold">Column 1</div>
|
|
871
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=3, xl=2</div>
|
|
872
872
|
</DemoCard>
|
|
873
873
|
</GridCol>
|
|
874
874
|
<GridCol xs={12} sm={6} md={4} lg={3} xl={2}>
|
|
875
875
|
<DemoCard variant="secondary">
|
|
876
|
-
<div className="u-
|
|
877
|
-
<div className="u-
|
|
876
|
+
<div className="u-font-bold">Column 2</div>
|
|
877
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=3, xl=2</div>
|
|
878
878
|
</DemoCard>
|
|
879
879
|
</GridCol>
|
|
880
880
|
<GridCol xs={12} sm={6} md={4} lg={3} xl={2}>
|
|
881
881
|
<DemoCard variant="secondary">
|
|
882
|
-
<div className="u-
|
|
883
|
-
<div className="u-
|
|
882
|
+
<div className="u-font-bold">Column 3</div>
|
|
883
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=3, xl=2</div>
|
|
884
884
|
</DemoCard>
|
|
885
885
|
</GridCol>
|
|
886
886
|
<GridCol xs={12} sm={6} md={4} lg={3} xl={2}>
|
|
887
887
|
<DemoCard variant="secondary">
|
|
888
|
-
<div className="u-
|
|
889
|
-
<div className="u-
|
|
888
|
+
<div className="u-font-bold">Column 4</div>
|
|
889
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=3, xl=2</div>
|
|
890
890
|
</DemoCard>
|
|
891
891
|
</GridCol>
|
|
892
892
|
<GridCol xs={12} sm={6} md={4} lg={3} xl={2}>
|
|
893
893
|
<DemoCard variant="secondary">
|
|
894
|
-
<div className="u-
|
|
895
|
-
<div className="u-
|
|
894
|
+
<div className="u-font-bold">Column 5</div>
|
|
895
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=3, xl=2</div>
|
|
896
896
|
</DemoCard>
|
|
897
897
|
</GridCol>
|
|
898
898
|
<GridCol xs={12} sm={6} md={4} lg={3} xl={2}>
|
|
899
899
|
<DemoCard variant="secondary">
|
|
900
|
-
<div className="u-
|
|
901
|
-
<div className="u-
|
|
900
|
+
<div className="u-font-bold">Column 6</div>
|
|
901
|
+
<div className="u-text-sm u-mt-2">xs=12, sm=6, md=4, lg=3, xl=2</div>
|
|
902
902
|
</DemoCard>
|
|
903
903
|
</GridCol>
|
|
904
904
|
</Grid>
|
|
@@ -275,7 +275,7 @@ export const ProgressiveImageLoading: Story = {
|
|
|
275
275
|
<h4 className="u-mb-2">Loading Progress</h4>
|
|
276
276
|
{totalCount > 0 && (
|
|
277
277
|
<div className="u-mb-2">
|
|
278
|
-
<div className="u-
|
|
278
|
+
<div className="u-flex u-justify-between u-mb-1">
|
|
279
279
|
<span>
|
|
280
280
|
Loading images: {loadedCount} of {totalCount}
|
|
281
281
|
</span>
|
|
@@ -356,7 +356,7 @@ export const MixedContent: Story = {
|
|
|
356
356
|
<div className="u-p-4 u-border u-rounded u-bg-brand-subtle u-h-100">
|
|
357
357
|
<h4 className="u-mb-3">Custom Content</h4>
|
|
358
358
|
<p>This is a custom content block using utility classes.</p>
|
|
359
|
-
<div className="u-
|
|
359
|
+
<div className="u-flex u-justify-between u-mt-3">
|
|
360
360
|
<span className="u-badge u-badge-primary">New</span>
|
|
361
361
|
<span className="u-badge u-badge-secondary">Featured</span>
|
|
362
362
|
</div>
|
|
@@ -59,10 +59,19 @@ export function useAccordion(
|
|
|
59
59
|
*/
|
|
60
60
|
const toggle = (): void => {
|
|
61
61
|
if (!defaultProps.disabled) {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const nextOpen = !isOpen;
|
|
63
|
+
|
|
64
|
+
if (!isControlled) {
|
|
65
|
+
setInternalOpen(nextOpen);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
defaultProps.onOpenChange?.(nextOpen);
|
|
69
|
+
|
|
70
|
+
// Call legacy handlers
|
|
71
|
+
if (nextOpen) {
|
|
72
|
+
defaultProps.onOpen?.();
|
|
64
73
|
} else {
|
|
65
|
-
|
|
74
|
+
defaultProps.onClose?.();
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
};
|
|
@@ -5,7 +5,7 @@ interface BreadcrumbOptions {
|
|
|
5
5
|
items: BreadcrumbItem[];
|
|
6
6
|
divider?: React.ReactNode;
|
|
7
7
|
className?: string;
|
|
8
|
-
|
|
8
|
+
'aria-label'?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -19,7 +19,7 @@ export function useBreadcrumb(initialOptions?: Partial<BreadcrumbOptions>) {
|
|
|
19
19
|
items: [],
|
|
20
20
|
divider: BREADCRUMB.DEFAULTS.DIVIDER,
|
|
21
21
|
className: '',
|
|
22
|
-
|
|
22
|
+
'aria-label': 'Breadcrumb',
|
|
23
23
|
...initialOptions,
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -9,8 +9,8 @@ export function useCallout(initialProps?: Partial<CalloutProps>) {
|
|
|
9
9
|
// Default callout properties
|
|
10
10
|
const defaultProps: Partial<CalloutProps> = {
|
|
11
11
|
variant: 'primary',
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
compact: false,
|
|
13
|
+
isToast: false,
|
|
14
14
|
glass: false,
|
|
15
15
|
...initialProps,
|
|
16
16
|
};
|
|
@@ -23,18 +23,18 @@ export function useCallout(initialProps?: Partial<CalloutProps>) {
|
|
|
23
23
|
const generateCalloutClass = (props: Partial<CalloutProps>): string => {
|
|
24
24
|
const {
|
|
25
25
|
variant = defaultProps.variant,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
compact = defaultProps.compact,
|
|
27
|
+
isToast = defaultProps.isToast,
|
|
28
28
|
glass = defaultProps.glass,
|
|
29
29
|
className = '',
|
|
30
30
|
} = props;
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
const toastClass =
|
|
32
|
+
const compactClass = compact ? 'c-callout--compact' : '';
|
|
33
|
+
const toastClass = isToast ? 'c-callout--toast' : '';
|
|
34
34
|
const variantClass = variant ? `c-callout--${variant}` : '';
|
|
35
35
|
const glassClass = glass ? 'c-callout--glass' : '';
|
|
36
36
|
|
|
37
|
-
return `c-callout ${variantClass} ${
|
|
37
|
+
return `c-callout ${variantClass} ${compactClass} ${toastClass} ${glassClass} ${className}`.trim();
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ControlOption {
|
|
4
|
+
type: 'select' | 'slider' | 'text' | 'checkbox';
|
|
5
|
+
label: string;
|
|
6
|
+
value: any;
|
|
7
|
+
onChange: (value: any) => void;
|
|
8
|
+
options?: string[];
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
step?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface InteractiveDemoProps {
|
|
15
|
+
controls: ControlOption[];
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const InteractiveDemo: React.FC<InteractiveDemoProps> = ({
|
|
20
|
+
controls,
|
|
21
|
+
children,
|
|
22
|
+
}) => {
|
|
23
|
+
const renderControl = (control: ControlOption, index: number) => {
|
|
24
|
+
const baseId = `control-${index}`;
|
|
25
|
+
|
|
26
|
+
switch (control.type) {
|
|
27
|
+
case 'select':
|
|
28
|
+
return (
|
|
29
|
+
<div key={baseId} className="mb-4">
|
|
30
|
+
<label htmlFor={baseId} className="block text-sm font-medium mb-2">
|
|
31
|
+
{control.label}
|
|
32
|
+
</label>
|
|
33
|
+
<select
|
|
34
|
+
id={baseId}
|
|
35
|
+
value={control.value}
|
|
36
|
+
onChange={(e) => control.onChange(e.target.value)}
|
|
37
|
+
className="w-full px-3 py-2 border rounded-lg"
|
|
38
|
+
>
|
|
39
|
+
{control.options?.map((option) => (
|
|
40
|
+
<option key={option} value={option}>
|
|
41
|
+
{option}
|
|
42
|
+
</option>
|
|
43
|
+
))}
|
|
44
|
+
</select>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
case 'slider':
|
|
49
|
+
return (
|
|
50
|
+
<div key={baseId} className="mb-4">
|
|
51
|
+
<label htmlFor={baseId} className="block text-sm font-medium mb-2">
|
|
52
|
+
{control.label}: {control.value}
|
|
53
|
+
</label>
|
|
54
|
+
<input
|
|
55
|
+
id={baseId}
|
|
56
|
+
type="range"
|
|
57
|
+
min={control.min}
|
|
58
|
+
max={control.max}
|
|
59
|
+
step={control.step}
|
|
60
|
+
value={control.value}
|
|
61
|
+
onChange={(e) => control.onChange(Number(e.target.value))}
|
|
62
|
+
className="w-full"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
case 'text':
|
|
68
|
+
return (
|
|
69
|
+
<div key={baseId} className="mb-4">
|
|
70
|
+
<label htmlFor={baseId} className="block text-sm font-medium mb-2">
|
|
71
|
+
{control.label}
|
|
72
|
+
</label>
|
|
73
|
+
<input
|
|
74
|
+
id={baseId}
|
|
75
|
+
type="text"
|
|
76
|
+
value={control.value}
|
|
77
|
+
onChange={(e) => control.onChange(e.target.value)}
|
|
78
|
+
className="w-full px-3 py-2 border rounded-lg"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
case 'checkbox':
|
|
84
|
+
return (
|
|
85
|
+
<div key={baseId} className="mb-4">
|
|
86
|
+
<label className="flex items-center space-x-2">
|
|
87
|
+
<input
|
|
88
|
+
type="checkbox"
|
|
89
|
+
checked={control.value}
|
|
90
|
+
onChange={(e) => control.onChange(e.target.checked)}
|
|
91
|
+
className="rounded"
|
|
92
|
+
/>
|
|
93
|
+
<span className="text-sm font-medium">{control.label}</span>
|
|
94
|
+
</label>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
default:
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div className="bg-white rounded-lg shadow-lg p-6 mb-8">
|
|
105
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6">
|
|
106
|
+
{controls.map(renderControl)}
|
|
107
|
+
</div>
|
|
108
|
+
<div className="border-t pt-6">
|
|
109
|
+
{children}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
};
|