@shohojdhara/atomix 0.5.1 → 0.5.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/atomix.config.ts +12 -0
- package/build-tools/webpack-loader.js +5 -4
- package/dist/atomix.css +138 -17
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +1 -1
- package/dist/atomix.min.css.map +1 -1
- package/dist/build-tools/webpack-loader.js +5 -4
- package/dist/charts.d.ts +23 -23
- package/dist/charts.js +40 -37
- package/dist/charts.js.map +1 -1
- package/dist/config.d.ts +624 -0
- package/dist/config.js +59 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts +2 -2
- package/dist/core.js +111 -50
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +3 -6
- package/dist/forms.js +2 -2
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +1 -1
- package/dist/heavy.js +173 -111
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +98 -65
- package/dist/index.esm.js +427 -422
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +394 -391
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layout.js +59 -60
- package/dist/layout.js.map +1 -1
- package/dist/theme.js +4 -4
- package/dist/theme.js.map +1 -1
- package/package.json +14 -9
- package/scripts/atomix-cli.js +15 -1
- package/scripts/cli/__tests__/complexity-utils.test.js +24 -0
- package/scripts/cli/__tests__/detector.test.js +50 -0
- package/scripts/cli/__tests__/template-engine.test.js +23 -0
- package/scripts/cli/__tests__/test-setup.js +3 -0
- package/scripts/cli/commands/doctor.js +15 -3
- package/scripts/cli/commands/generate.js +113 -51
- package/scripts/cli/internal/ai-engine.js +30 -10
- package/scripts/cli/internal/complexity-utils.js +60 -0
- package/scripts/cli/internal/component-validator.js +49 -16
- package/scripts/cli/internal/generator.js +89 -36
- package/scripts/cli/internal/hook-generator.js +5 -2
- package/scripts/cli/internal/itcss-generator.js +16 -12
- package/scripts/cli/templates/next-templates.js +81 -30
- package/scripts/cli/templates/storybook-templates.js +12 -2
- package/scripts/cli/utils/detector.js +45 -7
- package/scripts/cli/utils/diagnostics.js +78 -0
- package/scripts/cli/utils/telemetry.js +13 -0
- package/src/components/Accordion/Accordion.stories.tsx +4 -0
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +1 -1
- package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +219 -0
- package/src/components/AtomixGlass/glass-utils.ts +1 -1
- package/src/components/Button/Button.tsx +114 -57
- package/src/components/Callout/Callout.tsx +4 -4
- package/src/components/Chart/ChartRenderer.tsx +1 -1
- package/src/components/Chart/DonutChart.tsx +11 -8
- package/src/components/EdgePanel/EdgePanel.tsx +119 -115
- package/src/components/Form/Select.tsx +4 -4
- package/src/components/List/List.tsx +4 -4
- package/src/components/Navigation/SideMenu/SideMenu.tsx +6 -6
- package/src/components/PhotoViewer/PhotoViewerImage.tsx +1 -1
- package/src/components/ProductReview/ProductReview.tsx +4 -2
- package/src/components/Rating/Rating.tsx +4 -2
- package/src/components/SectionIntro/SectionIntro.tsx +4 -2
- package/src/components/Steps/Steps.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +5 -5
- package/src/components/Testimonial/Testimonial.tsx +4 -2
- package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
- package/src/layouts/CssGrid/CssGrid.stories.tsx +464 -0
- package/src/layouts/CssGrid/CssGrid.tsx +215 -0
- package/src/layouts/CssGrid/index.ts +8 -0
- package/src/layouts/CssGrid/scripts/CssGrid.js +284 -0
- package/src/layouts/CssGrid/scripts/index.js +43 -0
- package/src/layouts/Grid/scripts/Container.js +139 -0
- package/src/layouts/Grid/scripts/Grid.js +184 -0
- package/src/layouts/Grid/scripts/GridCol.js +273 -0
- package/src/layouts/Grid/scripts/Row.js +154 -0
- package/src/layouts/Grid/scripts/index.js +48 -0
- package/src/layouts/MasonryGrid/MasonryGrid.tsx +71 -59
- package/src/lib/composables/atomix-glass/useGlassSize.ts +1 -1
- package/src/lib/composables/useAccordion.ts +5 -5
- package/src/lib/composables/useAtomixGlass.ts +3 -3
- package/src/lib/composables/useBarChart.ts +2 -2
- package/src/lib/composables/useChart.ts +3 -2
- package/src/lib/composables/useChartToolbar.ts +48 -66
- package/src/lib/composables/useDataTable.ts +1 -1
- package/src/lib/composables/useDatePicker.ts +2 -2
- package/src/lib/composables/useEdgePanel.ts +45 -54
- package/src/lib/composables/useHeroBackgroundSlider.ts +5 -5
- package/src/lib/composables/usePhotoViewer.ts +2 -3
- package/src/lib/composables/usePieChart.ts +1 -1
- package/src/lib/composables/usePopover.ts +151 -139
- package/src/lib/composables/useSideMenu.ts +28 -41
- package/src/lib/composables/useSlider.ts +2 -6
- package/src/lib/composables/useTooltip.ts +2 -2
- package/src/lib/config/index.ts +39 -0
- package/src/lib/theme/devtools/Comparator.tsx +1 -1
- package/src/lib/theme/devtools/Inspector.tsx +1 -1
- package/src/lib/theme/devtools/LiveEditor.tsx +1 -1
- package/src/lib/theme/runtime/ThemeProvider.tsx +1 -1
- package/src/styles/01-settings/_index.scss +1 -0
- package/src/styles/01-settings/_settings.atomix-glass.scss +174 -0
- package/src/styles/01-settings/_settings.masonry-grid.scss +42 -6
- package/src/styles/02-tools/_tools.glass.scss +6 -0
- package/src/styles/05-objects/_objects.masonry-grid.scss +162 -24
- package/src/styles/06-components/_components.atomix-glass.scss +4 -4
- package/src/lib/composables/useBreadcrumb.ts +0 -81
- package/src/lib/composables/useChartInteractions.ts +0 -123
- package/src/lib/composables/useChartPerformance.ts +0 -347
- package/src/lib/composables/useDropdown.ts +0 -338
- package/src/lib/composables/useModal.ts +0 -110
- package/src/lib/hooks/usePerformanceMonitor.ts +0 -148
- package/src/lib/utils/displacement-generator.ts +0 -92
- package/src/lib/utils/memoryMonitor.ts +0 -191
- package/src/styles/01-settings/_settings.testtypecheck.scss +0 -53
- package/src/styles/01-settings/_settings.typedbutton.scss +0 -53
- package/src/styles/06-components/_components.testbutton.scss +0 -212
- package/src/styles/06-components/_components.testtypecheck.scss +0 -212
- package/src/styles/06-components/_components.typedbutton.scss +0 -212
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Grid - Vanilla JavaScript implementation of the Grid component
|
|
3
|
+
* @description Provides DOM manipulation for grid layouts with responsive alignment controls
|
|
4
|
+
* @requires ../Grid.css (auto-generated)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Grid component class for responsive layout management
|
|
9
|
+
*/
|
|
10
|
+
export class Grid {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Grid instance
|
|
13
|
+
* @param {Object} options - Grid configuration options
|
|
14
|
+
* @param {HTMLElement} options.element - The container element
|
|
15
|
+
* @param {string} [options.className=''] - Additional CSS classes
|
|
16
|
+
* @param {'start'|'end'|'center'|'between'|'around'|'evenly'} [options.justifyContent] - Horizontal alignment
|
|
17
|
+
* @param {'start'|'end'|'center'|'baseline'|'stretch'} [options.alignItems] - Vertical alignment
|
|
18
|
+
* @param {boolean} [options.noGutters=false] - Remove gutters between columns
|
|
19
|
+
* @param {'row'|'column'|'row-reverse'|'column-reverse'} [options.direction] - Flex direction
|
|
20
|
+
* @param {'nowrap'|'wrap'|'wrap-reverse'} [options.wrap] - Flex wrap behavior
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.element = options.element;
|
|
24
|
+
this.options = {
|
|
25
|
+
className: options.className || '',
|
|
26
|
+
justifyContent: options.justifyContent,
|
|
27
|
+
alignItems: options.alignItems,
|
|
28
|
+
noGutters: options.noGutters || false,
|
|
29
|
+
direction: options.direction,
|
|
30
|
+
wrap: options.wrap,
|
|
31
|
+
...options
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this.init();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Initialize the grid component
|
|
39
|
+
*/
|
|
40
|
+
init() {
|
|
41
|
+
this.updateClasses();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Update CSS classes based on current options
|
|
46
|
+
*/
|
|
47
|
+
updateClasses() {
|
|
48
|
+
const classes = ['o-grid'];
|
|
49
|
+
|
|
50
|
+
if (this.options.justifyContent) {
|
|
51
|
+
classes.push(`u-justify-content-${this.options.justifyContent}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (this.options.alignItems) {
|
|
55
|
+
classes.push(`u-align-items-${this.options.alignItems}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (this.options.noGutters) {
|
|
59
|
+
classes.push('o-grid--no-gutters');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (this.options.direction) {
|
|
63
|
+
classes.push(`u-flex-direction-${this.options.direction}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.options.wrap) {
|
|
67
|
+
classes.push(`u-flex-wrap-${this.options.wrap}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.options.className) {
|
|
71
|
+
classes.push(this.options.className);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.element.className = classes.join(' ');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Update grid options and refresh styling
|
|
79
|
+
* @param {Object} newOptions - New configuration options
|
|
80
|
+
*/
|
|
81
|
+
update(newOptions) {
|
|
82
|
+
this.options = { ...this.options, ...newOptions };
|
|
83
|
+
this.updateClasses();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Set horizontal alignment
|
|
88
|
+
* @param {'start'|'end'|'center'|'between'|'around'|'evenly'} alignment - Horizontal alignment
|
|
89
|
+
*/
|
|
90
|
+
setJustifyContent(alignment) {
|
|
91
|
+
this.update({ justifyContent: alignment });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Set vertical alignment
|
|
96
|
+
* @param {'start'|'end'|'center'|'baseline'|'stretch'} alignment - Vertical alignment
|
|
97
|
+
*/
|
|
98
|
+
setAlignItems(alignment) {
|
|
99
|
+
this.update({ alignItems: alignment });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Toggle gutters
|
|
104
|
+
* @param {boolean} noGutters - Whether to remove gutters
|
|
105
|
+
*/
|
|
106
|
+
setNoGutters(noGutters) {
|
|
107
|
+
this.update({ noGutters });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Set flex direction
|
|
112
|
+
* @param {'row'|'column'|'row-reverse'|'column-reverse'} direction - Flex direction
|
|
113
|
+
*/
|
|
114
|
+
setDirection(direction) {
|
|
115
|
+
this.update({ direction });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Set flex wrap behavior
|
|
120
|
+
* @param {'nowrap'|'wrap'|'wrap-reverse'} wrap - Wrap behavior
|
|
121
|
+
*/
|
|
122
|
+
setWrap(wrap) {
|
|
123
|
+
this.update({ wrap });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Reset grid to default state
|
|
128
|
+
*/
|
|
129
|
+
reset() {
|
|
130
|
+
this.options = {
|
|
131
|
+
className: '',
|
|
132
|
+
justifyContent: undefined,
|
|
133
|
+
alignItems: undefined,
|
|
134
|
+
noGutters: false,
|
|
135
|
+
direction: undefined,
|
|
136
|
+
wrap: undefined
|
|
137
|
+
};
|
|
138
|
+
this.updateClasses();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Destroy the grid instance and clean up
|
|
143
|
+
*/
|
|
144
|
+
destroy() {
|
|
145
|
+
this.element.className = '';
|
|
146
|
+
this.element = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Create a grid instance for a DOM element
|
|
152
|
+
* @param {HTMLElement} element - The DOM element to initialize as grid
|
|
153
|
+
* @param {Object} options - Grid configuration options
|
|
154
|
+
* @returns {Grid} Grid instance
|
|
155
|
+
*/
|
|
156
|
+
export function createGrid(element, options = {}) {
|
|
157
|
+
return new Grid({ element, ...options });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Initialize grid components on page load
|
|
162
|
+
* @param {string} [selector='[data-grid]'] - CSS selector for grid elements
|
|
163
|
+
* @param {Object} [defaultOptions={}] - Default grid options
|
|
164
|
+
*/
|
|
165
|
+
export function initGrids(selector = '[data-grid]', defaultOptions = {}) {
|
|
166
|
+
const elements = document.querySelectorAll(selector);
|
|
167
|
+
const grids = [];
|
|
168
|
+
|
|
169
|
+
elements.forEach(element => {
|
|
170
|
+
const options = {
|
|
171
|
+
...defaultOptions,
|
|
172
|
+
...(element.dataset.gridOptions ? JSON.parse(element.dataset.gridOptions) : {})
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
grids.push(createGrid(element, options));
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return grids;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Auto-initialize on DOM ready
|
|
182
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
183
|
+
initGrids();
|
|
184
|
+
});
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file GridCol - Vanilla JavaScript implementation of the GridCol component
|
|
3
|
+
* @description Provides DOM manipulation for grid columns with responsive sizing and offset controls
|
|
4
|
+
* @requires ../Grid.css (auto-generated)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Grid column component class for responsive column management
|
|
9
|
+
*/
|
|
10
|
+
export class GridCol {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new GridCol instance
|
|
13
|
+
* @param {Object} options - Grid column configuration options
|
|
14
|
+
* @param {HTMLElement} options.element - The column element
|
|
15
|
+
* @param {string} [options.className=''] - Additional CSS classes
|
|
16
|
+
* @param {number|'auto'|boolean} [options.xs] - Extra small breakpoint size
|
|
17
|
+
* @param {number|'auto'|boolean} [options.sm] - Small breakpoint size
|
|
18
|
+
* @param {number|'auto'|boolean} [options.md] - Medium breakpoint size
|
|
19
|
+
* @param {number|'auto'|boolean} [options.lg] - Large breakpoint size
|
|
20
|
+
* @param {number|'auto'|boolean} [options.xl] - Extra large breakpoint size
|
|
21
|
+
* @param {number|'auto'|boolean} [options.xxl] - Extra extra large breakpoint size
|
|
22
|
+
* @param {number} [options.offsetXs] - Extra small offset
|
|
23
|
+
* @param {number} [options.offsetSm] - Small offset
|
|
24
|
+
* @param {number} [options.offsetMd] - Medium offset
|
|
25
|
+
* @param {number} [options.offsetLg] - Large offset
|
|
26
|
+
* @param {number} [options.offsetXl] - Extra large offset
|
|
27
|
+
* @param {number} [options.offsetXxl] - Extra extra large offset
|
|
28
|
+
* @param {boolean} [options.grow] - Flex grow property
|
|
29
|
+
* @param {boolean} [options.shrink] - Flex shrink property
|
|
30
|
+
* @param {string} [options.basis] - Flex basis property
|
|
31
|
+
* @param {'start'|'end'|'center'|'baseline'|'stretch'} [options.align] - Column alignment
|
|
32
|
+
*/
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.element = options.element;
|
|
35
|
+
this.options = {
|
|
36
|
+
className: options.className || '',
|
|
37
|
+
xs: options.xs,
|
|
38
|
+
sm: options.sm,
|
|
39
|
+
md: options.md,
|
|
40
|
+
lg: options.lg,
|
|
41
|
+
xl: options.xl,
|
|
42
|
+
xxl: options.xxl,
|
|
43
|
+
offsetXs: options.offsetXs,
|
|
44
|
+
offsetSm: options.offsetSm,
|
|
45
|
+
offsetMd: options.offsetMd,
|
|
46
|
+
offsetLg: options.offsetLg,
|
|
47
|
+
offsetXl: options.offsetXl,
|
|
48
|
+
offsetXxl: options.offsetXxl,
|
|
49
|
+
grow: options.grow,
|
|
50
|
+
shrink: options.shrink,
|
|
51
|
+
basis: options.basis,
|
|
52
|
+
align: options.align,
|
|
53
|
+
...options
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
this.init();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Initialize the grid column component
|
|
61
|
+
*/
|
|
62
|
+
init() {
|
|
63
|
+
this.updateClasses();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Process responsive column sizing prop
|
|
68
|
+
* @param {number|'auto'|boolean} value - The prop value
|
|
69
|
+
* @param {string} breakpoint - The breakpoint name
|
|
70
|
+
* @returns {string|null} CSS class or null
|
|
71
|
+
*/
|
|
72
|
+
processResponsiveProp(value, breakpoint) {
|
|
73
|
+
if (value === undefined || value === false) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Handle boolean values
|
|
78
|
+
if (value === true) {
|
|
79
|
+
return breakpoint === 'xs' ? 'o-grid__col--auto' : `o-grid__col--${breakpoint}-auto`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Handle string/number values
|
|
83
|
+
if (breakpoint === 'xs') {
|
|
84
|
+
return value === 'auto' ? 'o-grid__col--auto' : `o-grid__col--${value}`;
|
|
85
|
+
} else {
|
|
86
|
+
return value === 'auto' ? `o-grid__col--${breakpoint}-auto` : `o-grid__col--${breakpoint}-${value}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Update CSS classes based on current options
|
|
92
|
+
*/
|
|
93
|
+
updateClasses() {
|
|
94
|
+
const isDefaultAuto = !this.options.xs && !this.options.sm && !this.options.md &&
|
|
95
|
+
!this.options.lg && !this.options.xl && !this.options.xxl;
|
|
96
|
+
|
|
97
|
+
const classes = isDefaultAuto ? ['o-grid__col', 'o-grid__col--auto'] : ['o-grid__col'];
|
|
98
|
+
|
|
99
|
+
// Add column size classes
|
|
100
|
+
const sizeClasses = [
|
|
101
|
+
this.processResponsiveProp(this.options.xs, 'xs'),
|
|
102
|
+
this.processResponsiveProp(this.options.sm, 'sm'),
|
|
103
|
+
this.processResponsiveProp(this.options.md, 'md'),
|
|
104
|
+
this.processResponsiveProp(this.options.lg, 'lg'),
|
|
105
|
+
this.processResponsiveProp(this.options.xl, 'xl'),
|
|
106
|
+
this.processResponsiveProp(this.options.xxl, 'xxl')
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
sizeClasses.forEach(cls => {
|
|
110
|
+
if (cls) classes.push(cls);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Add offset classes
|
|
114
|
+
if (this.options.offsetXs) classes.push(`o-grid__offset--${this.options.offsetXs}`);
|
|
115
|
+
if (this.options.offsetSm) classes.push(`o-grid__offset--sm-${this.options.offsetSm}`);
|
|
116
|
+
if (this.options.offsetMd) classes.push(`o-grid__offset--md-${this.options.offsetMd}`);
|
|
117
|
+
if (this.options.offsetLg) classes.push(`o-grid__offset--lg-${this.options.offsetLg}`);
|
|
118
|
+
if (this.options.offsetXl) classes.push(`o-grid__offset--xl-${this.options.offsetXl}`);
|
|
119
|
+
if (this.options.offsetXxl) classes.push(`o-grid__offset--xxl-${this.options.offsetXxl}`);
|
|
120
|
+
|
|
121
|
+
// Add flex properties
|
|
122
|
+
if (this.options.grow !== undefined) {
|
|
123
|
+
classes.push(this.options.grow ? 'u-flex-grow-1' : 'u-flex-grow-0');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (this.options.shrink !== undefined) {
|
|
127
|
+
classes.push(this.options.shrink ? 'u-flex-shrink-1' : 'u-flex-shrink-0');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.options.basis) {
|
|
131
|
+
classes.push(`u-flex-basis-${this.options.basis}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (this.options.align) {
|
|
135
|
+
classes.push(`u-align-self-${this.options.align}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.options.className) {
|
|
139
|
+
classes.push(this.options.className);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.element.className = classes.join(' ');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Update column options and refresh styling
|
|
147
|
+
* @param {Object} newOptions - New configuration options
|
|
148
|
+
*/
|
|
149
|
+
update(newOptions) {
|
|
150
|
+
this.options = { ...this.options, ...newOptions };
|
|
151
|
+
this.updateClasses();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Set column size for a specific breakpoint
|
|
156
|
+
* @param {string} breakpoint - Breakpoint name (xs, sm, md, lg, xl, xxl)
|
|
157
|
+
* @param {number|'auto'|boolean} size - Column size
|
|
158
|
+
*/
|
|
159
|
+
setSize(breakpoint, size) {
|
|
160
|
+
this.update({ [breakpoint]: size });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Set column offset for a specific breakpoint
|
|
165
|
+
* @param {string} breakpoint - Breakpoint name (xs, sm, md, lg, xl, xxl)
|
|
166
|
+
* @param {number} offset - Offset value
|
|
167
|
+
*/
|
|
168
|
+
setOffset(breakpoint, offset) {
|
|
169
|
+
this.update({ [`offset${breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1)}`]: offset });
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Set flex grow property
|
|
174
|
+
* @param {boolean} grow - Whether to grow
|
|
175
|
+
*/
|
|
176
|
+
setGrow(grow) {
|
|
177
|
+
this.update({ grow });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Set flex shrink property
|
|
182
|
+
* @param {boolean} shrink - Whether to shrink
|
|
183
|
+
*/
|
|
184
|
+
setShrink(shrink) {
|
|
185
|
+
this.update({ shrink });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Set flex basis property
|
|
190
|
+
* @param {string} basis - Flex basis value
|
|
191
|
+
*/
|
|
192
|
+
setBasis(basis) {
|
|
193
|
+
this.update({ basis });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Set column alignment
|
|
198
|
+
* @param {'start'|'end'|'center'|'baseline'|'stretch'} align - Alignment value
|
|
199
|
+
*/
|
|
200
|
+
setAlign(align) {
|
|
201
|
+
this.update({ align });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Reset column to default state
|
|
206
|
+
*/
|
|
207
|
+
reset() {
|
|
208
|
+
this.options = {
|
|
209
|
+
className: '',
|
|
210
|
+
xs: undefined,
|
|
211
|
+
sm: undefined,
|
|
212
|
+
md: undefined,
|
|
213
|
+
lg: undefined,
|
|
214
|
+
xl: undefined,
|
|
215
|
+
xxl: undefined,
|
|
216
|
+
offsetXs: undefined,
|
|
217
|
+
offsetSm: undefined,
|
|
218
|
+
offsetMd: undefined,
|
|
219
|
+
offsetLg: undefined,
|
|
220
|
+
offsetXl: undefined,
|
|
221
|
+
offsetXxl: undefined,
|
|
222
|
+
grow: undefined,
|
|
223
|
+
shrink: undefined,
|
|
224
|
+
basis: undefined,
|
|
225
|
+
align: undefined
|
|
226
|
+
};
|
|
227
|
+
this.updateClasses();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Destroy the column instance and clean up
|
|
232
|
+
*/
|
|
233
|
+
destroy() {
|
|
234
|
+
this.element.className = '';
|
|
235
|
+
this.element = null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Create a grid column instance for a DOM element
|
|
241
|
+
* @param {HTMLElement} element - The DOM element to initialize as grid column
|
|
242
|
+
* @param {Object} options - Grid column configuration options
|
|
243
|
+
* @returns {GridCol} Grid column instance
|
|
244
|
+
*/
|
|
245
|
+
export function createGridCol(element, options = {}) {
|
|
246
|
+
return new GridCol({ element, ...options });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Initialize grid columns on page load
|
|
251
|
+
* @param {string} [selector='[data-grid-col]'] - CSS selector for grid column elements
|
|
252
|
+
* @param {Object} [defaultOptions={}] - Default grid column options
|
|
253
|
+
*/
|
|
254
|
+
export function initGridCols(selector = '[data-grid-col]', defaultOptions = {}) {
|
|
255
|
+
const elements = document.querySelectorAll(selector);
|
|
256
|
+
const columns = [];
|
|
257
|
+
|
|
258
|
+
elements.forEach(element => {
|
|
259
|
+
const options = {
|
|
260
|
+
...defaultOptions,
|
|
261
|
+
...(element.dataset.gridColOptions ? JSON.parse(element.dataset.gridColOptions) : {})
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
columns.push(createGridCol(element, options));
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return columns;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Auto-initialize on DOM ready
|
|
271
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
272
|
+
initGridCols();
|
|
273
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Row - Vanilla JavaScript implementation of the Row component
|
|
3
|
+
* @description Provides DOM manipulation for grid rows with alignment controls
|
|
4
|
+
* @requires ../Grid.css (auto-generated)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Row component class for responsive row management
|
|
9
|
+
*/
|
|
10
|
+
export class Row {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Row instance
|
|
13
|
+
* @param {Object} options - Row configuration options
|
|
14
|
+
* @param {HTMLElement} options.element - The row element
|
|
15
|
+
* @param {string} [options.className=''] - Additional CSS classes
|
|
16
|
+
* @param {'start'|'end'|'center'|'between'|'around'|'evenly'} [options.justifyContent] - Horizontal alignment
|
|
17
|
+
* @param {'start'|'end'|'center'|'baseline'|'stretch'} [options.alignItems] - Vertical alignment
|
|
18
|
+
* @param {boolean} [options.noGutters=false] - Remove gutters between columns
|
|
19
|
+
*/
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.element = options.element;
|
|
22
|
+
this.options = {
|
|
23
|
+
className: options.className || '',
|
|
24
|
+
justifyContent: options.justifyContent,
|
|
25
|
+
alignItems: options.alignItems,
|
|
26
|
+
noGutters: options.noGutters || false,
|
|
27
|
+
...options
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
this.init();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the row component
|
|
35
|
+
*/
|
|
36
|
+
init() {
|
|
37
|
+
this.updateClasses();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Update CSS classes based on current options
|
|
42
|
+
*/
|
|
43
|
+
updateClasses() {
|
|
44
|
+
const classes = ['o-grid'];
|
|
45
|
+
|
|
46
|
+
if (this.options.justifyContent) {
|
|
47
|
+
classes.push(`u-justify-content-${this.options.justifyContent}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (this.options.alignItems) {
|
|
51
|
+
classes.push(`u-align-items-${this.options.alignItems}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (this.options.noGutters) {
|
|
55
|
+
classes.push('o-grid--no-gutters');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (this.options.className) {
|
|
59
|
+
classes.push(this.options.className);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.element.className = classes.join(' ');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Update row options and refresh styling
|
|
67
|
+
* @param {Object} newOptions - New configuration options
|
|
68
|
+
*/
|
|
69
|
+
update(newOptions) {
|
|
70
|
+
this.options = { ...this.options, ...newOptions };
|
|
71
|
+
this.updateClasses();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Set horizontal alignment
|
|
76
|
+
* @param {'start'|'end'|'center'|'between'|'around'|'evenly'} alignment - Horizontal alignment
|
|
77
|
+
*/
|
|
78
|
+
setJustifyContent(alignment) {
|
|
79
|
+
this.update({ justifyContent: alignment });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Set vertical alignment
|
|
84
|
+
* @param {'start'|'end'|'center'|'baseline'|'stretch'} alignment - Vertical alignment
|
|
85
|
+
*/
|
|
86
|
+
setAlignItems(alignment) {
|
|
87
|
+
this.update({ alignItems: alignment });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Toggle gutters
|
|
92
|
+
* @param {boolean} noGutters - Whether to remove gutters
|
|
93
|
+
*/
|
|
94
|
+
setNoGutters(noGutters) {
|
|
95
|
+
this.update({ noGutters });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Reset row to default state
|
|
100
|
+
*/
|
|
101
|
+
reset() {
|
|
102
|
+
this.options = {
|
|
103
|
+
className: '',
|
|
104
|
+
justifyContent: undefined,
|
|
105
|
+
alignItems: undefined,
|
|
106
|
+
noGutters: false
|
|
107
|
+
};
|
|
108
|
+
this.updateClasses();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Destroy the row instance and clean up
|
|
113
|
+
*/
|
|
114
|
+
destroy() {
|
|
115
|
+
this.element.className = '';
|
|
116
|
+
this.element = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Create a row instance for a DOM element
|
|
122
|
+
* @param {HTMLElement} element - The DOM element to initialize as row
|
|
123
|
+
* @param {Object} options - Row configuration options
|
|
124
|
+
* @returns {Row} Row instance
|
|
125
|
+
*/
|
|
126
|
+
export function createRow(element, options = {}) {
|
|
127
|
+
return new Row({ element, ...options });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Initialize row components on page load
|
|
132
|
+
* @param {string} [selector='[data-row]'] - CSS selector for row elements
|
|
133
|
+
* @param {Object} [defaultOptions={}] - Default row options
|
|
134
|
+
*/
|
|
135
|
+
export function initRows(selector = '[data-row]', defaultOptions = {}) {
|
|
136
|
+
const elements = document.querySelectorAll(selector);
|
|
137
|
+
const rows = [];
|
|
138
|
+
|
|
139
|
+
elements.forEach(element => {
|
|
140
|
+
const options = {
|
|
141
|
+
...defaultOptions,
|
|
142
|
+
...(element.dataset.rowOptions ? JSON.parse(element.dataset.rowOptions) : {})
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
rows.push(createRow(element, options));
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return rows;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Auto-initialize on DOM ready
|
|
152
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
153
|
+
initRows();
|
|
154
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Grid Scripts Index
|
|
3
|
+
* @description Entry point for vanilla JavaScript grid implementations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export * from './Grid.js';
|
|
7
|
+
export * from './GridCol.js';
|
|
8
|
+
export * from './Row.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Combine grid components for easy initialization
|
|
12
|
+
* @param {Object} options - Global initialization options
|
|
13
|
+
* @param {string} [options.gridSelector='[data-grid]'] - Grid element selector
|
|
14
|
+
* @param {string} [options.colSelector='[data-grid-col]'] - Grid column selector
|
|
15
|
+
* @param {string} [options.rowSelector='[data-row]'] - Row element selector
|
|
16
|
+
* @returns {Object} Grid instances by type
|
|
17
|
+
*/
|
|
18
|
+
export function initGridComponents(options = {}) {
|
|
19
|
+
const {
|
|
20
|
+
gridSelector = '[data-grid]',
|
|
21
|
+
colSelector = '[data-grid-col]',
|
|
22
|
+
rowSelector = '[data-row]'
|
|
23
|
+
} = options;
|
|
24
|
+
|
|
25
|
+
const grids = typeof initGrids === 'function' ? initGrids(gridSelector) : [];
|
|
26
|
+
const columns = typeof initGridCols === 'function' ? initGridCols(colSelector) : [];
|
|
27
|
+
const rows = typeof initRows === 'function' ? initRows(rowSelector) : [];
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
grids,
|
|
31
|
+
columns,
|
|
32
|
+
rows,
|
|
33
|
+
destroy: () => {
|
|
34
|
+
[...grids, ...columns, ...rows].forEach(instance => {
|
|
35
|
+
if (instance && typeof instance.destroy === 'function') {
|
|
36
|
+
instance.destroy();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Auto-initialize when imported in browser environment
|
|
44
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
45
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
46
|
+
initGridComponents();
|
|
47
|
+
});
|
|
48
|
+
}
|