@sproutsocial/seeds-react-stack 1.0.22 → 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/esm/index.js +125 -50
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +126 -51
- package/dist/index.js.map +1 -1
- package/dist/stack.css +99 -0
- package/package.json +17 -6
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -4
- package/.turbo/turbo-build.log +0 -21
- package/CHANGELOG.md +0 -187
- package/jest.config.js +0 -9
- package/src/Stack.stories.tsx +0 -102
- package/src/Stack.tsx +0 -116
- package/src/StackTypes.ts +0 -32
- package/src/__tests__/Stack.test.tsx +0 -26
- package/src/__tests__/Stack.typetest.tsx +0 -18
- package/src/index.ts +0 -5
- package/src/styled.d.ts +0 -7
- package/src/utils.ts +0 -42
- package/tsconfig.json +0 -15
- package/tsup.config.ts +0 -12
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.
|
|
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",
|
|
@@ -19,8 +30,8 @@
|
|
|
19
30
|
},
|
|
20
31
|
"dependencies": {
|
|
21
32
|
"@sproutsocial/seeds-react-theme": "^4.2.0",
|
|
22
|
-
"@sproutsocial/seeds-react-system-props": "^3.1.
|
|
23
|
-
"@sproutsocial/seeds-react-box": "^1.1.
|
|
33
|
+
"@sproutsocial/seeds-react-system-props": "^3.1.2",
|
|
34
|
+
"@sproutsocial/seeds-react-box": "^1.1.24"
|
|
24
35
|
},
|
|
25
36
|
"devDependencies": {
|
|
26
37
|
"@types/react": "^18.0.0",
|
|
@@ -33,7 +44,7 @@
|
|
|
33
44
|
"@sproutsocial/seeds-tsconfig": "*",
|
|
34
45
|
"@sproutsocial/seeds-testing": "*",
|
|
35
46
|
"@sproutsocial/seeds-react-testing-library": "*",
|
|
36
|
-
"@sproutsocial/seeds-react-text": "^1.5.
|
|
47
|
+
"@sproutsocial/seeds-react-text": "^1.5.1"
|
|
37
48
|
},
|
|
38
49
|
"peerDependencies": {
|
|
39
50
|
"styled-components": "^5.2.3"
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
yarn run v1.22.22
|
|
2
|
-
$ tsup --dts
|
|
3
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
4
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
|
-
[34mCLI[39m tsup v8.5.0
|
|
6
|
-
[34mCLI[39m Using tsup config: /home/runner/_work/seeds/seeds/seeds-react/seeds-react-stack/tsup.config.ts
|
|
7
|
-
[34mCLI[39m Target: es2022
|
|
8
|
-
[34mCLI[39m Cleaning output folder
|
|
9
|
-
[34mCJS[39m Build start
|
|
10
|
-
[34mESM[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[32m5.55 KB[39m
|
|
12
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m8.36 KB[39m
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in 76ms
|
|
14
|
-
[32mESM[39m [1mdist/esm/index.js [22m[32m3.75 KB[39m
|
|
15
|
-
[32mESM[39m [1mdist/esm/index.js.map [22m[32m8.25 KB[39m
|
|
16
|
-
[32mESM[39m ⚡️ Build success in 76ms
|
|
17
|
-
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in 3392ms
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.02 KB[39m
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.02 KB[39m
|
|
21
|
-
Done in 5.12s.
|
package/CHANGELOG.md
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# @sproutsocial/seeds-react-stack
|
|
2
|
-
|
|
3
|
-
## 1.0.22
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [85f9728]
|
|
8
|
-
- Updated dependencies [fa7d859]
|
|
9
|
-
- @sproutsocial/seeds-react-theme@4.2.0
|
|
10
|
-
- @sproutsocial/seeds-react-box@1.1.23
|
|
11
|
-
|
|
12
|
-
## 1.0.21
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- Updated dependencies [a13a571]
|
|
17
|
-
- @sproutsocial/seeds-react-theme@4.1.1
|
|
18
|
-
- @sproutsocial/seeds-react-box@1.1.22
|
|
19
|
-
|
|
20
|
-
## 1.0.20
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- Updated dependencies [5892f44]
|
|
25
|
-
- @sproutsocial/seeds-react-system-props@3.1.1
|
|
26
|
-
- @sproutsocial/seeds-react-box@1.1.21
|
|
27
|
-
|
|
28
|
-
## 1.0.19
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
31
|
-
|
|
32
|
-
- Updated dependencies [5114a32]
|
|
33
|
-
- @sproutsocial/seeds-react-theme@4.1.0
|
|
34
|
-
- @sproutsocial/seeds-react-box@1.1.20
|
|
35
|
-
|
|
36
|
-
## 1.0.18
|
|
37
|
-
|
|
38
|
-
### Patch Changes
|
|
39
|
-
|
|
40
|
-
- Updated dependencies [132ef9d]
|
|
41
|
-
- Updated dependencies [132ef9d]
|
|
42
|
-
- @sproutsocial/seeds-react-theme@4.0.0
|
|
43
|
-
- @sproutsocial/seeds-react-system-props@3.1.0
|
|
44
|
-
- @sproutsocial/seeds-react-box@1.1.19
|
|
45
|
-
|
|
46
|
-
## 1.0.17
|
|
47
|
-
|
|
48
|
-
### Patch Changes
|
|
49
|
-
|
|
50
|
-
- Updated dependencies [47c62b3]
|
|
51
|
-
- @sproutsocial/seeds-react-theme@3.7.1
|
|
52
|
-
- @sproutsocial/seeds-react-box@1.1.18
|
|
53
|
-
|
|
54
|
-
## 1.0.16
|
|
55
|
-
|
|
56
|
-
### Patch Changes
|
|
57
|
-
|
|
58
|
-
- Updated dependencies [06da9c2]
|
|
59
|
-
- @sproutsocial/seeds-react-theme@3.7.0
|
|
60
|
-
- @sproutsocial/seeds-react-box@1.1.17
|
|
61
|
-
|
|
62
|
-
## 1.0.15
|
|
63
|
-
|
|
64
|
-
### Patch Changes
|
|
65
|
-
|
|
66
|
-
- Updated dependencies [4ba8720]
|
|
67
|
-
- @sproutsocial/seeds-react-theme@3.6.2
|
|
68
|
-
- @sproutsocial/seeds-react-box@1.1.16
|
|
69
|
-
|
|
70
|
-
## 1.0.14
|
|
71
|
-
|
|
72
|
-
### Patch Changes
|
|
73
|
-
|
|
74
|
-
- Updated dependencies [1f9a473]
|
|
75
|
-
- @sproutsocial/seeds-react-theme@3.6.1
|
|
76
|
-
- @sproutsocial/seeds-react-box@1.1.15
|
|
77
|
-
|
|
78
|
-
## 1.0.13
|
|
79
|
-
|
|
80
|
-
### Patch Changes
|
|
81
|
-
|
|
82
|
-
- Updated dependencies [17d4f12]
|
|
83
|
-
- @sproutsocial/seeds-react-theme@3.6.0
|
|
84
|
-
- @sproutsocial/seeds-react-box@1.1.14
|
|
85
|
-
|
|
86
|
-
## 1.0.12
|
|
87
|
-
|
|
88
|
-
### Patch Changes
|
|
89
|
-
|
|
90
|
-
- Updated dependencies [118e300]
|
|
91
|
-
- @sproutsocial/seeds-react-theme@3.5.1
|
|
92
|
-
- @sproutsocial/seeds-react-box@1.1.13
|
|
93
|
-
|
|
94
|
-
## 1.0.11
|
|
95
|
-
|
|
96
|
-
### Patch Changes
|
|
97
|
-
|
|
98
|
-
- Updated dependencies [db6ce39]
|
|
99
|
-
- Updated dependencies [20bb01b]
|
|
100
|
-
- @sproutsocial/seeds-react-theme@3.5.0
|
|
101
|
-
- @sproutsocial/seeds-react-box@1.1.12
|
|
102
|
-
|
|
103
|
-
## 1.0.10
|
|
104
|
-
|
|
105
|
-
### Patch Changes
|
|
106
|
-
|
|
107
|
-
- Updated dependencies [7716e16]
|
|
108
|
-
- @sproutsocial/seeds-react-theme@3.4.0
|
|
109
|
-
- @sproutsocial/seeds-react-box@1.1.11
|
|
110
|
-
|
|
111
|
-
## 1.0.9
|
|
112
|
-
|
|
113
|
-
### Patch Changes
|
|
114
|
-
|
|
115
|
-
- @sproutsocial/seeds-react-theme@3.3.2
|
|
116
|
-
- @sproutsocial/seeds-react-box@1.1.10
|
|
117
|
-
|
|
118
|
-
## 1.0.8
|
|
119
|
-
|
|
120
|
-
### Patch Changes
|
|
121
|
-
|
|
122
|
-
- @sproutsocial/seeds-react-theme@3.3.1
|
|
123
|
-
- @sproutsocial/seeds-react-box@1.1.9
|
|
124
|
-
|
|
125
|
-
## 1.0.7
|
|
126
|
-
|
|
127
|
-
### Patch Changes
|
|
128
|
-
|
|
129
|
-
- Updated dependencies [750d1ea]
|
|
130
|
-
- @sproutsocial/seeds-react-theme@3.3.0
|
|
131
|
-
- @sproutsocial/seeds-react-box@1.1.8
|
|
132
|
-
|
|
133
|
-
## 1.0.6
|
|
134
|
-
|
|
135
|
-
### Patch Changes
|
|
136
|
-
|
|
137
|
-
- Updated dependencies [fa7579a]
|
|
138
|
-
- @sproutsocial/seeds-react-theme@3.2.1
|
|
139
|
-
- @sproutsocial/seeds-react-box@1.1.7
|
|
140
|
-
|
|
141
|
-
## 1.0.5
|
|
142
|
-
|
|
143
|
-
### Patch Changes
|
|
144
|
-
|
|
145
|
-
- Updated dependencies [8f6ba8d]
|
|
146
|
-
- @sproutsocial/seeds-react-theme@3.2.0
|
|
147
|
-
- @sproutsocial/seeds-react-box@1.1.6
|
|
148
|
-
|
|
149
|
-
## 1.0.4
|
|
150
|
-
|
|
151
|
-
### Patch Changes
|
|
152
|
-
|
|
153
|
-
- Updated dependencies [b1c3b44]
|
|
154
|
-
- @sproutsocial/seeds-react-theme@3.1.1
|
|
155
|
-
- @sproutsocial/seeds-react-box@1.1.5
|
|
156
|
-
|
|
157
|
-
## 1.0.3
|
|
158
|
-
|
|
159
|
-
### Patch Changes
|
|
160
|
-
|
|
161
|
-
- Updated dependencies [47580c4]
|
|
162
|
-
- @sproutsocial/seeds-react-theme@3.1.0
|
|
163
|
-
- @sproutsocial/seeds-react-box@1.1.4
|
|
164
|
-
|
|
165
|
-
## 1.0.2
|
|
166
|
-
|
|
167
|
-
### Patch Changes
|
|
168
|
-
|
|
169
|
-
- Updated dependencies [22e1111]
|
|
170
|
-
- @sproutsocial/seeds-react-theme@3.0.1
|
|
171
|
-
- @sproutsocial/seeds-react-box@1.1.3
|
|
172
|
-
|
|
173
|
-
## 1.0.1
|
|
174
|
-
|
|
175
|
-
### Patch Changes
|
|
176
|
-
|
|
177
|
-
- 9fd8bac: Update dependencies to use semantic package version instead of wildcards
|
|
178
|
-
- Updated dependencies [9fd8bac]
|
|
179
|
-
- @sproutsocial/seeds-react-system-props@3.0.2
|
|
180
|
-
- @sproutsocial/seeds-react-theme@2.2.1
|
|
181
|
-
- @sproutsocial/seeds-react-box@1.1.2
|
|
182
|
-
|
|
183
|
-
## 1.0.0
|
|
184
|
-
|
|
185
|
-
### Major Changes
|
|
186
|
-
|
|
187
|
-
- bd8d03d: Migrate Stack to its own seeds-react-stack component
|
package/jest.config.js
DELETED
package/src/Stack.stories.tsx
DELETED
|
@@ -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
package/src/styled.d.ts
DELETED