@kalink-ui/seedly 0.26.3 → 0.27.0
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 +12 -0
- package/package.json +3 -3
- package/src/components/grid/grid-child.css.ts +191 -0
- package/src/components/grid/grid-child.responsive.ts +28 -0
- package/src/components/grid/grid-child.tsx +57 -0
- package/src/components/grid/grid.css.ts +254 -4
- package/src/components/grid/grid.responsive.ts +23 -2
- package/src/components/grid/grid.tsx +34 -7
- package/src/components/grid/index.ts +1 -0
- package/src/styles/define-responsive-properties.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @kalink-ui/seedly
|
|
2
2
|
|
|
3
|
+
## 0.27.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3a1d6bd: feat(seedly/grid): introduce responsive Grid layout with GridChild
|
|
8
|
+
- Add `Grid` component with responsive variants for spacing, columns, fit
|
|
9
|
+
(auto-fill/auto-fit), and content/item alignment.
|
|
10
|
+
- Add `GridChild` for per-item spans, line starts/ends, and self alignment.
|
|
11
|
+
- Support `minSize` via CSS var to control auto-fit/auto-fill behavior.
|
|
12
|
+
- Export `Grid`, `GridChild`, and `gridRecipe` from the Grid module.
|
|
13
|
+
- Include Storybook stories demonstrating fixed columns, auto-fit, and spans.
|
|
14
|
+
|
|
3
15
|
## 0.26.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kalink-ui/seedly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "A set of components for building UIs with React and TypeScript",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"vite": "^6.3.5",
|
|
44
44
|
"vite-tsconfig-paths": "^5.1.4",
|
|
45
45
|
"vitest": "^3.2.3",
|
|
46
|
-
"@kalink-ui/
|
|
47
|
-
"@kalink-ui/
|
|
46
|
+
"@kalink-ui/typescript-config": "0.4.0",
|
|
47
|
+
"@kalink-ui/eslint-config": "0.10.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@vanilla-extract/css": "^1.17.1",
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { type StyleRule } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
|
+
|
|
4
|
+
import { components } from '../../styles/layers.css';
|
|
5
|
+
import {
|
|
6
|
+
createResponsiveVariants,
|
|
7
|
+
defaultMedia,
|
|
8
|
+
} from '../../styles/responsive';
|
|
9
|
+
|
|
10
|
+
const oneToTwelve = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;
|
|
11
|
+
type OneToTwelve = (typeof oneToTwelve)[number];
|
|
12
|
+
|
|
13
|
+
const oneToThirteen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] as const;
|
|
14
|
+
type OneToThirteen = (typeof oneToThirteen)[number];
|
|
15
|
+
type LineIndex = OneToThirteen | -1;
|
|
16
|
+
|
|
17
|
+
const colSpanStyles = Object.fromEntries(
|
|
18
|
+
oneToTwelve.map((n) => [
|
|
19
|
+
n,
|
|
20
|
+
{
|
|
21
|
+
'@layer': {
|
|
22
|
+
[components]: {
|
|
23
|
+
gridColumn: `auto / span ${n}`,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
]),
|
|
28
|
+
) as Record<OneToTwelve, { '@layer': Record<string, { gridColumn: string }> }>;
|
|
29
|
+
|
|
30
|
+
const rowSpanStyles = Object.fromEntries(
|
|
31
|
+
oneToTwelve.map((n) => [
|
|
32
|
+
n,
|
|
33
|
+
{
|
|
34
|
+
'@layer': {
|
|
35
|
+
[components]: {
|
|
36
|
+
gridRow: `auto / span ${n}`,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
]),
|
|
41
|
+
) as Record<OneToTwelve, { '@layer': Record<string, { gridRow: string }> }>;
|
|
42
|
+
|
|
43
|
+
const colStartStyles = Object.fromEntries(
|
|
44
|
+
oneToThirteen.map((n) => [
|
|
45
|
+
n,
|
|
46
|
+
{
|
|
47
|
+
'@layer': {
|
|
48
|
+
[components]: {
|
|
49
|
+
gridColumnStart: n,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
) as Record<
|
|
55
|
+
OneToThirteen,
|
|
56
|
+
{ '@layer': Record<string, { gridColumnStart: number }> }
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
const colEndStyles = Object.fromEntries(
|
|
60
|
+
[...oneToThirteen, -1 as const].map((n) => [
|
|
61
|
+
n,
|
|
62
|
+
{
|
|
63
|
+
'@layer': {
|
|
64
|
+
[components]: {
|
|
65
|
+
gridColumnEnd: n,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
]),
|
|
70
|
+
) as Record<LineIndex, { '@layer': Record<string, { gridColumnEnd: number }> }>;
|
|
71
|
+
|
|
72
|
+
const rowStartStyles = Object.fromEntries(
|
|
73
|
+
oneToThirteen.map((n) => [
|
|
74
|
+
n,
|
|
75
|
+
{
|
|
76
|
+
'@layer': {
|
|
77
|
+
[components]: {
|
|
78
|
+
gridRowStart: n,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
]),
|
|
83
|
+
) as Record<
|
|
84
|
+
OneToThirteen,
|
|
85
|
+
{ '@layer': Record<string, { gridRowStart: number }> }
|
|
86
|
+
>;
|
|
87
|
+
|
|
88
|
+
const rowEndStyles = Object.fromEntries(
|
|
89
|
+
[...oneToThirteen, -1 as const].map((n) => [
|
|
90
|
+
n,
|
|
91
|
+
{
|
|
92
|
+
'@layer': {
|
|
93
|
+
[components]: {
|
|
94
|
+
gridRowEnd: n,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
]),
|
|
99
|
+
) as Record<LineIndex, { '@layer': Record<string, { gridRowEnd: number }> }>;
|
|
100
|
+
|
|
101
|
+
const justifySelfStyles = {
|
|
102
|
+
start: {
|
|
103
|
+
'@layer': { [components]: { justifySelf: 'start' } },
|
|
104
|
+
},
|
|
105
|
+
end: {
|
|
106
|
+
'@layer': { [components]: { justifySelf: 'end' } },
|
|
107
|
+
},
|
|
108
|
+
center: {
|
|
109
|
+
'@layer': { [components]: { justifySelf: 'center' } },
|
|
110
|
+
},
|
|
111
|
+
stretch: {
|
|
112
|
+
'@layer': { [components]: { justifySelf: 'stretch' } },
|
|
113
|
+
},
|
|
114
|
+
} as const;
|
|
115
|
+
|
|
116
|
+
const alignSelfStyles = {
|
|
117
|
+
start: {
|
|
118
|
+
'@layer': { [components]: { alignSelf: 'start' } },
|
|
119
|
+
},
|
|
120
|
+
end: {
|
|
121
|
+
'@layer': { [components]: { alignSelf: 'end' } },
|
|
122
|
+
},
|
|
123
|
+
center: {
|
|
124
|
+
'@layer': { [components]: { alignSelf: 'center' } },
|
|
125
|
+
},
|
|
126
|
+
stretch: {
|
|
127
|
+
'@layer': { [components]: { alignSelf: 'stretch' } },
|
|
128
|
+
},
|
|
129
|
+
} as const;
|
|
130
|
+
|
|
131
|
+
export const gridChildRecipe = recipe({
|
|
132
|
+
base: {
|
|
133
|
+
'@layer': {
|
|
134
|
+
[components]: {},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
variants: {
|
|
138
|
+
colSpan: colSpanStyles,
|
|
139
|
+
rowSpan: rowSpanStyles,
|
|
140
|
+
colStart: colStartStyles,
|
|
141
|
+
colEnd: colEndStyles,
|
|
142
|
+
rowStart: rowStartStyles,
|
|
143
|
+
rowEnd: rowEndStyles,
|
|
144
|
+
justifySelf: justifySelfStyles,
|
|
145
|
+
alignSelf: alignSelfStyles,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export type GridChildVariants = NonNullable<
|
|
150
|
+
RecipeVariants<typeof gridChildRecipe>
|
|
151
|
+
>;
|
|
152
|
+
|
|
153
|
+
export const colSpanAt = createResponsiveVariants({
|
|
154
|
+
styles: colSpanStyles as Record<OneToTwelve, StyleRule | StyleRule[]>,
|
|
155
|
+
media: defaultMedia,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export const rowSpanAt = createResponsiveVariants({
|
|
159
|
+
styles: rowSpanStyles as Record<OneToTwelve, StyleRule | StyleRule[]>,
|
|
160
|
+
media: defaultMedia,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export const colStartAt = createResponsiveVariants({
|
|
164
|
+
styles: colStartStyles as Record<OneToThirteen, StyleRule | StyleRule[]>,
|
|
165
|
+
media: defaultMedia,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
export const colEndAt = createResponsiveVariants({
|
|
169
|
+
styles: colEndStyles as Record<LineIndex, StyleRule | StyleRule[]>,
|
|
170
|
+
media: defaultMedia,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
export const rowStartAt = createResponsiveVariants({
|
|
174
|
+
styles: rowStartStyles as Record<OneToThirteen, StyleRule | StyleRule[]>,
|
|
175
|
+
media: defaultMedia,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export const rowEndAt = createResponsiveVariants({
|
|
179
|
+
styles: rowEndStyles as Record<LineIndex, StyleRule | StyleRule[]>,
|
|
180
|
+
media: defaultMedia,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export const justifySelfAt = createResponsiveVariants({
|
|
184
|
+
styles: justifySelfStyles,
|
|
185
|
+
media: defaultMedia,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
export const alignSelfAt = createResponsiveVariants({
|
|
189
|
+
styles: alignSelfStyles,
|
|
190
|
+
media: defaultMedia,
|
|
191
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
alignSelfAt,
|
|
5
|
+
colEndAt,
|
|
6
|
+
colSpanAt,
|
|
7
|
+
colStartAt,
|
|
8
|
+
gridChildRecipe,
|
|
9
|
+
justifySelfAt,
|
|
10
|
+
rowEndAt,
|
|
11
|
+
rowSpanAt,
|
|
12
|
+
rowStartAt,
|
|
13
|
+
} from './grid-child.css';
|
|
14
|
+
|
|
15
|
+
export const gridChildResponsive = responsiveRecipe({
|
|
16
|
+
recipe: gridChildRecipe,
|
|
17
|
+
at: {
|
|
18
|
+
colSpan: colSpanAt,
|
|
19
|
+
rowSpan: rowSpanAt,
|
|
20
|
+
colStart: colStartAt,
|
|
21
|
+
colEnd: colEndAt,
|
|
22
|
+
rowStart: rowStartAt,
|
|
23
|
+
rowEnd: rowEndAt,
|
|
24
|
+
justifySelf: justifySelfAt,
|
|
25
|
+
alignSelf: alignSelfAt,
|
|
26
|
+
},
|
|
27
|
+
order: defaultOrder,
|
|
28
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { ElementType } from 'react';
|
|
6
|
+
|
|
7
|
+
import { gridChildResponsive } from './grid-child.responsive';
|
|
8
|
+
|
|
9
|
+
import type { GridChildVariants } from './grid-child.css';
|
|
10
|
+
import type { Responsive } from '../../styles/responsive';
|
|
11
|
+
|
|
12
|
+
type GridChildVariantResponsive = {
|
|
13
|
+
[K in keyof GridChildVariants]?: Responsive<
|
|
14
|
+
NonNullable<GridChildVariants[K]>
|
|
15
|
+
>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type GridChildProps<TUse extends ElementType> =
|
|
19
|
+
PolymorphicComponentProps<TUse> & GridChildVariantResponsive;
|
|
20
|
+
|
|
21
|
+
export function GridChild<TUse extends ElementType>({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: GridChildProps<TUse>) {
|
|
25
|
+
const { use: Comp = 'div', ...rest } = props;
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
colSpan,
|
|
29
|
+
rowSpan,
|
|
30
|
+
colStart,
|
|
31
|
+
colEnd,
|
|
32
|
+
rowStart,
|
|
33
|
+
rowEnd,
|
|
34
|
+
justifySelf,
|
|
35
|
+
alignSelf,
|
|
36
|
+
...domProps
|
|
37
|
+
} = rest as GridChildVariantResponsive & Record<string, unknown>;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Comp
|
|
41
|
+
className={clsx(
|
|
42
|
+
gridChildResponsive({
|
|
43
|
+
colSpan,
|
|
44
|
+
rowSpan,
|
|
45
|
+
colStart,
|
|
46
|
+
colEnd,
|
|
47
|
+
rowStart,
|
|
48
|
+
rowEnd,
|
|
49
|
+
justifySelf,
|
|
50
|
+
alignSelf,
|
|
51
|
+
}),
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
{...(domProps as Record<string, unknown>)}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createVar } from '@vanilla-extract/css';
|
|
1
|
+
import { createVar, type StyleRule } from '@vanilla-extract/css';
|
|
2
2
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
createResponsiveVariants,
|
|
6
6
|
defaultMedia,
|
|
7
|
-
sys,
|
|
8
7
|
mapContractVars,
|
|
8
|
+
sys,
|
|
9
9
|
} from '../../styles';
|
|
10
10
|
import { components } from '../../styles/layers.css';
|
|
11
11
|
|
|
@@ -15,17 +15,185 @@ export const minSizeVar = createVar();
|
|
|
15
15
|
export const gridSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
16
16
|
'@layer': {
|
|
17
17
|
[components]: {
|
|
18
|
-
|
|
18
|
+
gap: sys.spacing[key],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
export const gridColumnSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
24
|
+
'@layer': {
|
|
25
|
+
[components]: {
|
|
26
|
+
columnGap: sys.spacing[key],
|
|
19
27
|
},
|
|
20
28
|
},
|
|
21
29
|
}));
|
|
22
30
|
|
|
31
|
+
export const gridRowSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
32
|
+
'@layer': {
|
|
33
|
+
[components]: {
|
|
34
|
+
rowGap: sys.spacing[key],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
export const gridJustifyItemsStyles = {
|
|
40
|
+
start: {
|
|
41
|
+
'@layer': {
|
|
42
|
+
[components]: { justifyItems: 'start' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
end: {
|
|
46
|
+
'@layer': {
|
|
47
|
+
[components]: { justifyItems: 'end' },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
center: {
|
|
51
|
+
'@layer': {
|
|
52
|
+
[components]: { justifyItems: 'center' },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
stretch: {
|
|
56
|
+
'@layer': {
|
|
57
|
+
[components]: { justifyItems: 'stretch' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
} as const;
|
|
61
|
+
|
|
62
|
+
export const gridAlignItemsStyles = {
|
|
63
|
+
start: {
|
|
64
|
+
'@layer': {
|
|
65
|
+
[components]: { alignItems: 'start' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
end: {
|
|
69
|
+
'@layer': {
|
|
70
|
+
[components]: { alignItems: 'end' },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
center: {
|
|
74
|
+
'@layer': {
|
|
75
|
+
[components]: { alignItems: 'center' },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
stretch: {
|
|
79
|
+
'@layer': {
|
|
80
|
+
[components]: { alignItems: 'stretch' },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
} as const;
|
|
84
|
+
|
|
85
|
+
export const gridJustifyContentStyles = {
|
|
86
|
+
start: {
|
|
87
|
+
'@layer': {
|
|
88
|
+
[components]: { justifyContent: 'start' },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
end: {
|
|
92
|
+
'@layer': {
|
|
93
|
+
[components]: { justifyContent: 'end' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
center: {
|
|
97
|
+
'@layer': {
|
|
98
|
+
[components]: { justifyContent: 'center' },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
spaceBetween: {
|
|
102
|
+
'@layer': {
|
|
103
|
+
[components]: { justifyContent: 'space-between' },
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
spaceAround: {
|
|
107
|
+
'@layer': {
|
|
108
|
+
[components]: { justifyContent: 'space-around' },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
spaceEvenly: {
|
|
112
|
+
'@layer': {
|
|
113
|
+
[components]: { justifyContent: 'space-evenly' },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
} as const;
|
|
117
|
+
|
|
118
|
+
export const gridAlignContentStyles = {
|
|
119
|
+
start: {
|
|
120
|
+
'@layer': {
|
|
121
|
+
[components]: { alignContent: 'start' },
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
end: {
|
|
125
|
+
'@layer': {
|
|
126
|
+
[components]: { alignContent: 'end' },
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
center: {
|
|
130
|
+
'@layer': {
|
|
131
|
+
[components]: { alignContent: 'center' },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
spaceBetween: {
|
|
135
|
+
'@layer': {
|
|
136
|
+
[components]: { alignContent: 'space-between' },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
spaceAround: {
|
|
140
|
+
'@layer': {
|
|
141
|
+
[components]: { alignContent: 'space-around' },
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
spaceEvenly: {
|
|
145
|
+
'@layer': {
|
|
146
|
+
[components]: { alignContent: 'space-evenly' },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
stretch: {
|
|
150
|
+
'@layer': {
|
|
151
|
+
[components]: { alignContent: 'stretch' },
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
} as const;
|
|
155
|
+
|
|
156
|
+
const columnCountValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;
|
|
157
|
+
type ColumnCount = (typeof columnCountValues)[number];
|
|
158
|
+
|
|
159
|
+
const gridColumnsStyles = Object.fromEntries(
|
|
160
|
+
columnCountValues.map((n) => [
|
|
161
|
+
n,
|
|
162
|
+
{
|
|
163
|
+
'@layer': {
|
|
164
|
+
[components]: {
|
|
165
|
+
gridTemplateColumns: `repeat(${n}, 1fr)`,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
]),
|
|
170
|
+
) as Record<
|
|
171
|
+
ColumnCount,
|
|
172
|
+
{ '@layer': Record<string, { gridTemplateColumns: string }> }
|
|
173
|
+
>;
|
|
174
|
+
|
|
175
|
+
export const gridFitStyles = {
|
|
176
|
+
fill: {
|
|
177
|
+
'@layer': {
|
|
178
|
+
[components]: {
|
|
179
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(min(${minSizeVar}, 100%), 1fr))`,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
fit: {
|
|
184
|
+
'@layer': {
|
|
185
|
+
[components]: {
|
|
186
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(${minSizeVar}, 100%), 1fr))`,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
} as const;
|
|
191
|
+
|
|
23
192
|
export const gridRecipe = recipe({
|
|
24
193
|
base: {
|
|
25
194
|
'@layer': {
|
|
26
195
|
[components]: {
|
|
27
196
|
display: 'grid',
|
|
28
|
-
gridTemplateColumns: `repeat(auto-fill, minmax(min(${minSizeVar}, 100%), 1fr))`,
|
|
29
197
|
|
|
30
198
|
vars: {
|
|
31
199
|
[minSizeVar]: '250px',
|
|
@@ -39,6 +207,46 @@ export const gridRecipe = recipe({
|
|
|
39
207
|
* The spacing between the grid cell
|
|
40
208
|
*/
|
|
41
209
|
spacing: gridSpacingStyles,
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The spacing between columns only
|
|
213
|
+
*/
|
|
214
|
+
columnSpacing: gridColumnSpacingStyles,
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The spacing between rows only
|
|
218
|
+
*/
|
|
219
|
+
rowSpacing: gridRowSpacingStyles,
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Force a fixed number of columns
|
|
223
|
+
*/
|
|
224
|
+
columns: gridColumnsStyles,
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Whether to use auto-fill (default) or auto-fit
|
|
228
|
+
*/
|
|
229
|
+
fit: gridFitStyles,
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Grid item alignment along inline axis
|
|
233
|
+
*/
|
|
234
|
+
justifyItems: gridJustifyItemsStyles,
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Grid item alignment along block axis
|
|
238
|
+
*/
|
|
239
|
+
alignItems: gridAlignItemsStyles,
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Content alignment within the grid inline axis
|
|
243
|
+
*/
|
|
244
|
+
justifyContent: gridJustifyContentStyles,
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Content alignment within the grid block axis
|
|
248
|
+
*/
|
|
249
|
+
alignContent: gridAlignContentStyles,
|
|
42
250
|
},
|
|
43
251
|
});
|
|
44
252
|
|
|
@@ -48,3 +256,45 @@ export const spacingAt = createResponsiveVariants({
|
|
|
48
256
|
styles: gridSpacingStyles,
|
|
49
257
|
media: defaultMedia,
|
|
50
258
|
});
|
|
259
|
+
|
|
260
|
+
// gridFitStyles now declared above for reuse
|
|
261
|
+
|
|
262
|
+
export const columnSpacingAt = createResponsiveVariants({
|
|
263
|
+
styles: gridColumnSpacingStyles,
|
|
264
|
+
media: defaultMedia,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
export const rowSpacingAt = createResponsiveVariants({
|
|
268
|
+
styles: gridRowSpacingStyles,
|
|
269
|
+
media: defaultMedia,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
export const columnsAt = createResponsiveVariants({
|
|
273
|
+
styles: gridColumnsStyles as Record<ColumnCount, StyleRule | StyleRule[]>,
|
|
274
|
+
media: defaultMedia,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
export const fitAt = createResponsiveVariants({
|
|
278
|
+
styles: gridFitStyles,
|
|
279
|
+
media: defaultMedia,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
export const justifyItemsAt = createResponsiveVariants({
|
|
283
|
+
styles: gridJustifyItemsStyles,
|
|
284
|
+
media: defaultMedia,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
export const alignItemsAt = createResponsiveVariants({
|
|
288
|
+
styles: gridAlignItemsStyles,
|
|
289
|
+
media: defaultMedia,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
export const justifyContentAt = createResponsiveVariants({
|
|
293
|
+
styles: gridJustifyContentStyles,
|
|
294
|
+
media: defaultMedia,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
export const alignContentAt = createResponsiveVariants({
|
|
298
|
+
styles: gridAlignContentStyles,
|
|
299
|
+
media: defaultMedia,
|
|
300
|
+
});
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
alignContentAt,
|
|
5
|
+
alignItemsAt,
|
|
6
|
+
columnsAt,
|
|
7
|
+
fitAt,
|
|
8
|
+
gridRecipe,
|
|
9
|
+
justifyContentAt,
|
|
10
|
+
justifyItemsAt,
|
|
11
|
+
rowSpacingAt,
|
|
12
|
+
spacingAt,
|
|
13
|
+
columnSpacingAt,
|
|
14
|
+
} from './grid.css';
|
|
4
15
|
|
|
5
16
|
export const gridResponsive = responsiveRecipe({
|
|
6
17
|
recipe: gridRecipe,
|
|
7
|
-
at: {
|
|
18
|
+
at: {
|
|
19
|
+
spacing: spacingAt,
|
|
20
|
+
columnSpacing: columnSpacingAt,
|
|
21
|
+
rowSpacing: rowSpacingAt,
|
|
22
|
+
columns: columnsAt,
|
|
23
|
+
fit: fitAt,
|
|
24
|
+
justifyItems: justifyItemsAt,
|
|
25
|
+
alignItems: alignItemsAt,
|
|
26
|
+
justifyContent: justifyContentAt,
|
|
27
|
+
alignContent: alignContentAt,
|
|
28
|
+
},
|
|
8
29
|
order: defaultOrder,
|
|
9
30
|
});
|
|
@@ -10,17 +10,20 @@ import { gridResponsive } from './grid.responsive';
|
|
|
10
10
|
|
|
11
11
|
import type { Responsive } from '../../styles/responsive';
|
|
12
12
|
|
|
13
|
+
type GridVariantResponsive = {
|
|
14
|
+
[K in keyof GridVariants]?: Responsive<NonNullable<GridVariants[K]>>;
|
|
15
|
+
};
|
|
16
|
+
|
|
13
17
|
type GridProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
14
|
-
|
|
18
|
+
GridVariantResponsive & {
|
|
15
19
|
/**
|
|
16
20
|
* The minimum size of a grid cell
|
|
17
21
|
*/
|
|
18
22
|
minSize?: string;
|
|
19
|
-
spacing?: Responsive<NonNullable<GridVariants['spacing']>>;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
|
-
* The Grid layout provides a flexible, responsive grid system
|
|
26
|
+
* The Grid layout provides a flexible, responsive grid system. It can also
|
|
24
27
|
* arranges elements in a structured, multi-column format, automatically
|
|
25
28
|
* adjusting the number of columns based on the available space and
|
|
26
29
|
* predefined constraints.
|
|
@@ -28,20 +31,44 @@ type GridProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
|
28
31
|
* https://every-layout.dev/layouts/grid/
|
|
29
32
|
*/
|
|
30
33
|
export function Grid<TUse extends ElementType>({
|
|
31
|
-
spacing,
|
|
32
34
|
minSize,
|
|
33
35
|
className,
|
|
34
36
|
...props
|
|
35
37
|
}: GridProps<TUse>) {
|
|
36
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
use: Comp = 'div',
|
|
40
|
+
spacing,
|
|
41
|
+
columnSpacing,
|
|
42
|
+
rowSpacing,
|
|
43
|
+
columns = { xs: 4, md: 8, lg: 12 },
|
|
44
|
+
fit,
|
|
45
|
+
justifyItems,
|
|
46
|
+
alignItems,
|
|
47
|
+
justifyContent,
|
|
48
|
+
alignContent,
|
|
49
|
+
...rest
|
|
50
|
+
} = props;
|
|
37
51
|
|
|
38
52
|
return (
|
|
39
53
|
<Comp
|
|
40
|
-
className={clsx(
|
|
54
|
+
className={clsx(
|
|
55
|
+
gridResponsive({
|
|
56
|
+
spacing,
|
|
57
|
+
columnSpacing,
|
|
58
|
+
rowSpacing,
|
|
59
|
+
columns,
|
|
60
|
+
fit,
|
|
61
|
+
justifyItems,
|
|
62
|
+
alignItems,
|
|
63
|
+
justifyContent,
|
|
64
|
+
alignContent,
|
|
65
|
+
}),
|
|
66
|
+
className,
|
|
67
|
+
)}
|
|
41
68
|
style={assignInlineVars({
|
|
42
69
|
...(minSize && { [minSizeVar]: minSize }),
|
|
43
70
|
})}
|
|
44
|
-
{...rest}
|
|
71
|
+
{...(rest as Record<string, unknown>)}
|
|
45
72
|
/>
|
|
46
73
|
);
|
|
47
74
|
}
|
|
@@ -72,6 +72,7 @@ export const defineResponsiveProperties = ({
|
|
|
72
72
|
justifySelf: ['start', 'end', 'center', 'stretch'],
|
|
73
73
|
alignItems: ['flex-start', 'flex-end', 'center', 'baseline', 'stretch'],
|
|
74
74
|
alignSelf: ['flex-start', 'flex-end', 'center', 'baseline', 'stretch'],
|
|
75
|
+
alignContent: ['start', 'end', 'center', 'stretch'],
|
|
75
76
|
|
|
76
77
|
position: [
|
|
77
78
|
'absolute',
|