@sproutsocial/seeds-react-stack 1.0.23 → 1.0.24

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/dist/stack.css ADDED
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Seeds Stack component classes
3
+ * Use these instead of writing out individual Tailwind utility classes.
4
+ *
5
+ * Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
6
+ * CSS variable definitions and dark mode support.
7
+ *
8
+ * Usage:
9
+ * <div class="seeds-stack seeds-stack-vertical seeds-stack-align-left seeds-stack-space-300">…</div>
10
+ */
11
+
12
+ /*
13
+ * Wrapped in @layer components so consumer Tailwind utilities (which live in
14
+ * @layer utilities, ordered after components) can override these component
15
+ * styles. Unlayered rules would always win the cascade regardless of source
16
+ * order, preventing overrides like className="inline-flex mx-200".
17
+ */
18
+ @layer components {
19
+ .seeds-stack {
20
+ display: flex;
21
+ }
22
+
23
+ .seeds-stack-vertical {
24
+ flex-direction: column;
25
+ }
26
+
27
+ .seeds-stack-horizontal {
28
+ flex-direction: row;
29
+ align-items: center;
30
+ }
31
+
32
+ /* vertical: align controls the cross axis (align-items) */
33
+ .seeds-stack-vertical.seeds-stack-align-left {
34
+ align-items: flex-start;
35
+ }
36
+
37
+ .seeds-stack-vertical.seeds-stack-align-center {
38
+ align-items: center;
39
+ }
40
+
41
+ .seeds-stack-vertical.seeds-stack-align-right {
42
+ align-items: flex-end;
43
+ }
44
+
45
+ .seeds-stack-vertical.seeds-stack-align-stretch {
46
+ align-items: stretch;
47
+ }
48
+
49
+ /* horizontal: align-items stays center; align controls justify-content */
50
+ .seeds-stack-horizontal.seeds-stack-align-center {
51
+ justify-content: center;
52
+ }
53
+
54
+ .seeds-stack-horizontal.seeds-stack-align-right {
55
+ justify-content: flex-end;
56
+ }
57
+
58
+ /* stretch + horizontal: stretch each child to fill (replicates flexBasis: 100%) */
59
+ .seeds-stack-horizontal.seeds-stack-align-stretch > * {
60
+ flex-basis: 100%;
61
+ }
62
+
63
+ /* spacing via gap (replaces the per-child margins of the styled-components path) */
64
+ .seeds-stack-space-0 {
65
+ gap: var(--space-0);
66
+ }
67
+
68
+ .seeds-stack-space-100 {
69
+ gap: var(--space-100);
70
+ }
71
+
72
+ .seeds-stack-space-200 {
73
+ gap: var(--space-200);
74
+ }
75
+
76
+ .seeds-stack-space-300 {
77
+ gap: var(--space-300);
78
+ }
79
+
80
+ .seeds-stack-space-350 {
81
+ gap: var(--space-350);
82
+ }
83
+
84
+ .seeds-stack-space-400 {
85
+ gap: var(--space-400);
86
+ }
87
+
88
+ .seeds-stack-space-450 {
89
+ gap: var(--space-450);
90
+ }
91
+
92
+ .seeds-stack-space-500 {
93
+ gap: var(--space-500);
94
+ }
95
+
96
+ .seeds-stack-space-600 {
97
+ gap: var(--space-600);
98
+ }
99
+ }
package/package.json CHANGED
@@ -1,15 +1,26 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-stack",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Seeds React Stack",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/esm/index.js",
16
+ "require": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ },
19
+ "./dist/stack.css": "./dist/stack.css"
20
+ },
10
21
  "scripts": {
11
- "build": "tsup --dts",
12
- "build:debug": "tsup --dts --metafile",
22
+ "build": "tsup --dts && cp src/stack.css dist/stack.css",
23
+ "build:debug": "tsup --dts --metafile && cp src/stack.css dist/stack.css",
13
24
  "dev": "tsup --watch --dts",
14
25
  "clean": "rm -rf .turbo dist",
15
26
  "clean:modules": "rm -rf node_modules",
package/.eslintignore DELETED
@@ -1,6 +0,0 @@
1
- # Node modules
2
- node_modules/
3
-
4
- # Build output
5
- dist/
6
- coverage/
package/.eslintrc.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: ["eslint-config-seeds/racine"],
4
- };
@@ -1,21 +0,0 @@
1
- yarn run v1.22.22
2
- $ tsup --dts
3
- CLI Building entry: src/index.ts
4
- CLI Using tsconfig: tsconfig.json
5
- CLI tsup v8.5.0
6
- CLI Using tsup config: /home/runner/_work/seeds/seeds/seeds-react/seeds-react-stack/tsup.config.ts
7
- CLI Target: es2022
8
- CLI Cleaning output folder
9
- CJS Build start
10
- ESM Build start
11
- CJS dist/index.js 5.55 KB
12
- CJS dist/index.js.map 8.36 KB
13
- CJS ⚡️ Build success in 14ms
14
- ESM dist/esm/index.js 3.75 KB
15
- ESM dist/esm/index.js.map 8.25 KB
16
- ESM ⚡️ Build success in 15ms
17
- DTS Build start
18
- DTS ⚡️ Build success in 4190ms
19
- DTS dist/index.d.ts 1.02 KB
20
- DTS dist/index.d.mts 1.02 KB
21
- Done in 5.57s.
package/CHANGELOG.md DELETED
@@ -1,195 +0,0 @@
1
- # @sproutsocial/seeds-react-stack
2
-
3
- ## 1.0.23
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [6611f6a]
8
- - @sproutsocial/seeds-react-system-props@3.1.2
9
- - @sproutsocial/seeds-react-box@1.1.24
10
-
11
- ## 1.0.22
12
-
13
- ### Patch Changes
14
-
15
- - Updated dependencies [85f9728]
16
- - Updated dependencies [fa7d859]
17
- - @sproutsocial/seeds-react-theme@4.2.0
18
- - @sproutsocial/seeds-react-box@1.1.23
19
-
20
- ## 1.0.21
21
-
22
- ### Patch Changes
23
-
24
- - Updated dependencies [a13a571]
25
- - @sproutsocial/seeds-react-theme@4.1.1
26
- - @sproutsocial/seeds-react-box@1.1.22
27
-
28
- ## 1.0.20
29
-
30
- ### Patch Changes
31
-
32
- - Updated dependencies [5892f44]
33
- - @sproutsocial/seeds-react-system-props@3.1.1
34
- - @sproutsocial/seeds-react-box@1.1.21
35
-
36
- ## 1.0.19
37
-
38
- ### Patch Changes
39
-
40
- - Updated dependencies [5114a32]
41
- - @sproutsocial/seeds-react-theme@4.1.0
42
- - @sproutsocial/seeds-react-box@1.1.20
43
-
44
- ## 1.0.18
45
-
46
- ### Patch Changes
47
-
48
- - Updated dependencies [132ef9d]
49
- - Updated dependencies [132ef9d]
50
- - @sproutsocial/seeds-react-theme@4.0.0
51
- - @sproutsocial/seeds-react-system-props@3.1.0
52
- - @sproutsocial/seeds-react-box@1.1.19
53
-
54
- ## 1.0.17
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies [47c62b3]
59
- - @sproutsocial/seeds-react-theme@3.7.1
60
- - @sproutsocial/seeds-react-box@1.1.18
61
-
62
- ## 1.0.16
63
-
64
- ### Patch Changes
65
-
66
- - Updated dependencies [06da9c2]
67
- - @sproutsocial/seeds-react-theme@3.7.0
68
- - @sproutsocial/seeds-react-box@1.1.17
69
-
70
- ## 1.0.15
71
-
72
- ### Patch Changes
73
-
74
- - Updated dependencies [4ba8720]
75
- - @sproutsocial/seeds-react-theme@3.6.2
76
- - @sproutsocial/seeds-react-box@1.1.16
77
-
78
- ## 1.0.14
79
-
80
- ### Patch Changes
81
-
82
- - Updated dependencies [1f9a473]
83
- - @sproutsocial/seeds-react-theme@3.6.1
84
- - @sproutsocial/seeds-react-box@1.1.15
85
-
86
- ## 1.0.13
87
-
88
- ### Patch Changes
89
-
90
- - Updated dependencies [17d4f12]
91
- - @sproutsocial/seeds-react-theme@3.6.0
92
- - @sproutsocial/seeds-react-box@1.1.14
93
-
94
- ## 1.0.12
95
-
96
- ### Patch Changes
97
-
98
- - Updated dependencies [118e300]
99
- - @sproutsocial/seeds-react-theme@3.5.1
100
- - @sproutsocial/seeds-react-box@1.1.13
101
-
102
- ## 1.0.11
103
-
104
- ### Patch Changes
105
-
106
- - Updated dependencies [db6ce39]
107
- - Updated dependencies [20bb01b]
108
- - @sproutsocial/seeds-react-theme@3.5.0
109
- - @sproutsocial/seeds-react-box@1.1.12
110
-
111
- ## 1.0.10
112
-
113
- ### Patch Changes
114
-
115
- - Updated dependencies [7716e16]
116
- - @sproutsocial/seeds-react-theme@3.4.0
117
- - @sproutsocial/seeds-react-box@1.1.11
118
-
119
- ## 1.0.9
120
-
121
- ### Patch Changes
122
-
123
- - @sproutsocial/seeds-react-theme@3.3.2
124
- - @sproutsocial/seeds-react-box@1.1.10
125
-
126
- ## 1.0.8
127
-
128
- ### Patch Changes
129
-
130
- - @sproutsocial/seeds-react-theme@3.3.1
131
- - @sproutsocial/seeds-react-box@1.1.9
132
-
133
- ## 1.0.7
134
-
135
- ### Patch Changes
136
-
137
- - Updated dependencies [750d1ea]
138
- - @sproutsocial/seeds-react-theme@3.3.0
139
- - @sproutsocial/seeds-react-box@1.1.8
140
-
141
- ## 1.0.6
142
-
143
- ### Patch Changes
144
-
145
- - Updated dependencies [fa7579a]
146
- - @sproutsocial/seeds-react-theme@3.2.1
147
- - @sproutsocial/seeds-react-box@1.1.7
148
-
149
- ## 1.0.5
150
-
151
- ### Patch Changes
152
-
153
- - Updated dependencies [8f6ba8d]
154
- - @sproutsocial/seeds-react-theme@3.2.0
155
- - @sproutsocial/seeds-react-box@1.1.6
156
-
157
- ## 1.0.4
158
-
159
- ### Patch Changes
160
-
161
- - Updated dependencies [b1c3b44]
162
- - @sproutsocial/seeds-react-theme@3.1.1
163
- - @sproutsocial/seeds-react-box@1.1.5
164
-
165
- ## 1.0.3
166
-
167
- ### Patch Changes
168
-
169
- - Updated dependencies [47580c4]
170
- - @sproutsocial/seeds-react-theme@3.1.0
171
- - @sproutsocial/seeds-react-box@1.1.4
172
-
173
- ## 1.0.2
174
-
175
- ### Patch Changes
176
-
177
- - Updated dependencies [22e1111]
178
- - @sproutsocial/seeds-react-theme@3.0.1
179
- - @sproutsocial/seeds-react-box@1.1.3
180
-
181
- ## 1.0.1
182
-
183
- ### Patch Changes
184
-
185
- - 9fd8bac: Update dependencies to use semantic package version instead of wildcards
186
- - Updated dependencies [9fd8bac]
187
- - @sproutsocial/seeds-react-system-props@3.0.2
188
- - @sproutsocial/seeds-react-theme@2.2.1
189
- - @sproutsocial/seeds-react-box@1.1.2
190
-
191
- ## 1.0.0
192
-
193
- ### Major Changes
194
-
195
- - bd8d03d: Migrate Stack to its own seeds-react-stack component
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-stack",
7
- };
8
-
9
- module.exports = config;
@@ -1,102 +0,0 @@
1
- import React from "react";
2
- import type { Meta, StoryObj } from "@storybook/react";
3
- import Text from "@sproutsocial/seeds-react-text";
4
- import Stack from "./Stack";
5
-
6
- const meta: Meta<typeof Stack> = {
7
- title: "Components/Stack",
8
- component: Stack,
9
- argTypes: {
10
- align: {
11
- options: ["left", "center", "right", "stretch"],
12
- control: {
13
- type: "select",
14
- },
15
- },
16
- direction: {
17
- options: ["horizontal", "vertical"],
18
- control: {
19
- type: "select",
20
- },
21
- },
22
- },
23
- args: {
24
- align: undefined,
25
- direction: undefined,
26
- },
27
- };
28
- export default meta;
29
-
30
- interface ItemProps {
31
- children: React.ReactNode;
32
- }
33
-
34
- const Item: React.FC<ItemProps> = (props) => (
35
- <Text as="p" color="text.body" {...props} />
36
- );
37
-
38
- type Story = StoryObj<typeof Stack>;
39
-
40
- export const DefaultStory: Story = {
41
- name: "Default (Vertical)",
42
- args: {
43
- // ...existing code...
44
- },
45
- render: (args) => (
46
- <Stack p={400} {...args}>
47
- <Item>This</Item>
48
- <Item>is</Item>
49
- <Item>the</Item>
50
- <Item>stack</Item>
51
- <Item>component</Item>
52
- </Stack>
53
- ),
54
- };
55
-
56
- export const ResponsiveDirection: Story = {
57
- name: "Responsive direction",
58
- args: {
59
- direction: ["vertical", "horizontal", "vertical"],
60
- },
61
- render: (args) => (
62
- <Stack p={400} {...args}>
63
- <Item>Stack</Item>
64
- <Item>is</Item>
65
- <Item>a</Item>
66
- <Item>layout</Item>
67
- <Item>utility</Item>
68
- </Stack>
69
- ),
70
- };
71
-
72
- export const ResponsiveAlignment: Story = {
73
- name: "Responsive alignment",
74
- args: {
75
- align: ["left", "center", "stretch"],
76
- },
77
- render: (args) => (
78
- <Stack p={400} {...args}>
79
- <Item>Stack</Item>
80
- <Item>is</Item>
81
- <Item>a</Item>
82
- <Item>layout</Item>
83
- <Item>utility</Item>
84
- </Stack>
85
- ),
86
- };
87
-
88
- export const ResponsiveSpace: Story = {
89
- name: "Responsive space",
90
- args: {
91
- space: [300, 450, 600],
92
- },
93
- render: (args) => (
94
- <Stack p={400} {...args}>
95
- <Item>Stack</Item>
96
- <Item>is</Item>
97
- <Item>a</Item>
98
- <Item>layout</Item>
99
- <Item>utility</Item>
100
- </Stack>
101
- ),
102
- };
package/src/Stack.tsx DELETED
@@ -1,116 +0,0 @@
1
- import * as React from "react";
2
- import { Children } from "react";
3
- import { normalizeResponsiveProp } from "./utils";
4
- import Box from "@sproutsocial/seeds-react-box";
5
- import type { TypeStackProps } from "./StackTypes";
6
-
7
- const stackStyles = {
8
- horizontal: {
9
- left: {
10
- alignItems: "center",
11
- },
12
- center: {
13
- alignItems: "center",
14
- justifyContent: "center",
15
- },
16
- right: {
17
- alignItems: "center",
18
- justifyContent: "flex-end",
19
- },
20
- stretch: {
21
- alignItems: "center",
22
- },
23
- },
24
- vertical: {
25
- left: {
26
- flexDirection: "column",
27
- alignItems: "flex-start",
28
- },
29
- center: {
30
- flexDirection: "column",
31
- alignItems: "center",
32
- },
33
- right: {
34
- flexDirection: "column",
35
- alignItems: "flex-end",
36
- },
37
- stretch: {
38
- flexDirection: "column",
39
- alignItems: "stretch",
40
- },
41
- },
42
- };
43
-
44
- const Stack = ({
45
- children,
46
- space = 300,
47
- align = "left",
48
- direction = "vertical",
49
- ...rest
50
- }: TypeStackProps) => {
51
- const stackItems = Children.toArray(children);
52
- const responsiveAlignment = normalizeResponsiveProp(align);
53
- const responsiveDirection = normalizeResponsiveProp(direction);
54
- const responsiveSpace = normalizeResponsiveProp(space);
55
- const initialValue = ["initial", "initial", "initial", "initial", "initial"];
56
-
57
- // TODO: rely on styled system to solve this during the refactor
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- const styleProps: any = {
60
- alignItems: [...initialValue],
61
- flexDirection: [...initialValue],
62
- justifyContent: [...initialValue],
63
- };
64
- const childFlexBasis: (string | null)[] = [...initialValue];
65
- const childMarginProps = {
66
- marginLeft: [...initialValue],
67
- marginTop: [...initialValue],
68
- };
69
-
70
- initialValue.forEach((_, i) => {
71
- const currentDirection = responsiveDirection[i] as keyof typeof stackStyles;
72
- const currentAlignment = responsiveAlignment[
73
- i
74
- ] as keyof (typeof stackStyles)["horizontal"];
75
- const currentSpace = responsiveSpace[i];
76
-
77
- if (currentDirection && currentAlignment) {
78
- const styles: { [key: string]: string } =
79
- stackStyles[currentDirection][currentAlignment];
80
- Object.keys(styleProps).forEach((key: string) => {
81
- styleProps[key][i] = styles[key] || "initial";
82
- });
83
- }
84
-
85
- const flexBasis =
86
- currentAlignment === "stretch" && currentDirection === "horizontal"
87
- ? "100%"
88
- : null;
89
- childFlexBasis[i] = flexBasis;
90
-
91
- const margin =
92
- currentDirection === "horizontal" ? "marginLeft" : "marginTop";
93
-
94
- const opposite =
95
- currentDirection === "horizontal" ? "marginTop" : "marginLeft";
96
- childMarginProps[margin][i] = currentSpace;
97
- // styled system can pass numbers that map to theme values and TS doesn't like it
98
- childMarginProps[opposite][i] = 0 as unknown as string;
99
- });
100
-
101
- return (
102
- <Box display="flex" {...styleProps} {...rest}>
103
- {stackItems.map((item, i) => (
104
- <Box
105
- flexBasis={childFlexBasis}
106
- {...(i !== 0 ? childMarginProps : {})}
107
- key={i}
108
- >
109
- {item}
110
- </Box>
111
- ))}
112
- </Box>
113
- );
114
- };
115
-
116
- export default Stack;
package/src/StackTypes.ts DELETED
@@ -1,32 +0,0 @@
1
- import * as React from "react";
2
-
3
- import type { TypeResponsive } from "@sproutsocial/seeds-react-system-props";
4
- import type { TypeBoxProps } from "@sproutsocial/seeds-react-box";
5
-
6
- export type TypeSpaceLiterals =
7
- | 0
8
- | 100
9
- | 200
10
- | 300
11
- | 350
12
- | 400
13
- | 450
14
- | 500
15
- | 600
16
- | string;
17
-
18
- type TypeDirection = "vertical" | "horizontal";
19
-
20
- type TypeAlignment = "left" | "center" | "right" | "stretch";
21
-
22
- export interface TypeStackProps extends TypeBoxProps {
23
- /** Amount of space between items in the stack */
24
- space?: TypeResponsive<TypeSpaceLiterals>;
25
-
26
- /** Alignment of the items in the stack (horizontal or vertical) */
27
- align?: TypeResponsive<TypeAlignment>;
28
-
29
- /** Axis upon which the stack is laid out (left, center, right, or stretch) */
30
- direction?: TypeResponsive<TypeDirection>;
31
- children: React.ReactNode;
32
- }
@@ -1,26 +0,0 @@
1
- import React from "react";
2
- import { render } from "@sproutsocial/seeds-react-testing-library";
3
- import { Text } from "@sproutsocial/seeds-react-text";
4
- import Stack from "../Stack";
5
-
6
- interface ItemProps {
7
- [key: string]: any;
8
- }
9
-
10
- const Item = (props: ItemProps) => (
11
- <Text as="div" color="text.body" bg="container.background.base" {...props}>
12
- {props.children}
13
- </Text>
14
- );
15
-
16
- describe("Stack", () => {
17
- it("should render properly", async () => {
18
- const { container, runA11yCheck } = render(
19
- <Stack>
20
- <Item>Hello world!</Item>
21
- </Stack>
22
- );
23
- expect(container).toBeTruthy();
24
- await runA11yCheck();
25
- });
26
- });
@@ -1,18 +0,0 @@
1
- import * as React from "react";
2
- import { Box } from "@sproutsocial/seeds-react-box";
3
- import Stack from "../Stack";
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- function StackTypes() {
7
- return (
8
- <>
9
- <Stack space={300} align="center" direction="horizontal">
10
- <Box>Seeds</Box>
11
- <Box>Design</Box>
12
- <Box>System</Box>
13
- </Stack>
14
- {/* @ts-expect-error - test that invalid children are rejected */}
15
- <Stack />
16
- </>
17
- );
18
- }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import Stack from "./Stack";
2
-
3
- export default Stack;
4
- export { Stack };
5
- export * from "./StackTypes";
package/src/styled.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import "styled-components";
2
- import { TypeTheme } from "@sproutsocial/seeds-react-theme";
3
-
4
- declare module "styled-components" {
5
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
- export interface DefaultTheme extends TypeTheme {}
7
- }