@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,215 @@
|
|
|
1
|
+
import React, { forwardRef, HTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CssGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* The content to be rendered within the CSS Grid
|
|
6
|
+
*/
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Additional CSS class names
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Grid template columns definition
|
|
16
|
+
*/
|
|
17
|
+
templateColumns?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Grid template rows definition
|
|
21
|
+
*/
|
|
22
|
+
templateRows?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Grid template areas definition
|
|
26
|
+
*/
|
|
27
|
+
templateAreas?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Auto-placement algorithm
|
|
31
|
+
*/
|
|
32
|
+
autoFlow?: 'row' | 'column' | 'dense' | 'row dense' | 'column dense';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Gap between grid items
|
|
36
|
+
*/
|
|
37
|
+
gap?: string | number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Column gap
|
|
41
|
+
*/
|
|
42
|
+
columnGap?: string | number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Row gap
|
|
46
|
+
*/
|
|
47
|
+
rowGap?: string | number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Justify items (align items along row axis)
|
|
51
|
+
*/
|
|
52
|
+
justifyItems?: 'start' | 'end' | 'center' | 'stretch';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Align items (align items along column axis)
|
|
56
|
+
*/
|
|
57
|
+
alignItems?: 'start' | 'end' | 'center' | 'stretch' | 'baseline';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Justify content (grid container alignment along row axis)
|
|
61
|
+
*/
|
|
62
|
+
justifyContent?: 'start' | 'end' | 'center' | 'stretch' | 'space-around' | 'space-between' | 'space-evenly';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Align content (grid container alignment along column axis)
|
|
66
|
+
*/
|
|
67
|
+
alignContent?: 'start' | 'end' | 'center' | 'stretch' | 'space-around' | 'space-between' | 'space-evenly';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Responsive column count
|
|
71
|
+
*/
|
|
72
|
+
columns?: number | ResponsiveColumns;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Minimum column width with auto-fit/auto-fill
|
|
76
|
+
*/
|
|
77
|
+
minColumnWidth?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ResponsiveColumns {
|
|
81
|
+
/**
|
|
82
|
+
* Extra small screen columns
|
|
83
|
+
*/
|
|
84
|
+
xs?: number;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Small screen columns
|
|
88
|
+
*/
|
|
89
|
+
sm?: number;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Medium screen columns
|
|
93
|
+
*/
|
|
94
|
+
md?: number;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Large screen columns
|
|
98
|
+
*/
|
|
99
|
+
lg?: number;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Extra large screen columns
|
|
103
|
+
*/
|
|
104
|
+
xl?: number;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Extra extra large screen columns
|
|
108
|
+
*/
|
|
109
|
+
xxl?: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* CssGrid component for modern CSS Grid layouts with advanced features
|
|
114
|
+
* Provides native CSS Grid support with template areas, auto-placement, and responsive design
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* // Basic grid
|
|
119
|
+
* <CssGrid columns={3} gap="1rem">
|
|
120
|
+
* <div>Item 1</div>
|
|
121
|
+
* <div>Item 2</div>
|
|
122
|
+
* <div>Item 3</div>
|
|
123
|
+
* </CssGrid>
|
|
124
|
+
*
|
|
125
|
+
* // Template areas
|
|
126
|
+
* <CssGrid
|
|
127
|
+
* templateAreas={`
|
|
128
|
+
* "header header header"
|
|
129
|
+
* "sidebar content content"
|
|
130
|
+
* "footer footer footer"
|
|
131
|
+
* `}
|
|
132
|
+
* gap="1rem"
|
|
133
|
+
* >
|
|
134
|
+
* <div style={{ gridArea: "header" }}>Header</div>
|
|
135
|
+
* <div style={{ gridArea: "sidebar" }}>Sidebar</div>
|
|
136
|
+
* <div style={{ gridArea: "content" }}>Content</div>
|
|
137
|
+
* <div style={{ gridArea: "footer" }}>Footer</div>
|
|
138
|
+
* </CssGrid>
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export const CssGrid = forwardRef<HTMLDivElement, CssGridProps>(
|
|
142
|
+
({
|
|
143
|
+
children,
|
|
144
|
+
className = '',
|
|
145
|
+
templateColumns,
|
|
146
|
+
templateRows,
|
|
147
|
+
templateAreas,
|
|
148
|
+
autoFlow,
|
|
149
|
+
gap,
|
|
150
|
+
columnGap,
|
|
151
|
+
rowGap,
|
|
152
|
+
justifyItems,
|
|
153
|
+
alignItems,
|
|
154
|
+
justifyContent,
|
|
155
|
+
alignContent,
|
|
156
|
+
columns,
|
|
157
|
+
minColumnWidth,
|
|
158
|
+
style,
|
|
159
|
+
...props
|
|
160
|
+
}, ref) => {
|
|
161
|
+
const gridStyle: CSSProperties = {
|
|
162
|
+
display: 'grid',
|
|
163
|
+
...style
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// Set grid template columns based on columns prop
|
|
167
|
+
if (columns) {
|
|
168
|
+
if (typeof columns === 'number') {
|
|
169
|
+
gridStyle.gridTemplateColumns = `repeat(${columns}, 1fr)`;
|
|
170
|
+
} else {
|
|
171
|
+
// Handle responsive columns through CSS classes
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Apply grid template definitions
|
|
176
|
+
if (templateColumns) gridStyle.gridTemplateColumns = templateColumns;
|
|
177
|
+
if (templateRows) gridStyle.gridTemplateRows = templateRows;
|
|
178
|
+
if (templateAreas) gridStyle.gridTemplateAreas = templateAreas;
|
|
179
|
+
if (autoFlow) gridStyle.gridAutoFlow = autoFlow;
|
|
180
|
+
|
|
181
|
+
// Apply gaps
|
|
182
|
+
if (gap) gridStyle.gap = typeof gap === 'number' ? `${gap}px` : gap;
|
|
183
|
+
if (columnGap) gridStyle.columnGap = typeof columnGap === 'number' ? `${columnGap}px` : columnGap;
|
|
184
|
+
if (rowGap) gridStyle.rowGap = typeof rowGap === 'number' ? `${rowGap}px` : rowGap;
|
|
185
|
+
|
|
186
|
+
// Apply alignment properties
|
|
187
|
+
if (justifyItems) gridStyle.justifyItems = justifyItems;
|
|
188
|
+
if (alignItems) gridStyle.alignItems = alignItems;
|
|
189
|
+
if (justifyContent) gridStyle.justifyContent = justifyContent;
|
|
190
|
+
if (alignContent) gridStyle.alignContent = alignContent;
|
|
191
|
+
|
|
192
|
+
// Handle min column width with auto-fit/auto-fill
|
|
193
|
+
if (minColumnWidth && !templateColumns) {
|
|
194
|
+
gridStyle.gridTemplateColumns = `repeat(auto-fit, minmax(${minColumnWidth}, 1fr))`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const classes = ['o-css-grid'];
|
|
198
|
+
if (className) classes.push(className);
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<div
|
|
202
|
+
ref={ref}
|
|
203
|
+
className={classes.join(' ')}
|
|
204
|
+
style={gridStyle}
|
|
205
|
+
{...props}
|
|
206
|
+
>
|
|
207
|
+
{children}
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
CssGrid.displayName = 'CssGrid';
|
|
214
|
+
|
|
215
|
+
export default CssGrid;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file CssGrid - Vanilla JavaScript implementation of the CssGrid component
|
|
3
|
+
* @description Provides DOM manipulation for modern CSS Grid layouts
|
|
4
|
+
* @requires ../CssGrid.css (auto-generated)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* CSS Grid component class for modern grid layouts
|
|
9
|
+
*/
|
|
10
|
+
export class CssGrid {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new CssGrid instance
|
|
13
|
+
* @param {Object} options - CSS Grid configuration options
|
|
14
|
+
* @param {HTMLElement} options.element - The container element
|
|
15
|
+
* @param {string} [options.className=''] - Additional CSS classes
|
|
16
|
+
* @param {string} [options.templateColumns] - Grid template columns definition
|
|
17
|
+
* @param {string} [options.templateRows] - Grid template rows definition
|
|
18
|
+
* @param {string} [options.templateAreas] - Grid template areas definition
|
|
19
|
+
* @param {'row'|'column'|'dense'|'row dense'|'column dense'} [options.autoFlow] - Auto-placement algorithm
|
|
20
|
+
* @param {string|number} [options.gap] - Gap between grid items
|
|
21
|
+
* @param {string|number} [options.columnGap] - Column gap
|
|
22
|
+
* @param {string|number} [options.rowGap] - Row gap
|
|
23
|
+
* @param {'start'|'end'|'center'|'stretch'} [options.justifyItems] - Justify items
|
|
24
|
+
* @param {'start'|'end'|'center'|'stretch'|'baseline'} [options.alignItems] - Align items
|
|
25
|
+
* @param {'start'|'end'|'center'|'stretch'|'space-around'|'space-between'|'space-evenly'} [options.justifyContent] - Justify content
|
|
26
|
+
* @param {'start'|'end'|'center'|'stretch'|'space-around'|'space-between'|'space-evenly'} [options.alignContent] - Align content
|
|
27
|
+
* @param {number|Object} [options.columns] - Responsive column count
|
|
28
|
+
* @param {string} [options.minColumnWidth] - Minimum column width
|
|
29
|
+
*/
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.element = options.element;
|
|
32
|
+
this.options = {
|
|
33
|
+
className: options.className || '',
|
|
34
|
+
templateColumns: options.templateColumns,
|
|
35
|
+
templateRows: options.templateRows,
|
|
36
|
+
templateAreas: options.templateAreas,
|
|
37
|
+
autoFlow: options.autoFlow,
|
|
38
|
+
gap: options.gap,
|
|
39
|
+
columnGap: options.columnGap,
|
|
40
|
+
rowGap: options.rowGap,
|
|
41
|
+
justifyItems: options.justifyItems,
|
|
42
|
+
alignItems: options.alignItems,
|
|
43
|
+
justifyContent: options.justifyContent,
|
|
44
|
+
alignContent: options.alignContent,
|
|
45
|
+
columns: options.columns,
|
|
46
|
+
minColumnWidth: options.minColumnWidth,
|
|
47
|
+
...options
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.init();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initialize the CSS Grid component
|
|
55
|
+
*/
|
|
56
|
+
init() {
|
|
57
|
+
this.applyStyles();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Apply CSS Grid styles based on options
|
|
62
|
+
*/
|
|
63
|
+
applyStyles() {
|
|
64
|
+
const style = this.element.style;
|
|
65
|
+
|
|
66
|
+
// Reset base styles
|
|
67
|
+
style.display = 'grid';
|
|
68
|
+
|
|
69
|
+
// Apply template definitions
|
|
70
|
+
if (this.options.templateColumns) {
|
|
71
|
+
style.gridTemplateColumns = this.options.templateColumns;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (this.options.templateRows) {
|
|
75
|
+
style.gridTemplateRows = this.options.templateRows;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (this.options.templateAreas) {
|
|
79
|
+
style.gridTemplateAreas = this.options.templateAreas;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.options.autoFlow) {
|
|
83
|
+
style.gridAutoFlow = this.options.autoFlow;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Apply gaps
|
|
87
|
+
if (this.options.gap !== undefined) {
|
|
88
|
+
style.gap = typeof this.options.gap === 'number'
|
|
89
|
+
? `${this.options.gap}px`
|
|
90
|
+
: this.options.gap;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.options.columnGap !== undefined) {
|
|
94
|
+
style.columnGap = typeof this.options.columnGap === 'number'
|
|
95
|
+
? `${this.options.columnGap}px`
|
|
96
|
+
: this.options.columnGap;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.options.rowGap !== undefined) {
|
|
100
|
+
style.rowGap = typeof this.options.rowGap === 'number'
|
|
101
|
+
? `${this.options.rowGap}px`
|
|
102
|
+
: this.options.rowGap;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Apply alignment properties
|
|
106
|
+
if (this.options.justifyItems) {
|
|
107
|
+
style.justifyItems = this.options.justifyItems;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.options.alignItems) {
|
|
111
|
+
style.alignItems = this.options.alignItems;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this.options.justifyContent) {
|
|
115
|
+
style.justifyContent = this.options.justifyContent;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (this.options.alignContent) {
|
|
119
|
+
style.alignContent = this.options.alignContent;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Handle column configuration
|
|
123
|
+
if (this.options.columns) {
|
|
124
|
+
if (typeof this.options.columns === 'number') {
|
|
125
|
+
style.gridTemplateColumns = `repeat(${this.options.columns}, 1fr)`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Handle min column width with auto-fit/auto-fill
|
|
130
|
+
if (this.options.minColumnWidth && !this.options.templateColumns) {
|
|
131
|
+
style.gridTemplateColumns = `repeat(auto-fit, minmax(${this.options.minColumnWidth}, 1fr))`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Add CSS classes
|
|
135
|
+
const classes = ['o-css-grid'];
|
|
136
|
+
if (this.options.className) {
|
|
137
|
+
classes.push(this.options.className);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.element.className = classes.join(' ');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Update grid options and refresh styling
|
|
145
|
+
* @param {Object} newOptions - New configuration options
|
|
146
|
+
*/
|
|
147
|
+
update(newOptions) {
|
|
148
|
+
this.options = { ...this.options, ...newOptions };
|
|
149
|
+
this.applyStyles();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Set grid template columns
|
|
154
|
+
* @param {string} templateColumns - Template columns definition
|
|
155
|
+
*/
|
|
156
|
+
setTemplateColumns(templateColumns) {
|
|
157
|
+
this.update({ templateColumns });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Set grid template rows
|
|
162
|
+
* @param {string} templateRows - Template rows definition
|
|
163
|
+
*/
|
|
164
|
+
setTemplateRows(templateRows) {
|
|
165
|
+
this.update({ templateRows });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Set grid template areas
|
|
170
|
+
* @param {string} templateAreas - Template areas definition
|
|
171
|
+
*/
|
|
172
|
+
setTemplateAreas(templateAreas) {
|
|
173
|
+
this.update({ templateAreas });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set grid gap
|
|
178
|
+
* @param {string|number} gap - Gap value
|
|
179
|
+
*/
|
|
180
|
+
setGap(gap) {
|
|
181
|
+
this.update({ gap });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Set number of columns
|
|
186
|
+
* @param {number} columns - Number of columns
|
|
187
|
+
*/
|
|
188
|
+
setColumns(columns) {
|
|
189
|
+
this.update({ columns });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Add a child element to the grid
|
|
194
|
+
* @param {HTMLElement} child - Child element to add
|
|
195
|
+
* @param {Object} [options] - Grid item options
|
|
196
|
+
* @param {number} [options.column] - Column position
|
|
197
|
+
* @param {number} [options.row] - Row position
|
|
198
|
+
* @param {string} [options.area] - Grid area name
|
|
199
|
+
*/
|
|
200
|
+
addChild(child, options = {}) {
|
|
201
|
+
if (options.column) {
|
|
202
|
+
child.style.gridColumn = String(options.column);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (options.row) {
|
|
206
|
+
child.style.gridRow = String(options.row);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (options.area) {
|
|
210
|
+
child.style.gridArea = options.area;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.element.appendChild(child);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Reset grid to default state
|
|
218
|
+
*/
|
|
219
|
+
reset() {
|
|
220
|
+
this.options = {
|
|
221
|
+
className: '',
|
|
222
|
+
templateColumns: undefined,
|
|
223
|
+
templateRows: undefined,
|
|
224
|
+
templateAreas: undefined,
|
|
225
|
+
autoFlow: undefined,
|
|
226
|
+
gap: undefined,
|
|
227
|
+
columnGap: undefined,
|
|
228
|
+
rowGap: undefined,
|
|
229
|
+
justifyItems: undefined,
|
|
230
|
+
alignItems: undefined,
|
|
231
|
+
justifyContent: undefined,
|
|
232
|
+
alignContent: undefined,
|
|
233
|
+
columns: undefined,
|
|
234
|
+
minColumnWidth: undefined
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
this.applyStyles();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Destroy the grid instance and clean up
|
|
242
|
+
*/
|
|
243
|
+
destroy() {
|
|
244
|
+
this.element.style.cssText = '';
|
|
245
|
+
this.element.className = '';
|
|
246
|
+
this.element = null;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Create a CSS Grid instance for a DOM element
|
|
252
|
+
* @param {HTMLElement} element - The DOM element to initialize as CSS Grid
|
|
253
|
+
* @param {Object} options - CSS Grid configuration options
|
|
254
|
+
* @returns {CssGrid} CSS Grid instance
|
|
255
|
+
*/
|
|
256
|
+
export function createCssGrid(element, options = {}) {
|
|
257
|
+
return new CssGrid({ element, ...options });
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Initialize CSS Grid components on page load
|
|
262
|
+
* @param {string} [selector='[data-css-grid]'] - CSS selector for CSS Grid elements
|
|
263
|
+
* @param {Object} [defaultOptions={}] - Default CSS Grid options
|
|
264
|
+
*/
|
|
265
|
+
export function initCssGrids(selector = '[data-css-grid]', defaultOptions = {}) {
|
|
266
|
+
const elements = document.querySelectorAll(selector);
|
|
267
|
+
const grids = [];
|
|
268
|
+
|
|
269
|
+
elements.forEach(element => {
|
|
270
|
+
const options = {
|
|
271
|
+
...defaultOptions,
|
|
272
|
+
...(element.dataset.cssGridOptions ? JSON.parse(element.dataset.cssGridOptions) : {})
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
grids.push(createCssGrid(element, options));
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return grids;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Auto-initialize on DOM ready
|
|
282
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
283
|
+
initCssGrids();
|
|
284
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file CssGrid Scripts Index
|
|
3
|
+
* @description Entry point for vanilla JavaScript CSS Grid implementation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export * from './CssGrid.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Initialize CSS Grid components on page load
|
|
10
|
+
* @param {string} [selector='[data-css-grid]'] - CSS selector for CSS Grid elements
|
|
11
|
+
* @param {Object} [defaultOptions={}] - Default CSS Grid options
|
|
12
|
+
*/
|
|
13
|
+
export function initCssGrids(selector = '[data-css-grid]', defaultOptions = {}) {
|
|
14
|
+
const elements = document.querySelectorAll(selector);
|
|
15
|
+
const grids = [];
|
|
16
|
+
|
|
17
|
+
elements.forEach(element => {
|
|
18
|
+
const options = {
|
|
19
|
+
...defaultOptions,
|
|
20
|
+
...(element.dataset.cssGridOptions ? JSON.parse(element.dataset.cssGridOptions) : {})
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
grids.push(CssGrid({ element, ...options }));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
grids,
|
|
28
|
+
destroy: () => {
|
|
29
|
+
grids.forEach(instance => {
|
|
30
|
+
if (instance && typeof instance.destroy === 'function') {
|
|
31
|
+
instance.destroy();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Auto-initialize when imported in browser environment
|
|
39
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
40
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
41
|
+
initCssGrids();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Container - Vanilla JavaScript implementation of the Container component
|
|
3
|
+
* @description Provides DOM manipulation for responsive container layouts
|
|
4
|
+
* @requires ../Grid.css (auto-generated)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Container component class for responsive content constraints
|
|
9
|
+
*/
|
|
10
|
+
export class Container {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Container instance
|
|
13
|
+
* @param {Object} options - Container configuration options
|
|
14
|
+
* @param {HTMLElement} options.element - The container element
|
|
15
|
+
* @param {string} [options.className=''] - Additional CSS classes
|
|
16
|
+
* @param {'fluid'|'sm'|'md'|'lg'|'xl'|'xxl'} [options.size] - Container size
|
|
17
|
+
* @param {boolean} [options.noPadding=false] - Remove container padding
|
|
18
|
+
*/
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.element = options.element;
|
|
21
|
+
this.options = {
|
|
22
|
+
className: options.className || '',
|
|
23
|
+
size: options.size,
|
|
24
|
+
noPadding: options.noPadding || false,
|
|
25
|
+
...options
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
this.init();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the container component
|
|
33
|
+
*/
|
|
34
|
+
init() {
|
|
35
|
+
this.updateClasses();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Update CSS classes based on current options
|
|
40
|
+
*/
|
|
41
|
+
updateClasses() {
|
|
42
|
+
const classes = ['o-container'];
|
|
43
|
+
|
|
44
|
+
if (this.options.size) {
|
|
45
|
+
classes.push(`o-container--${this.options.size}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.options.noPadding) {
|
|
49
|
+
classes.push('o-container--no-padding');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (this.options.className) {
|
|
53
|
+
classes.push(this.options.className);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.element.className = classes.join(' ');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Update container options and refresh styling
|
|
61
|
+
* @param {Object} newOptions - New configuration options
|
|
62
|
+
*/
|
|
63
|
+
update(newOptions) {
|
|
64
|
+
this.options = { ...this.options, ...newOptions };
|
|
65
|
+
this.updateClasses();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set container size
|
|
70
|
+
* @param {'fluid'|'sm'|'md'|'lg'|'xl'|'xxl'} size - Container size
|
|
71
|
+
*/
|
|
72
|
+
setSize(size) {
|
|
73
|
+
this.update({ size });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Toggle padding
|
|
78
|
+
* @param {boolean} noPadding - Whether to remove padding
|
|
79
|
+
*/
|
|
80
|
+
setNoPadding(noPadding) {
|
|
81
|
+
this.update({ noPadding });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reset container to default state
|
|
86
|
+
*/
|
|
87
|
+
reset() {
|
|
88
|
+
this.options = {
|
|
89
|
+
className: '',
|
|
90
|
+
size: undefined,
|
|
91
|
+
noPadding: false
|
|
92
|
+
};
|
|
93
|
+
this.updateClasses();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Destroy the container instance and clean up
|
|
98
|
+
*/
|
|
99
|
+
destroy() {
|
|
100
|
+
this.element.className = '';
|
|
101
|
+
this.element = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Create a container instance for a DOM element
|
|
107
|
+
* @param {HTMLElement} element - The DOM element to initialize as container
|
|
108
|
+
* @param {Object} options - Container configuration options
|
|
109
|
+
* @returns {Container} Container instance
|
|
110
|
+
*/
|
|
111
|
+
export function createContainer(element, options = {}) {
|
|
112
|
+
return new Container({ element, ...options });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Initialize container components on page load
|
|
117
|
+
* @param {string} [selector='[data-container]'] - CSS selector for container elements
|
|
118
|
+
* @param {Object} [defaultOptions={}] - Default container options
|
|
119
|
+
*/
|
|
120
|
+
export function initContainers(selector = '[data-container]', defaultOptions = {}) {
|
|
121
|
+
const elements = document.querySelectorAll(selector);
|
|
122
|
+
const containers = [];
|
|
123
|
+
|
|
124
|
+
elements.forEach(element => {
|
|
125
|
+
const options = {
|
|
126
|
+
...defaultOptions,
|
|
127
|
+
...(element.dataset.containerOptions ? JSON.parse(element.dataset.containerOptions) : {})
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
containers.push(createContainer(element, options));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return containers;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Auto-initialize on DOM ready
|
|
137
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
138
|
+
initContainers();
|
|
139
|
+
});
|