@sproutsocial/seeds-react-grid 0.1.0 → 0.2.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.
@@ -8,14 +8,14 @@ $ tsup --dts
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 3.61 KB
12
- CJS dist/index.js.map 4.56 KB
13
- CJS ⚡️ Build success in 99ms
14
- ESM dist/esm/index.js 1.71 KB
15
- ESM dist/esm/index.js.map 4.45 KB
16
- ESM ⚡️ Build success in 101ms
11
+ CJS dist/index.js 3.71 KB
12
+ CJS dist/index.js.map 5.23 KB
13
+ CJS ⚡️ Build success in 50ms
14
+ ESM dist/esm/index.js 1.84 KB
15
+ ESM dist/esm/index.js.map 5.11 KB
16
+ ESM ⚡️ Build success in 51ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 4810ms
19
- DTS dist/index.d.ts 1.50 KB
20
- DTS dist/index.d.mts 1.50 KB
21
- Done in 6.61s.
18
+ DTS ⚡️ Build success in 4364ms
19
+ DTS dist/index.d.ts 1.86 KB
20
+ DTS dist/index.d.mts 1.86 KB
21
+ Done in 5.53s.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @sproutsocial/seeds-react-grid
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a08b705: Gap values can now be passed an object of responsive values
8
+
9
+ ### Patch Changes
10
+
11
+ - 4ba8720: Fix `breakpoints` alias typing so consumers can import `TypeBreakpoint` (and use `theme.breakpoints`) without type errors.
12
+
13
+ - `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.
14
+ - `newBreakpoints` is no longer exported from the theme package — consumers should use `theme.breakpoints.sm/md/lg/xl` instead. Grid media queries updated accordingly.
15
+
16
+ - Updated dependencies [4ba8720]
17
+ - @sproutsocial/seeds-react-theme@3.6.2
18
+ - @sproutsocial/seeds-react-box@1.1.16
19
+
20
+ ## 0.1.1
21
+
22
+ ### Patch Changes
23
+
24
+ - 1f9a473: Switched grids to use newBreakpoints theme values that are preventing users from using grid's columns api responsively
25
+ - Updated dependencies [1f9a473]
26
+ - @sproutsocial/seeds-react-theme@3.6.1
27
+ - @sproutsocial/seeds-react-box@1.1.15
28
+
3
29
  ## 0.1.0
4
30
 
5
31
  ### Minor Changes
package/dist/esm/index.js CHANGED
@@ -7,6 +7,10 @@ import Box from "@sproutsocial/seeds-react-box";
7
7
  import { css } from "styled-components";
8
8
  import { theme } from "@sproutsocial/seeds-react-theme";
9
9
  var { breakpoints } = theme;
10
+ var toResponsiveGapObject = (value) => {
11
+ if (typeof value !== "object") return value;
12
+ return value;
13
+ };
10
14
  var getResponsiveStyles = (columns = 1) => {
11
15
  if (typeof columns === "number") {
12
16
  return css`
@@ -14,20 +18,24 @@ var getResponsiveStyles = (columns = 1) => {
14
18
  `;
15
19
  }
16
20
  return css`
17
- grid-template-columns: repeat(${columns.sm || 1}, 1fr);
21
+ grid-template-columns: repeat(1, 1fr);
22
+
23
+ @media (min-width: ${breakpoints.sm}) {
24
+ grid-template-columns: repeat(${columns.sm || 1}, 1fr);
25
+ }
18
26
 
19
- @media (min-width: ${breakpoints.md}px) {
27
+ @media (min-width: ${breakpoints.md}) {
20
28
  grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);
21
29
  }
22
30
 
23
- @media (min-width: ${breakpoints.lg}px) {
31
+ @media (min-width: ${breakpoints.lg}) {
24
32
  grid-template-columns: repeat(
25
33
  ${columns.lg || columns.md || columns.sm || 1},
26
34
  1fr
27
35
  );
28
36
  }
29
37
 
30
- @media (min-width: ${breakpoints.xl}px) {
38
+ @media (min-width: ${breakpoints.xl}) {
31
39
  grid-template-columns: repeat(
32
40
  ${columns.xl || columns.lg || columns.md || columns.sm || 1},
33
41
  1fr
@@ -53,8 +61,8 @@ var Grid = ({
53
61
  Container,
54
62
  {
55
63
  display: "grid",
56
- rowGap: rowGap ?? gap,
57
- columnGap: columnGap ?? gap,
64
+ rowGap: toResponsiveGapObject(rowGap ?? gap),
65
+ columnGap: toResponsiveGapObject(columnGap ?? gap),
58
66
  $columns: columns,
59
67
  className,
60
68
  children
@@ -66,18 +74,9 @@ var Grid_default = Grid;
66
74
  // src/GridTypes.ts
67
75
  import "react";
68
76
 
69
- // src/constants.ts
70
- var BREAKPOINTS = {
71
- sm: 640,
72
- md: 768,
73
- lg: 1024,
74
- xl: 1280
75
- };
76
-
77
77
  // src/index.ts
78
78
  var index_default = Grid_default;
79
79
  export {
80
- BREAKPOINTS,
81
80
  Grid_default as Grid,
82
81
  index_default as default
83
82
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Grid.tsx","../../src/utils.ts","../../src/GridTypes.ts","../../src/constants.ts","../../src/index.ts"],"sourcesContent":["import React from \"react\";\nimport styled from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { ContainerProps, GridProps } from \"./GridTypes\";\nimport { getResponsiveStyles } from \"./utils\";\n\nconst Container = styled(Box)<ContainerProps>`\n ${(props) => getResponsiveStyles(props.$columns)}\n`;\n\nconst Grid: React.FC<GridProps> = ({\n columns = 1,\n gap = 400,\n rowGap,\n columnGap,\n children,\n className,\n}) => {\n return (\n <Container\n display=\"grid\"\n rowGap={rowGap ?? gap}\n columnGap={columnGap ?? gap}\n $columns={columns}\n className={className}\n >\n {children}\n </Container>\n );\n};\n\nexport default Grid;\n","import type { ResponsiveValue } from \"./GridTypes\";\nimport { css } from \"styled-components\";\nimport { theme } from \"@sproutsocial/seeds-react-theme\";\n// WE may want to check this. I also see seeds-react/seeds-react-grid/src/constants.ts which has different values\n// And 900px for \"small\" seems way too big\nconst { breakpoints } = theme;\n\nexport const getResponsiveStyles = (columns: ResponsiveValue = 1) => {\n if (typeof columns === \"number\") {\n return css`\n grid-template-columns: repeat(${columns}, 1fr);\n `;\n }\n\n return css`\n grid-template-columns: repeat(${columns.sm || 1}, 1fr);\n\n @media (min-width: ${breakpoints.md}px) {\n grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);\n }\n\n @media (min-width: ${breakpoints.lg}px) {\n grid-template-columns: repeat(\n ${columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n\n @media (min-width: ${breakpoints.xl}px) {\n grid-template-columns: repeat(\n ${columns.xl || columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n `;\n};\n","import type { TypeSpace } from \"@sproutsocial/seeds-react-theme\";\nimport * as React from \"react\";\n\nexport type ResponsiveValue =\n | number\n | {\n sm?: number;\n md?: number;\n lg?: number;\n xl?: number;\n };\n\n/**\n * Gap value that can be either:\n * - A space scale value from the theme (0, 100, 200, 300, 350, 400, 450, 500, 600)\n * - A pixel string value (e.g., \"16px\", \"20px\")\n */\nexport type GapValue = keyof TypeSpace | (string & {});\n\nexport interface ContainerProps {\n $columns?: ResponsiveValue;\n}\n\nexport interface GridProps {\n /** Number of columns (can be responsive) */\n columns?: ResponsiveValue;\n /** Gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., \"16px\") */\n gap?: GapValue;\n /** Row gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., \"16px\") */\n rowGap?: GapValue;\n /** Column gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., \"16px\") */\n columnGap?: GapValue;\n /** Children elements to display in the grid */\n children?: React.ReactNode;\n /** Custom className */\n className?: string;\n}\n","export const BREAKPOINTS = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n} as const;\n","import Grid from \"./Grid\";\n\nexport default Grid;\nexport { Grid };\nexport * from \"./GridTypes\";\nexport { BREAKPOINTS } from \"./constants\";\n"],"mappings":";AAAA,OAAkB;AAClB,OAAO,YAAY;AACnB,OAAO,SAAS;;;ACDhB,SAAS,WAAW;AACpB,SAAS,aAAa;AAGtB,IAAM,EAAE,YAAY,IAAI;AAEjB,IAAM,sBAAsB,CAAC,UAA2B,MAAM;AACnE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,sCAC2B,OAAO;AAAA;AAAA,EAE3C;AAEA,SAAO;AAAA,oCAC2B,QAAQ,MAAM,CAAC;AAAA;AAAA,yBAE1B,YAAY,EAAE;AAAA,sCACD,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA,yBAG1C,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,yBAK5B,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAKnE;;;ADhBI;AAbJ,IAAM,YAAY,OAAO,GAAG;AAAA,IACxB,CAAC,UAAU,oBAAoB,MAAM,QAAQ,CAAC;AAAA;AAGlD,IAAM,OAA4B,CAAC;AAAA,EACjC,UAAU;AAAA,EACV,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,QAAQ,UAAU;AAAA,MAClB,WAAW,aAAa;AAAA,MACxB,UAAU;AAAA,MACV;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;AE9Bf,OAAuB;;;ACDhB,IAAM,cAAc;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;;;ACHA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../src/Grid.tsx","../../src/utils.ts","../../src/GridTypes.ts","../../src/index.ts"],"sourcesContent":["import React from \"react\";\nimport styled from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { ContainerProps, GridProps } from \"./GridTypes\";\nimport { getResponsiveStyles, toResponsiveGapObject } from \"./utils\";\n\nconst Container = styled(Box)<ContainerProps>`\n ${(props) => getResponsiveStyles(props.$columns)}\n`;\n\nconst Grid: React.FC<GridProps> = ({\n columns = 1,\n gap = 400,\n rowGap,\n columnGap,\n children,\n className,\n}) => {\n return (\n <Container\n display=\"grid\"\n rowGap={toResponsiveGapObject(rowGap ?? gap)}\n columnGap={toResponsiveGapObject(columnGap ?? gap)}\n $columns={columns}\n className={className}\n >\n {children}\n </Container>\n );\n};\n\nexport default Grid;\n","import type {\n GapValue,\n ResponsiveGapValue,\n ResponsiveValue,\n} from \"./GridTypes\";\nimport { css } from \"styled-components\";\nimport { theme } from \"@sproutsocial/seeds-react-theme\";\n\nconst { breakpoints } = theme;\n\nexport const toResponsiveGapObject = (\n value: ResponsiveGapValue\n):\n | GapValue\n | { sm?: GapValue; md?: GapValue; lg?: GapValue; xl?: GapValue } => {\n if (typeof value !== \"object\") return value;\n return value;\n};\n\nexport const getResponsiveStyles = (columns: ResponsiveValue = 1) => {\n if (typeof columns === \"number\") {\n return css`\n grid-template-columns: repeat(${columns}, 1fr);\n `;\n }\n\n return css`\n grid-template-columns: repeat(1, 1fr);\n\n @media (min-width: ${breakpoints.sm}) {\n grid-template-columns: repeat(${columns.sm || 1}, 1fr);\n }\n\n @media (min-width: ${breakpoints.md}) {\n grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);\n }\n\n @media (min-width: ${breakpoints.lg}) {\n grid-template-columns: repeat(\n ${columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n\n @media (min-width: ${breakpoints.xl}) {\n grid-template-columns: repeat(\n ${columns.xl || columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n `;\n};\n","import type { TypeSpace } from \"@sproutsocial/seeds-react-theme\";\nimport * as React from \"react\";\n\nexport type ResponsiveValue =\n | number\n | {\n sm?: number;\n md?: number;\n lg?: number;\n xl?: number;\n };\n\n/**\n * Gap value that can be either:\n * - A space scale value from the theme (0, 100, 200, 300, 350, 400, 450, 500, 600)\n * - A pixel string value (e.g., \"16px\", \"20px\")\n */\nexport type GapValue = keyof TypeSpace | (string & {});\n\n/**\n * Responsive gap value that can be either:\n * - A single GapValue applied at all breakpoints\n * - An object with optional breakpoint keys (sm, md, lg, xl) for responsive values\n */\nexport type ResponsiveGapValue =\n | GapValue\n | {\n sm?: GapValue;\n md?: GapValue;\n lg?: GapValue;\n xl?: GapValue;\n };\n\nexport interface ContainerProps {\n $columns?: ResponsiveValue;\n}\n\nexport interface GridProps {\n /** Number of columns (can be responsive) */\n columns?: ResponsiveValue;\n /** 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 }) */\n gap?: ResponsiveGapValue;\n /** 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 }) */\n rowGap?: ResponsiveGapValue;\n /** 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 }) */\n columnGap?: ResponsiveGapValue;\n /** Children elements to display in the grid */\n children?: React.ReactNode;\n /** Custom className */\n className?: string;\n}\n","import Grid from \"./Grid\";\n\nexport default Grid;\nexport { Grid };\nexport * from \"./GridTypes\";\n"],"mappings":";AAAA,OAAkB;AAClB,OAAO,YAAY;AACnB,OAAO,SAAS;;;ACGhB,SAAS,WAAW;AACpB,SAAS,aAAa;AAEtB,IAAM,EAAE,YAAY,IAAI;AAEjB,IAAM,wBAAwB,CACnC,UAGoE;AACpE,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO;AACT;AAEO,IAAM,sBAAsB,CAAC,UAA2B,MAAM;AACnE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,sCAC2B,OAAO;AAAA;AAAA,EAE3C;AAEA,SAAO;AAAA;AAAA;AAAA,yBAGgB,YAAY,EAAE;AAAA,sCACD,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA,yBAG5B,YAAY,EAAE;AAAA,sCACD,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA,yBAG1C,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,yBAK5B,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAKnE;;;ADhCI;AAbJ,IAAM,YAAY,OAAO,GAAG;AAAA,IACxB,CAAC,UAAU,oBAAoB,MAAM,QAAQ,CAAC;AAAA;AAGlD,IAAM,OAA4B,CAAC;AAAA,EACjC,UAAU;AAAA,EACV,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,QAAQ,sBAAsB,UAAU,GAAG;AAAA,MAC3C,WAAW,sBAAsB,aAAa,GAAG;AAAA,MACjD,UAAU;AAAA,MACV;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;AE9Bf,OAAuB;;;ACCvB,IAAO,gBAAQ;","names":[]}
package/dist/index.d.mts CHANGED
@@ -14,18 +14,29 @@ type ResponsiveValue = number | {
14
14
  * - A pixel string value (e.g., "16px", "20px")
15
15
  */
16
16
  type GapValue = keyof TypeSpace | (string & {});
17
+ /**
18
+ * Responsive gap value that can be either:
19
+ * - A single GapValue applied at all breakpoints
20
+ * - An object with optional breakpoint keys (sm, md, lg, xl) for responsive values
21
+ */
22
+ type ResponsiveGapValue = GapValue | {
23
+ sm?: GapValue;
24
+ md?: GapValue;
25
+ lg?: GapValue;
26
+ xl?: GapValue;
27
+ };
17
28
  interface ContainerProps {
18
29
  $columns?: ResponsiveValue;
19
30
  }
20
31
  interface GridProps {
21
32
  /** Number of columns (can be responsive) */
22
33
  columns?: ResponsiveValue;
23
- /** Gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
24
- gap?: GapValue;
25
- /** Row gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
26
- rowGap?: GapValue;
27
- /** Column gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
28
- columnGap?: GapValue;
34
+ /** 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 }) */
35
+ gap?: ResponsiveGapValue;
36
+ /** 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 }) */
37
+ rowGap?: ResponsiveGapValue;
38
+ /** 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 }) */
39
+ columnGap?: ResponsiveGapValue;
29
40
  /** Children elements to display in the grid */
30
41
  children?: React.ReactNode;
31
42
  /** Custom className */
@@ -34,11 +45,4 @@ interface GridProps {
34
45
 
35
46
  declare const Grid: React__default.FC<GridProps>;
36
47
 
37
- declare const BREAKPOINTS: {
38
- readonly sm: 640;
39
- readonly md: 768;
40
- readonly lg: 1024;
41
- readonly xl: 1280;
42
- };
43
-
44
- export { BREAKPOINTS, type ContainerProps, type GapValue, Grid, type GridProps, type ResponsiveValue, Grid as default };
48
+ export { type ContainerProps, type GapValue, Grid, type GridProps, type ResponsiveGapValue, type ResponsiveValue, Grid as default };
package/dist/index.d.ts CHANGED
@@ -14,18 +14,29 @@ type ResponsiveValue = number | {
14
14
  * - A pixel string value (e.g., "16px", "20px")
15
15
  */
16
16
  type GapValue = keyof TypeSpace | (string & {});
17
+ /**
18
+ * Responsive gap value that can be either:
19
+ * - A single GapValue applied at all breakpoints
20
+ * - An object with optional breakpoint keys (sm, md, lg, xl) for responsive values
21
+ */
22
+ type ResponsiveGapValue = GapValue | {
23
+ sm?: GapValue;
24
+ md?: GapValue;
25
+ lg?: GapValue;
26
+ xl?: GapValue;
27
+ };
17
28
  interface ContainerProps {
18
29
  $columns?: ResponsiveValue;
19
30
  }
20
31
  interface GridProps {
21
32
  /** Number of columns (can be responsive) */
22
33
  columns?: ResponsiveValue;
23
- /** Gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
24
- gap?: GapValue;
25
- /** Row gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
26
- rowGap?: GapValue;
27
- /** Column gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
28
- columnGap?: GapValue;
34
+ /** 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 }) */
35
+ gap?: ResponsiveGapValue;
36
+ /** 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 }) */
37
+ rowGap?: ResponsiveGapValue;
38
+ /** 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 }) */
39
+ columnGap?: ResponsiveGapValue;
29
40
  /** Children elements to display in the grid */
30
41
  children?: React.ReactNode;
31
42
  /** Custom className */
@@ -34,11 +45,4 @@ interface GridProps {
34
45
 
35
46
  declare const Grid: React__default.FC<GridProps>;
36
47
 
37
- declare const BREAKPOINTS: {
38
- readonly sm: 640;
39
- readonly md: 768;
40
- readonly lg: 1024;
41
- readonly xl: 1280;
42
- };
43
-
44
- export { BREAKPOINTS, type ContainerProps, type GapValue, Grid, type GridProps, type ResponsiveValue, Grid as default };
48
+ export { type ContainerProps, type GapValue, Grid, type GridProps, type ResponsiveGapValue, type ResponsiveValue, Grid as default };
package/dist/index.js CHANGED
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- BREAKPOINTS: () => BREAKPOINTS,
34
33
  Grid: () => Grid_default,
35
34
  default: () => index_default
36
35
  });
@@ -45,6 +44,10 @@ var import_seeds_react_box = __toESM(require("@sproutsocial/seeds-react-box"));
45
44
  var import_styled_components = require("styled-components");
46
45
  var import_seeds_react_theme = require("@sproutsocial/seeds-react-theme");
47
46
  var { breakpoints } = import_seeds_react_theme.theme;
47
+ var toResponsiveGapObject = (value) => {
48
+ if (typeof value !== "object") return value;
49
+ return value;
50
+ };
48
51
  var getResponsiveStyles = (columns = 1) => {
49
52
  if (typeof columns === "number") {
50
53
  return import_styled_components.css`
@@ -52,20 +55,24 @@ var getResponsiveStyles = (columns = 1) => {
52
55
  `;
53
56
  }
54
57
  return import_styled_components.css`
55
- grid-template-columns: repeat(${columns.sm || 1}, 1fr);
58
+ grid-template-columns: repeat(1, 1fr);
59
+
60
+ @media (min-width: ${breakpoints.sm}) {
61
+ grid-template-columns: repeat(${columns.sm || 1}, 1fr);
62
+ }
56
63
 
57
- @media (min-width: ${breakpoints.md}px) {
64
+ @media (min-width: ${breakpoints.md}) {
58
65
  grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);
59
66
  }
60
67
 
61
- @media (min-width: ${breakpoints.lg}px) {
68
+ @media (min-width: ${breakpoints.lg}) {
62
69
  grid-template-columns: repeat(
63
70
  ${columns.lg || columns.md || columns.sm || 1},
64
71
  1fr
65
72
  );
66
73
  }
67
74
 
68
- @media (min-width: ${breakpoints.xl}px) {
75
+ @media (min-width: ${breakpoints.xl}) {
69
76
  grid-template-columns: repeat(
70
77
  ${columns.xl || columns.lg || columns.md || columns.sm || 1},
71
78
  1fr
@@ -91,8 +98,8 @@ var Grid = ({
91
98
  Container,
92
99
  {
93
100
  display: "grid",
94
- rowGap: rowGap ?? gap,
95
- columnGap: columnGap ?? gap,
101
+ rowGap: toResponsiveGapObject(rowGap ?? gap),
102
+ columnGap: toResponsiveGapObject(columnGap ?? gap),
96
103
  $columns: columns,
97
104
  className,
98
105
  children
@@ -104,19 +111,10 @@ var Grid_default = Grid;
104
111
  // src/GridTypes.ts
105
112
  var React2 = require("react");
106
113
 
107
- // src/constants.ts
108
- var BREAKPOINTS = {
109
- sm: 640,
110
- md: 768,
111
- lg: 1024,
112
- xl: 1280
113
- };
114
-
115
114
  // src/index.ts
116
115
  var index_default = Grid_default;
117
116
  // Annotate the CommonJS export names for ESM import in node:
118
117
  0 && (module.exports = {
119
- BREAKPOINTS,
120
118
  Grid
121
119
  });
122
120
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Grid.tsx","../src/utils.ts","../src/GridTypes.ts","../src/constants.ts"],"sourcesContent":["import Grid from \"./Grid\";\n\nexport default Grid;\nexport { Grid };\nexport * from \"./GridTypes\";\nexport { BREAKPOINTS } from \"./constants\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { ContainerProps, GridProps } from \"./GridTypes\";\nimport { getResponsiveStyles } from \"./utils\";\n\nconst Container = styled(Box)<ContainerProps>`\n ${(props) => getResponsiveStyles(props.$columns)}\n`;\n\nconst Grid: React.FC<GridProps> = ({\n columns = 1,\n gap = 400,\n rowGap,\n columnGap,\n children,\n className,\n}) => {\n return (\n <Container\n display=\"grid\"\n rowGap={rowGap ?? gap}\n columnGap={columnGap ?? gap}\n $columns={columns}\n className={className}\n >\n {children}\n </Container>\n );\n};\n\nexport default Grid;\n","import type { ResponsiveValue } from \"./GridTypes\";\nimport { css } from \"styled-components\";\nimport { theme } from \"@sproutsocial/seeds-react-theme\";\n// WE may want to check this. I also see seeds-react/seeds-react-grid/src/constants.ts which has different values\n// And 900px for \"small\" seems way too big\nconst { breakpoints } = theme;\n\nexport const getResponsiveStyles = (columns: ResponsiveValue = 1) => {\n if (typeof columns === \"number\") {\n return css`\n grid-template-columns: repeat(${columns}, 1fr);\n `;\n }\n\n return css`\n grid-template-columns: repeat(${columns.sm || 1}, 1fr);\n\n @media (min-width: ${breakpoints.md}px) {\n grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);\n }\n\n @media (min-width: ${breakpoints.lg}px) {\n grid-template-columns: repeat(\n ${columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n\n @media (min-width: ${breakpoints.xl}px) {\n grid-template-columns: repeat(\n ${columns.xl || columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n `;\n};\n","import type { TypeSpace } from \"@sproutsocial/seeds-react-theme\";\nimport * as React from \"react\";\n\nexport type ResponsiveValue =\n | number\n | {\n sm?: number;\n md?: number;\n lg?: number;\n xl?: number;\n };\n\n/**\n * Gap value that can be either:\n * - A space scale value from the theme (0, 100, 200, 300, 350, 400, 450, 500, 600)\n * - A pixel string value (e.g., \"16px\", \"20px\")\n */\nexport type GapValue = keyof TypeSpace | (string & {});\n\nexport interface ContainerProps {\n $columns?: ResponsiveValue;\n}\n\nexport interface GridProps {\n /** Number of columns (can be responsive) */\n columns?: ResponsiveValue;\n /** Gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., \"16px\") */\n gap?: GapValue;\n /** Row gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., \"16px\") */\n rowGap?: GapValue;\n /** Column gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., \"16px\") */\n columnGap?: GapValue;\n /** Children elements to display in the grid */\n children?: React.ReactNode;\n /** Custom className */\n className?: string;\n}\n","export const BREAKPOINTS = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,4BAAmB;AACnB,6BAAgB;;;ACDhB,+BAAoB;AACpB,+BAAsB;AAGtB,IAAM,EAAE,YAAY,IAAI;AAEjB,IAAM,sBAAsB,CAAC,UAA2B,MAAM;AACnE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,sCAC2B,OAAO;AAAA;AAAA,EAE3C;AAEA,SAAO;AAAA,oCAC2B,QAAQ,MAAM,CAAC;AAAA;AAAA,yBAE1B,YAAY,EAAE;AAAA,sCACD,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA,yBAG1C,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,yBAK5B,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAKnE;;;ADhBI;AAbJ,IAAM,gBAAY,0BAAAC,SAAO,uBAAAC,OAAG;AAAA,IACxB,CAAC,UAAU,oBAAoB,MAAM,QAAQ,CAAC;AAAA;AAGlD,IAAM,OAA4B,CAAC;AAAA,EACjC,UAAU;AAAA,EACV,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,QAAQ,UAAU;AAAA,MAClB,WAAW,aAAa;AAAA,MACxB,UAAU;AAAA,MACV;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;AE9Bf,IAAAC,SAAuB;;;ACDhB,IAAM,cAAc;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;;;AJHA,IAAO,gBAAQ;","names":["import_styled_components","styled","Box","React"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Grid.tsx","../src/utils.ts","../src/GridTypes.ts"],"sourcesContent":["import Grid from \"./Grid\";\n\nexport default Grid;\nexport { Grid };\nexport * from \"./GridTypes\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { ContainerProps, GridProps } from \"./GridTypes\";\nimport { getResponsiveStyles, toResponsiveGapObject } from \"./utils\";\n\nconst Container = styled(Box)<ContainerProps>`\n ${(props) => getResponsiveStyles(props.$columns)}\n`;\n\nconst Grid: React.FC<GridProps> = ({\n columns = 1,\n gap = 400,\n rowGap,\n columnGap,\n children,\n className,\n}) => {\n return (\n <Container\n display=\"grid\"\n rowGap={toResponsiveGapObject(rowGap ?? gap)}\n columnGap={toResponsiveGapObject(columnGap ?? gap)}\n $columns={columns}\n className={className}\n >\n {children}\n </Container>\n );\n};\n\nexport default Grid;\n","import type {\n GapValue,\n ResponsiveGapValue,\n ResponsiveValue,\n} from \"./GridTypes\";\nimport { css } from \"styled-components\";\nimport { theme } from \"@sproutsocial/seeds-react-theme\";\n\nconst { breakpoints } = theme;\n\nexport const toResponsiveGapObject = (\n value: ResponsiveGapValue\n):\n | GapValue\n | { sm?: GapValue; md?: GapValue; lg?: GapValue; xl?: GapValue } => {\n if (typeof value !== \"object\") return value;\n return value;\n};\n\nexport const getResponsiveStyles = (columns: ResponsiveValue = 1) => {\n if (typeof columns === \"number\") {\n return css`\n grid-template-columns: repeat(${columns}, 1fr);\n `;\n }\n\n return css`\n grid-template-columns: repeat(1, 1fr);\n\n @media (min-width: ${breakpoints.sm}) {\n grid-template-columns: repeat(${columns.sm || 1}, 1fr);\n }\n\n @media (min-width: ${breakpoints.md}) {\n grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);\n }\n\n @media (min-width: ${breakpoints.lg}) {\n grid-template-columns: repeat(\n ${columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n\n @media (min-width: ${breakpoints.xl}) {\n grid-template-columns: repeat(\n ${columns.xl || columns.lg || columns.md || columns.sm || 1},\n 1fr\n );\n }\n `;\n};\n","import type { TypeSpace } from \"@sproutsocial/seeds-react-theme\";\nimport * as React from \"react\";\n\nexport type ResponsiveValue =\n | number\n | {\n sm?: number;\n md?: number;\n lg?: number;\n xl?: number;\n };\n\n/**\n * Gap value that can be either:\n * - A space scale value from the theme (0, 100, 200, 300, 350, 400, 450, 500, 600)\n * - A pixel string value (e.g., \"16px\", \"20px\")\n */\nexport type GapValue = keyof TypeSpace | (string & {});\n\n/**\n * Responsive gap value that can be either:\n * - A single GapValue applied at all breakpoints\n * - An object with optional breakpoint keys (sm, md, lg, xl) for responsive values\n */\nexport type ResponsiveGapValue =\n | GapValue\n | {\n sm?: GapValue;\n md?: GapValue;\n lg?: GapValue;\n xl?: GapValue;\n };\n\nexport interface ContainerProps {\n $columns?: ResponsiveValue;\n}\n\nexport interface GridProps {\n /** Number of columns (can be responsive) */\n columns?: ResponsiveValue;\n /** 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 }) */\n gap?: ResponsiveGapValue;\n /** 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 }) */\n rowGap?: ResponsiveGapValue;\n /** 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 }) */\n columnGap?: ResponsiveGapValue;\n /** Children elements to display in the grid */\n children?: React.ReactNode;\n /** Custom className */\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,4BAAmB;AACnB,6BAAgB;;;ACGhB,+BAAoB;AACpB,+BAAsB;AAEtB,IAAM,EAAE,YAAY,IAAI;AAEjB,IAAM,wBAAwB,CACnC,UAGoE;AACpE,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO;AACT;AAEO,IAAM,sBAAsB,CAAC,UAA2B,MAAM;AACnE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,sCAC2B,OAAO;AAAA;AAAA,EAE3C;AAEA,SAAO;AAAA;AAAA;AAAA,yBAGgB,YAAY,EAAE;AAAA,sCACD,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA,yBAG5B,YAAY,EAAE;AAAA,sCACD,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA,yBAG1C,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,yBAK5B,YAAY,EAAE;AAAA;AAAA,UAE7B,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAKnE;;;ADhCI;AAbJ,IAAM,gBAAY,0BAAAC,SAAO,uBAAAC,OAAG;AAAA,IACxB,CAAC,UAAU,oBAAoB,MAAM,QAAQ,CAAC;AAAA;AAGlD,IAAM,OAA4B,CAAC;AAAA,EACjC,UAAU;AAAA,EACV,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,QAAQ,sBAAsB,UAAU,GAAG;AAAA,MAC3C,WAAW,sBAAsB,aAAa,GAAG;AAAA,MACjD,UAAU;AAAA,MACV;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;AE9Bf,IAAAC,SAAuB;;;AHCvB,IAAO,gBAAQ;","names":["import_styled_components","styled","Box","React"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-grid",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Seeds React Grid",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -18,8 +18,8 @@
18
18
  "test:watch": "jest --watch --coverage=false"
19
19
  },
20
20
  "dependencies": {
21
- "@sproutsocial/seeds-react-box": "^1.1.14",
22
- "@sproutsocial/seeds-react-theme": "^3.0.0",
21
+ "@sproutsocial/seeds-react-box": "^1.1.16",
22
+ "@sproutsocial/seeds-react-theme": "^3.6.2",
23
23
  "@sproutsocial/seeds-react-system-props": "^3.0.1"
24
24
  },
25
25
  "devDependencies": {
@@ -175,10 +175,16 @@ export const Playground: StoryObj<PlaygroundArgs> = {
175
175
  lg: columnsLg,
176
176
  xl: columnsXl,
177
177
  },
178
- ...(rowGap && (typeof rowGap === "string" || rowGap > 0)
178
+ ...(rowGap &&
179
+ (typeof rowGap === "string" ||
180
+ (typeof rowGap === "number" && rowGap > 0) ||
181
+ typeof rowGap === "object")
179
182
  ? { rowGap }
180
183
  : {}),
181
- ...(columnGap && (typeof columnGap === "string" || columnGap > 0)
184
+ ...(columnGap &&
185
+ (typeof columnGap === "string" ||
186
+ (typeof columnGap === "number" && columnGap > 0) ||
187
+ typeof columnGap === "object")
182
188
  ? { columnGap }
183
189
  : {}),
184
190
  };
@@ -198,6 +204,60 @@ export const Playground: StoryObj<PlaygroundArgs> = {
198
204
  },
199
205
  };
200
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
+
201
261
  export const NestedGrid: Story = {
202
262
  name: "Nested Grid Layout",
203
263
  args: {
package/src/Grid.tsx CHANGED
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import styled from "styled-components";
3
3
  import Box from "@sproutsocial/seeds-react-box";
4
4
  import type { ContainerProps, GridProps } from "./GridTypes";
5
- import { getResponsiveStyles } from "./utils";
5
+ import { getResponsiveStyles, toResponsiveGapObject } from "./utils";
6
6
 
7
7
  const Container = styled(Box)<ContainerProps>`
8
8
  ${(props) => getResponsiveStyles(props.$columns)}
@@ -19,8 +19,8 @@ const Grid: React.FC<GridProps> = ({
19
19
  return (
20
20
  <Container
21
21
  display="grid"
22
- rowGap={rowGap ?? gap}
23
- columnGap={columnGap ?? gap}
22
+ rowGap={toResponsiveGapObject(rowGap ?? gap)}
23
+ columnGap={toResponsiveGapObject(columnGap ?? gap)}
24
24
  $columns={columns}
25
25
  className={className}
26
26
  >
package/src/GridTypes.ts CHANGED
@@ -17,6 +17,20 @@ export type ResponsiveValue =
17
17
  */
18
18
  export type GapValue = keyof TypeSpace | (string & {});
19
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
+
20
34
  export interface ContainerProps {
21
35
  $columns?: ResponsiveValue;
22
36
  }
@@ -24,12 +38,12 @@ export interface ContainerProps {
24
38
  export interface GridProps {
25
39
  /** Number of columns (can be responsive) */
26
40
  columns?: ResponsiveValue;
27
- /** Gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
28
- gap?: GapValue;
29
- /** Row gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
30
- rowGap?: GapValue;
31
- /** Column gap between grid items. Use theme.space scale (0, 100, 200, 300, 350, 400, 450, 500, 600) or pixel string (e.g., "16px") */
32
- columnGap?: GapValue;
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;
33
47
  /** Children elements to display in the grid */
34
48
  children?: React.ReactNode;
35
49
  /** Custom className */
@@ -57,6 +57,36 @@ function GridTypes() {
57
57
  <div>Item 2</div>
58
58
  </Grid>
59
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
+
60
90
  {/* @ts-expect-error - invalid columns value */}
61
91
  <Grid columns="invalid">
62
92
  <div>Item</div>
@@ -151,6 +151,66 @@ describe("Grid", () => {
151
151
  expect(styles.columnGap).toBe("10px");
152
152
  });
153
153
 
154
+ it("should accept responsive object for gap", () => {
155
+ const { container } = render(
156
+ <Grid gap={{ sm: 400, md: 450, lg: 500 }}>
157
+ <div>Item 1</div>
158
+ <div>Item 2</div>
159
+ </Grid>
160
+ );
161
+ const gridElement = container.firstChild as HTMLElement;
162
+ const styles = window.getComputedStyle(gridElement);
163
+ expect(styles.display).toBe("grid");
164
+ });
165
+
166
+ it("should accept responsive object for rowGap", () => {
167
+ const { container } = render(
168
+ <Grid rowGap={{ sm: 300, md: 400 }} columnGap={400}>
169
+ <div>Item 1</div>
170
+ <div>Item 2</div>
171
+ </Grid>
172
+ );
173
+ const gridElement = container.firstChild as HTMLElement;
174
+ const styles = window.getComputedStyle(gridElement);
175
+ expect(styles.columnGap).toBe("16px");
176
+ });
177
+
178
+ it("should accept responsive object for columnGap", () => {
179
+ const { container } = render(
180
+ <Grid rowGap={400} columnGap={{ sm: 400, lg: 500 }}>
181
+ <div>Item 1</div>
182
+ <div>Item 2</div>
183
+ </Grid>
184
+ );
185
+ const gridElement = container.firstChild as HTMLElement;
186
+ const styles = window.getComputedStyle(gridElement);
187
+ expect(styles.rowGap).toBe("16px");
188
+ });
189
+
190
+ it("should mix responsive and static gap values", () => {
191
+ const { container } = render(
192
+ <Grid gap={{ sm: 400 }} columnGap={300}>
193
+ <div>Item 1</div>
194
+ <div>Item 2</div>
195
+ </Grid>
196
+ );
197
+ const gridElement = container.firstChild as HTMLElement;
198
+ const styles = window.getComputedStyle(gridElement);
199
+ expect(styles.columnGap).toBe("8px");
200
+ });
201
+
202
+ it("should accept responsive object with pixel strings", () => {
203
+ const { container } = render(
204
+ <Grid gap={{ sm: "16px", md: "24px" }}>
205
+ <div>Item 1</div>
206
+ <div>Item 2</div>
207
+ </Grid>
208
+ );
209
+ const gridElement = container.firstChild as HTMLElement;
210
+ const styles = window.getComputedStyle(gridElement);
211
+ expect(styles.display).toBe("grid");
212
+ });
213
+
154
214
  it("should render with single column by default", () => {
155
215
  const { container } = render(
156
216
  <Grid>
package/src/index.ts CHANGED
@@ -3,4 +3,3 @@ import Grid from "./Grid";
3
3
  export default Grid;
4
4
  export { Grid };
5
5
  export * from "./GridTypes";
6
- export { BREAKPOINTS } from "./constants";
package/src/utils.ts CHANGED
@@ -1,10 +1,22 @@
1
- import type { ResponsiveValue } from "./GridTypes";
1
+ import type {
2
+ GapValue,
3
+ ResponsiveGapValue,
4
+ ResponsiveValue,
5
+ } from "./GridTypes";
2
6
  import { css } from "styled-components";
3
7
  import { theme } from "@sproutsocial/seeds-react-theme";
4
- // WE may want to check this. I also see seeds-react/seeds-react-grid/src/constants.ts which has different values
5
- // And 900px for "small" seems way too big
8
+
6
9
  const { breakpoints } = theme;
7
10
 
11
+ export const toResponsiveGapObject = (
12
+ value: ResponsiveGapValue
13
+ ):
14
+ | GapValue
15
+ | { sm?: GapValue; md?: GapValue; lg?: GapValue; xl?: GapValue } => {
16
+ if (typeof value !== "object") return value;
17
+ return value;
18
+ };
19
+
8
20
  export const getResponsiveStyles = (columns: ResponsiveValue = 1) => {
9
21
  if (typeof columns === "number") {
10
22
  return css`
@@ -13,20 +25,24 @@ export const getResponsiveStyles = (columns: ResponsiveValue = 1) => {
13
25
  }
14
26
 
15
27
  return css`
16
- grid-template-columns: repeat(${columns.sm || 1}, 1fr);
28
+ grid-template-columns: repeat(1, 1fr);
29
+
30
+ @media (min-width: ${breakpoints.sm}) {
31
+ grid-template-columns: repeat(${columns.sm || 1}, 1fr);
32
+ }
17
33
 
18
- @media (min-width: ${breakpoints.md}px) {
34
+ @media (min-width: ${breakpoints.md}) {
19
35
  grid-template-columns: repeat(${columns.md || columns.sm || 1}, 1fr);
20
36
  }
21
37
 
22
- @media (min-width: ${breakpoints.lg}px) {
38
+ @media (min-width: ${breakpoints.lg}) {
23
39
  grid-template-columns: repeat(
24
40
  ${columns.lg || columns.md || columns.sm || 1},
25
41
  1fr
26
42
  );
27
43
  }
28
44
 
29
- @media (min-width: ${breakpoints.xl}px) {
45
+ @media (min-width: ${breakpoints.xl}) {
30
46
  grid-template-columns: repeat(
31
47
  ${columns.xl || columns.lg || columns.md || columns.sm || 1},
32
48
  1fr
package/src/constants.ts DELETED
@@ -1,6 +0,0 @@
1
- export const BREAKPOINTS = {
2
- sm: 640,
3
- md: 768,
4
- lg: 1024,
5
- xl: 1280,
6
- } as const;