@sproutsocial/seeds-react-grid 0.2.11 → 0.2.13

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 DELETED
@@ -1,132 +0,0 @@
1
- # @sproutsocial/seeds-react-grid
2
-
3
- ## 0.2.11
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [d8509a3]
8
- - @sproutsocial/seeds-react-theme@4.3.1
9
- - @sproutsocial/seeds-react-box@1.1.27
10
-
11
- ## 0.2.10
12
-
13
- ### Patch Changes
14
-
15
- - Updated dependencies [b77aca0]
16
- - Updated dependencies [2e72599]
17
- - @sproutsocial/seeds-react-system-props@3.1.3
18
- - @sproutsocial/seeds-react-theme@4.3.0
19
- - @sproutsocial/seeds-react-box@1.1.26
20
-
21
- ## 0.2.9
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies [d21ae54]
26
- - @sproutsocial/seeds-react-theme@4.2.1
27
- - @sproutsocial/seeds-react-box@1.1.25
28
-
29
- ## 0.2.8
30
-
31
- ### Patch Changes
32
-
33
- - Updated dependencies [6611f6a]
34
- - @sproutsocial/seeds-react-system-props@3.1.2
35
- - @sproutsocial/seeds-react-box@1.1.24
36
-
37
- ## 0.2.7
38
-
39
- ### Patch Changes
40
-
41
- - Updated dependencies [85f9728]
42
- - Updated dependencies [fa7d859]
43
- - @sproutsocial/seeds-react-theme@4.2.0
44
- - @sproutsocial/seeds-react-box@1.1.23
45
-
46
- ## 0.2.6
47
-
48
- ### Patch Changes
49
-
50
- - Updated dependencies [a13a571]
51
- - @sproutsocial/seeds-react-theme@4.1.1
52
- - @sproutsocial/seeds-react-box@1.1.22
53
-
54
- ## 0.2.5
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies [5892f44]
59
- - @sproutsocial/seeds-react-system-props@3.1.1
60
- - @sproutsocial/seeds-react-box@1.1.21
61
-
62
- ## 0.2.4
63
-
64
- ### Patch Changes
65
-
66
- - Updated dependencies [5114a32]
67
- - @sproutsocial/seeds-react-theme@4.1.0
68
- - @sproutsocial/seeds-react-box@1.1.20
69
-
70
- ## 0.2.3
71
-
72
- ### Patch Changes
73
-
74
- - Updated dependencies [132ef9d]
75
- - Updated dependencies [132ef9d]
76
- - @sproutsocial/seeds-react-theme@4.0.0
77
- - @sproutsocial/seeds-react-system-props@3.1.0
78
- - @sproutsocial/seeds-react-box@1.1.19
79
-
80
- ## 0.2.2
81
-
82
- ### Patch Changes
83
-
84
- - Updated dependencies [47c62b3]
85
- - @sproutsocial/seeds-react-theme@3.7.1
86
- - @sproutsocial/seeds-react-box@1.1.18
87
-
88
- ## 0.2.1
89
-
90
- ### Patch Changes
91
-
92
- - Updated dependencies [06da9c2]
93
- - @sproutsocial/seeds-react-theme@3.7.0
94
- - @sproutsocial/seeds-react-box@1.1.17
95
-
96
- ## 0.2.0
97
-
98
- ### Minor Changes
99
-
100
- - a08b705: Gap values can now be passed an object of responsive values
101
-
102
- ### Patch Changes
103
-
104
- - 4ba8720: Fix `breakpoints` alias typing so consumers can import `TypeBreakpoint` (and use `theme.breakpoints`) without type errors.
105
-
106
- - `theme.breakpoints.sm/md/lg/xl` are now CSS length strings (e.g. `"640px"`) instead of raw numbers. Array entries (`breakpoints[0]`...) are unchanged during the migration to the new scale.
107
- - `newBreakpoints` is no longer exported from the theme package — consumers should use `theme.breakpoints.sm/md/lg/xl` instead. Grid media queries updated accordingly.
108
-
109
- - Updated dependencies [4ba8720]
110
- - @sproutsocial/seeds-react-theme@3.6.2
111
- - @sproutsocial/seeds-react-box@1.1.16
112
-
113
- ## 0.1.1
114
-
115
- ### Patch Changes
116
-
117
- - 1f9a473: Switched grids to use newBreakpoints theme values that are preventing users from using grid's columns api responsively
118
- - Updated dependencies [1f9a473]
119
- - @sproutsocial/seeds-react-theme@3.6.1
120
- - @sproutsocial/seeds-react-box@1.1.15
121
-
122
- ## 0.1.0
123
-
124
- ### Minor Changes
125
-
126
- - 990c196: Add Grid component: a layout primitive for creating CSS Grid layouts with responsive column configurations and customizable gaps.
127
-
128
- ## 0.0.1
129
-
130
- ### Patch Changes
131
-
132
- - de310b9: Fix grid style import
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- const baseConfig = require("@sproutsocial/seeds-testing");
2
-
3
- /** * @type {import('jest').Config} */
4
- const config = {
5
- ...baseConfig,
6
- displayName: "seeds-react-grid",
7
- };
8
-
9
- module.exports = config;
@@ -1,290 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import React from "react";
3
- import COLORS from "@sproutsocial/seeds-color";
4
- import Grid from "./Grid";
5
- import type { GridProps } from "./GridTypes";
6
-
7
- const meta = {
8
- title: "Components/Grid",
9
- component: Grid,
10
- argTypes: {
11
- columns: {
12
- control: { type: "number", min: 1, max: 12, step: 1 },
13
- description:
14
- "Number of columns in the grid (can be a number or responsive object)",
15
- },
16
- gap: {
17
- control: { type: "select" },
18
- options: [
19
- 0,
20
- 100,
21
- 200,
22
- 300,
23
- 350,
24
- 400,
25
- 450,
26
- 500,
27
- 600,
28
- "16px",
29
- "20px",
30
- "24px",
31
- ],
32
- description:
33
- "Gap between all grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., '16px')",
34
- },
35
- rowGap: {
36
- control: { type: "select" },
37
- options: [
38
- 0,
39
- 100,
40
- 200,
41
- 300,
42
- 350,
43
- 400,
44
- 450,
45
- 500,
46
- 600,
47
- "16px",
48
- "20px",
49
- "24px",
50
- ],
51
- description:
52
- "Optional: Override gap for rows only. Use theme.space scale or pixel string (e.g., '16px')",
53
- table: {
54
- defaultValue: { summary: "undefined" },
55
- },
56
- },
57
- columnGap: {
58
- control: { type: "select" },
59
- options: [
60
- 0,
61
- 100,
62
- 200,
63
- 300,
64
- 350,
65
- 400,
66
- 450,
67
- 500,
68
- 600,
69
- "16px",
70
- "20px",
71
- "24px",
72
- ],
73
- description:
74
- "Optional: Override gap for columns only. Use theme.space scale or pixel string (e.g., '16px')",
75
- table: {
76
- defaultValue: { summary: "undefined" },
77
- },
78
- },
79
- children: {
80
- control: false,
81
- description: "Child elements to display in the grid",
82
- },
83
- className: {
84
- control: "text",
85
- description: "Custom CSS class name",
86
- },
87
- },
88
- } satisfies Meta<typeof Grid>;
89
-
90
- export default meta;
91
- type Story = StoryObj<typeof meta>;
92
-
93
- type PlaygroundArgs = GridProps & {
94
- columnsSm?: number;
95
- columnsMd?: number;
96
- columnsLg?: number;
97
- columnsXl?: number;
98
- };
99
-
100
- // Helper component for grid items
101
- const GridItem = ({
102
- children,
103
- color = COLORS.COLOR_BLUE_600,
104
- }: {
105
- children: React.ReactNode;
106
- color?: string;
107
- }) => (
108
- <div
109
- style={{
110
- backgroundColor: color,
111
- padding: "20px",
112
- borderRadius: "8px",
113
- color: "white",
114
- display: "flex",
115
- alignItems: "center",
116
- justifyContent: "center",
117
- minHeight: "100px",
118
- fontWeight: "bold",
119
- }}
120
- >
121
- {children}
122
- </div>
123
- );
124
-
125
- export const Playground: StoryObj<PlaygroundArgs> = {
126
- name: "Playground",
127
- args: {
128
- gap: 400,
129
- columnsSm: 1,
130
- columnsMd: 2,
131
- columnsLg: 3,
132
- columnsXl: 4,
133
- },
134
- argTypes: {
135
- columnsSm: {
136
- control: { type: "number", min: 1, max: 12, step: 1 },
137
- name: "Columns (sm - 640px)",
138
- description: "Number of columns on small screens (640px and up)",
139
- },
140
- columnsMd: {
141
- control: { type: "number", min: 1, max: 12, step: 1 },
142
- name: "Columns (md - 768px)",
143
- description: "Number of columns on medium screens (768px and up)",
144
- },
145
- columnsLg: {
146
- control: { type: "number", min: 1, max: 12, step: 1 },
147
- name: "Columns (lg - 1024px)",
148
- description: "Number of columns on large screens (1024px and up)",
149
- },
150
- columnsXl: {
151
- control: { type: "number", min: 1, max: 12, step: 1 },
152
- name: "Columns (xl - 1280px)",
153
- description: "Number of columns on xl screens (1280px and up)",
154
- },
155
- columns: {
156
- control: false,
157
- table: { disable: true },
158
- },
159
- },
160
- render: (args) => {
161
- const {
162
- rowGap,
163
- columnGap,
164
- columnsSm,
165
- columnsMd,
166
- columnsLg,
167
- columnsXl,
168
- ...restArgs
169
- } = args;
170
- const gridProps = {
171
- ...restArgs,
172
- columns: {
173
- sm: columnsSm,
174
- md: columnsMd,
175
- lg: columnsLg,
176
- xl: columnsXl,
177
- },
178
- ...(rowGap &&
179
- (typeof rowGap === "string" ||
180
- (typeof rowGap === "number" && rowGap > 0) ||
181
- typeof rowGap === "object")
182
- ? { rowGap }
183
- : {}),
184
- ...(columnGap &&
185
- (typeof columnGap === "string" ||
186
- (typeof columnGap === "number" && columnGap > 0) ||
187
- typeof columnGap === "object")
188
- ? { columnGap }
189
- : {}),
190
- };
191
- return (
192
- <Grid {...gridProps}>
193
- <GridItem color={COLORS.COLOR_BLUE_600}>Item 1</GridItem>
194
- <GridItem color={COLORS.COLOR_PURPLE_600}>Item 2</GridItem>
195
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 3</GridItem>
196
- <GridItem color={COLORS.COLOR_RED_600}>Item 4</GridItem>
197
- <GridItem color={COLORS.COLOR_ORANGE_600}>Item 5</GridItem>
198
- <GridItem color={COLORS.COLOR_MAGENTA_600}>Item 6</GridItem>
199
- <GridItem color={COLORS.COLOR_AQUA_600}>Item 7</GridItem>
200
- <GridItem color={COLORS.COLOR_PINK_600}>Item 8</GridItem>
201
- <GridItem color={COLORS.COLOR_GREEN_600}>Item 9</GridItem>
202
- </Grid>
203
- );
204
- },
205
- };
206
-
207
- export const ResponsiveGap: Story = {
208
- name: "Responsive Gap",
209
- render: () => {
210
- return (
211
- <div style={{ display: "flex", flexDirection: "column", gap: "32px" }}>
212
- <div>
213
- <p style={{ marginBottom: "8px", fontWeight: "bold" }}>
214
- Uniform gap (resize to see no change): gap=&#123;400&#125;
215
- </p>
216
- <Grid columns={{ sm: 1, md: 2, lg: 3 }} gap={400}>
217
- <GridItem color={COLORS.COLOR_BLUE_600}>Item 1</GridItem>
218
- <GridItem color={COLORS.COLOR_BLUE_600}>Item 2</GridItem>
219
- <GridItem color={COLORS.COLOR_BLUE_600}>Item 3</GridItem>
220
- </Grid>
221
- </div>
222
-
223
- <div>
224
- <p style={{ marginBottom: "8px", fontWeight: "bold" }}>
225
- Responsive gap (resize to see gap change): gap=&#123;&#123; sm: 200,
226
- md: 400, lg: 500 &#125;&#125;
227
- </p>
228
- <Grid
229
- columns={{ sm: 1, md: 2, lg: 3 }}
230
- gap={{ sm: 200, md: 400, lg: 500 }}
231
- >
232
- <GridItem color={COLORS.COLOR_PURPLE_600}>Item 1</GridItem>
233
- <GridItem color={COLORS.COLOR_PURPLE_600}>Item 2</GridItem>
234
- <GridItem color={COLORS.COLOR_PURPLE_600}>Item 3</GridItem>
235
- </Grid>
236
- </div>
237
-
238
- <div>
239
- <p style={{ marginBottom: "8px", fontWeight: "bold" }}>
240
- Independent row/column gaps: rowGap=&#123;&#123; sm: 200, md: 500
241
- &#125;&#125; columnGap=&#123;&#123; sm: 400, md: 200 &#125;&#125;
242
- </p>
243
- <Grid
244
- columns={{ sm: 2, md: 3 }}
245
- rowGap={{ sm: 200, md: 500 }}
246
- columnGap={{ sm: 400, md: 200 }}
247
- >
248
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 1</GridItem>
249
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 2</GridItem>
250
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 3</GridItem>
251
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 4</GridItem>
252
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 5</GridItem>
253
- <GridItem color={COLORS.COLOR_TEAL_600}>Item 6</GridItem>
254
- </Grid>
255
- </div>
256
- </div>
257
- );
258
- },
259
- };
260
-
261
- export const NestedGrid: Story = {
262
- name: "Nested Grid Layout",
263
- args: {
264
- gap: 400,
265
- },
266
- render: (args) => {
267
- return (
268
- <Grid columns={1} gap={args.gap}>
269
- <Grid columns={1} gap={350}>
270
- <GridItem color={COLORS.COLOR_BLUE_600}>Row 1, Column 1</GridItem>
271
- </Grid>
272
-
273
- <Grid columns={{ sm: 1, md: 2 }} gap={350}>
274
- <GridItem color={COLORS.COLOR_PURPLE_600}>Row 2, Column 1</GridItem>
275
- <GridItem color={COLORS.COLOR_PURPLE_600}>Row 2, Column 2</GridItem>
276
- </Grid>
277
-
278
- <Grid columns={{ sm: 1, md: 3 }} gap={350}>
279
- <GridItem color={COLORS.COLOR_TEAL_600}>Row 3, Column 1</GridItem>
280
- <GridItem color={COLORS.COLOR_TEAL_600}>Row 3, Column 2</GridItem>
281
- <GridItem color={COLORS.COLOR_TEAL_600}>Row 3, Column 3</GridItem>
282
- </Grid>
283
-
284
- <Grid columns={1} gap={350}>
285
- <GridItem color={COLORS.COLOR_RED_600}>Row 4, Column 1</GridItem>
286
- </Grid>
287
- </Grid>
288
- );
289
- },
290
- };
package/src/Grid.tsx DELETED
@@ -1,32 +0,0 @@
1
- import React from "react";
2
- import styled from "styled-components";
3
- import Box from "@sproutsocial/seeds-react-box";
4
- import type { ContainerProps, GridProps } from "./GridTypes";
5
- import { getResponsiveStyles, toResponsiveGapObject } from "./utils";
6
-
7
- const Container = styled(Box)<ContainerProps>`
8
- ${(props) => getResponsiveStyles(props.$columns)}
9
- `;
10
-
11
- const Grid: React.FC<GridProps> = ({
12
- columns = 1,
13
- gap = 400,
14
- rowGap,
15
- columnGap,
16
- children,
17
- className,
18
- }) => {
19
- return (
20
- <Container
21
- display="grid"
22
- rowGap={toResponsiveGapObject(rowGap ?? gap)}
23
- columnGap={toResponsiveGapObject(columnGap ?? gap)}
24
- $columns={columns}
25
- className={className}
26
- >
27
- {children}
28
- </Container>
29
- );
30
- };
31
-
32
- export default Grid;
package/src/GridTypes.ts DELETED
@@ -1,51 +0,0 @@
1
- import type { TypeSpace } from "@sproutsocial/seeds-react-theme";
2
- import * as React from "react";
3
-
4
- export type ResponsiveValue =
5
- | number
6
- | {
7
- sm?: number;
8
- md?: number;
9
- lg?: number;
10
- xl?: number;
11
- };
12
-
13
- /**
14
- * Gap value that can be either:
15
- * - A space scale value from the theme (0, 100, 200, 300, 350, 400, 450, 500, 600)
16
- * - A pixel string value (e.g., "16px", "20px")
17
- */
18
- export type GapValue = keyof TypeSpace | (string & {});
19
-
20
- /**
21
- * Responsive gap value that can be either:
22
- * - A single GapValue applied at all breakpoints
23
- * - An object with optional breakpoint keys (sm, md, lg, xl) for responsive values
24
- */
25
- export type ResponsiveGapValue =
26
- | GapValue
27
- | {
28
- sm?: GapValue;
29
- md?: GapValue;
30
- lg?: GapValue;
31
- xl?: GapValue;
32
- };
33
-
34
- export interface ContainerProps {
35
- $columns?: ResponsiveValue;
36
- }
37
-
38
- export interface GridProps {
39
- /** Number of columns (can be responsive) */
40
- columns?: ResponsiveValue;
41
- /** Gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600), pixel string (e.g., "16px"), or responsive object (e.g., { sm: 400, md: 500 }) */
42
- gap?: ResponsiveGapValue;
43
- /** Row gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600), pixel string (e.g., "16px"), or responsive object (e.g., { sm: 400, md: 500 }) */
44
- rowGap?: ResponsiveGapValue;
45
- /** Column gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600), pixel string (e.g., "16px"), or responsive object (e.g., { sm: 400, md: 500 }) */
46
- columnGap?: ResponsiveGapValue;
47
- /** Children elements to display in the grid */
48
- children?: React.ReactNode;
49
- /** Custom className */
50
- className?: string;
51
- }
@@ -1,131 +0,0 @@
1
- import * as React from "react";
2
- import Grid from "../Grid";
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
- function GridTypes() {
6
- return (
7
- <>
8
- {/* Basic usage */}
9
- <Grid>
10
- <div>Item</div>
11
- </Grid>
12
-
13
- {/* With fixed columns */}
14
- <Grid columns={3}>
15
- <div>Item</div>
16
- </Grid>
17
-
18
- {/* With responsive columns */}
19
- <Grid columns={{ sm: 1, md: 2, lg: 3, xl: 4 }}>
20
- <div>Item</div>
21
- </Grid>
22
-
23
- {/* With gap using space scale */}
24
- <Grid gap={450}>
25
- <div>Item</div>
26
- </Grid>
27
-
28
- {/* With gap using pixel string */}
29
- <Grid gap="24px">
30
- <div>Item</div>
31
- </Grid>
32
-
33
- {/* With rowGap and columnGap using space scale */}
34
- <Grid rowGap={500} columnGap={400}>
35
- <div>Item</div>
36
- </Grid>
37
-
38
- {/* With rowGap and columnGap using pixel strings */}
39
- <Grid rowGap="32px" columnGap="16px">
40
- <div>Item</div>
41
- </Grid>
42
-
43
- {/* Mix of space scale and pixel strings */}
44
- <Grid rowGap={450} columnGap="20px">
45
- <div>Item</div>
46
- </Grid>
47
-
48
- {/* With all props */}
49
- <Grid
50
- columns={{ sm: 1, md: 2, lg: 3 }}
51
- gap={400}
52
- rowGap={450}
53
- columnGap={350}
54
- className="custom-grid"
55
- >
56
- <div>Item 1</div>
57
- <div>Item 2</div>
58
- </Grid>
59
-
60
- {/* With responsive gap using space scale */}
61
- <Grid gap={{ sm: 400, md: 450, lg: 500 }}>
62
- <div>Item</div>
63
- </Grid>
64
-
65
- {/* With partial responsive gap */}
66
- <Grid gap={{ sm: 400 }}>
67
- <div>Item</div>
68
- </Grid>
69
-
70
- {/* With responsive rowGap using pixel strings */}
71
- <Grid rowGap={{ sm: "16px", md: "24px" }}>
72
- <div>Item</div>
73
- </Grid>
74
-
75
- {/* With responsive columnGap */}
76
- <Grid columnGap={{ sm: 300, md: 400, lg: 450, xl: 500 }}>
77
- <div>Item</div>
78
- </Grid>
79
-
80
- {/* @ts-expect-error - invalid key in responsive gap */}
81
- <Grid gap={{ xs: 400 }}>
82
- <div>Item</div>
83
- </Grid>
84
-
85
- {/* @ts-expect-error - invalid gap value inside responsive object */}
86
- <Grid gap={{ sm: 16 }}>
87
- <div>Item</div>
88
- </Grid>
89
-
90
- {/* @ts-expect-error - invalid columns value */}
91
- <Grid columns="invalid">
92
- <div>Item</div>
93
- </Grid>
94
-
95
- {/* Valid gap value - any string is allowed */}
96
- <Grid gap="invalid">
97
- <div>Item</div>
98
- </Grid>
99
-
100
- {/* @ts-expect-error - invalid responsive columns */}
101
- <Grid columns={{ xs: 1 }}>
102
- <div>Item</div>
103
- </Grid>
104
-
105
- {/* @ts-expect-error - invalid gap value (not in SpaceScale and not a px string) */}
106
- <Grid gap={16}>
107
- <div>Item</div>
108
- </Grid>
109
-
110
- {/* @ts-expect-error - invalid rowGap value (not in SpaceScale and not a px string) */}
111
- <Grid rowGap={20}>
112
- <div>Item</div>
113
- </Grid>
114
-
115
- {/* @ts-expect-error - invalid columnGap value (not in SpaceScale and not a px string) */}
116
- <Grid columnGap={25}>
117
- <div>Item</div>
118
- </Grid>
119
-
120
- {/* Valid gap value - any string is allowed */}
121
- <Grid gap="16rem">
122
- <div>Item</div>
123
- </Grid>
124
-
125
- {/* Valid gap value - any string is allowed */}
126
- <Grid gap="1em">
127
- <div>Item</div>
128
- </Grid>
129
- </>
130
- );
131
- }