@spark-web/stack 1.0.3 → 1.0.4
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/README.md +8 -5
- package/dist/spark-web-stack.cjs.dev.js +3 -1
- package/dist/spark-web-stack.cjs.prod.js +3 -1
- package/dist/spark-web-stack.esm.js +3 -1
- package/package.json +8 -5
- package/CHANGELOG.md +0 -67
- package/src/Stack.stories.tsx +0 -27
- package/src/Stack.tsx +0 -59
- package/src/alignment.ts +0 -12
- package/src/index.ts +0 -5
package/README.md
CHANGED
|
@@ -103,10 +103,11 @@ Nest Stack components to create more complex white space rules.
|
|
|
103
103
|
|
|
104
104
|
## Props
|
|
105
105
|
|
|
106
|
-
| Prop | Type
|
|
107
|
-
| --------- |
|
|
108
|
-
| align? | [ResponsiveProp\<Align>][align]
|
|
109
|
-
| dividers? | boolean
|
|
106
|
+
| Prop | Type | Default | Description |
|
|
107
|
+
| --------- | -------------------------------------- | --------- | ----------------------------------------------------- |
|
|
108
|
+
| align? | [ResponsiveProp\<Align>][align] | 'stretch' | Horizontally align items within the container. |
|
|
109
|
+
| dividers? | boolean | | Sets whether to place a divider between each element. |
|
|
110
|
+
| data? | [DataAttributeMap][data-attribute-map] | | Sets data attributes on the component. |
|
|
110
111
|
|
|
111
112
|
`Stack` props also include [`Box`](/package/box) props and are not listed here
|
|
112
113
|
(excludes `display`, `className`, `alignItems`, `flexDirection`,
|
|
@@ -115,4 +116,6 @@ Nest Stack components to create more complex white space rules.
|
|
|
115
116
|
Extra props are also passed into the underlying [`Box`](/package/box) component.
|
|
116
117
|
|
|
117
118
|
[align]:
|
|
118
|
-
https://
|
|
119
|
+
https://github.com/brighte-labs/spark-web/blob/e7f6f4285b4cfd876312cc89fbdd094039aa239a/packages/stack/src/Stack.tsx#L24
|
|
120
|
+
[data-attribute-map]:
|
|
121
|
+
https://github.com/brighte-labs/spark-web/blob/e7f6f4285b4cfd876312cc89fbdd094039aa239a/packages/utils/src/internal/buildDataAttributes.ts#L1
|
|
@@ -19,11 +19,12 @@ var alignLookup = {
|
|
|
19
19
|
};
|
|
20
20
|
var alignToAlignItems = theme.createResponsiveMapFn(alignLookup);
|
|
21
21
|
|
|
22
|
-
var _excluded = ["align", "children", "dividers"];
|
|
22
|
+
var _excluded = ["align", "children", "data", "dividers"];
|
|
23
23
|
var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
24
24
|
var _ref$align = _ref.align,
|
|
25
25
|
align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
|
26
26
|
children = _ref.children,
|
|
27
|
+
data = _ref.data,
|
|
27
28
|
dividers = _ref.dividers,
|
|
28
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
30
|
|
|
@@ -32,6 +33,7 @@ var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
32
33
|
var rootProps = _objectSpread({
|
|
33
34
|
ref: forwardedRef,
|
|
34
35
|
alignItems: alignItems,
|
|
36
|
+
data: data,
|
|
35
37
|
display: 'flex',
|
|
36
38
|
flexDirection: 'column'
|
|
37
39
|
}, props); // bail early w/o dividers to avoid unnecessary map
|
|
@@ -19,11 +19,12 @@ var alignLookup = {
|
|
|
19
19
|
};
|
|
20
20
|
var alignToAlignItems = theme.createResponsiveMapFn(alignLookup);
|
|
21
21
|
|
|
22
|
-
var _excluded = ["align", "children", "dividers"];
|
|
22
|
+
var _excluded = ["align", "children", "data", "dividers"];
|
|
23
23
|
var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
24
24
|
var _ref$align = _ref.align,
|
|
25
25
|
align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
|
26
26
|
children = _ref.children,
|
|
27
|
+
data = _ref.data,
|
|
27
28
|
dividers = _ref.dividers,
|
|
28
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
30
|
|
|
@@ -32,6 +33,7 @@ var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
32
33
|
var rootProps = _objectSpread({
|
|
33
34
|
ref: forwardedRef,
|
|
34
35
|
alignItems: alignItems,
|
|
36
|
+
data: data,
|
|
35
37
|
display: 'flex',
|
|
36
38
|
flexDirection: 'column'
|
|
37
39
|
}, props); // bail early w/o dividers to avoid unnecessary map
|
|
@@ -15,11 +15,12 @@ var alignLookup = {
|
|
|
15
15
|
};
|
|
16
16
|
var alignToAlignItems = createResponsiveMapFn(alignLookup);
|
|
17
17
|
|
|
18
|
-
var _excluded = ["align", "children", "dividers"];
|
|
18
|
+
var _excluded = ["align", "children", "data", "dividers"];
|
|
19
19
|
var Stack = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
20
20
|
var _ref$align = _ref.align,
|
|
21
21
|
align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
|
22
22
|
children = _ref.children,
|
|
23
|
+
data = _ref.data,
|
|
23
24
|
dividers = _ref.dividers,
|
|
24
25
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
26
|
|
|
@@ -28,6 +29,7 @@ var Stack = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
28
29
|
var rootProps = _objectSpread({
|
|
29
30
|
ref: forwardedRef,
|
|
30
31
|
alignItems: alignItems,
|
|
32
|
+
data: data,
|
|
31
33
|
display: 'flex',
|
|
32
34
|
flexDirection: 'column'
|
|
33
35
|
}, props); // bail early w/o dividers to avoid unnecessary map
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/stack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/spark-web-stack.cjs.js",
|
|
6
6
|
"module": "dist/spark-web-stack.esm.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"dependencies": {
|
|
8
11
|
"@babel/runtime": "^7.14.6",
|
|
9
12
|
"@emotion/css": "^11.7.1",
|
|
10
|
-
"@spark-web/box": "^1.0.
|
|
11
|
-
"@spark-web/divider": "^1.0.
|
|
12
|
-
"@spark-web/theme": "^
|
|
13
|
-
"@spark-web/utils": "^1.1.
|
|
13
|
+
"@spark-web/box": "^1.0.4",
|
|
14
|
+
"@spark-web/divider": "^1.0.4",
|
|
15
|
+
"@spark-web/theme": "^3.0.0",
|
|
16
|
+
"@spark-web/utils": "^1.1.2"
|
|
14
17
|
},
|
|
15
18
|
"devDependencies": {
|
|
16
19
|
"@types/react": "^17.0.12",
|
package/CHANGELOG.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# @spark-web/stack
|
|
2
|
-
|
|
3
|
-
## 1.0.3
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#42](https://github.com/brighte-labs/spark-web/pull/42)
|
|
8
|
-
[`435779a`](https://github.com/brighte-labs/spark-web/commit/435779aa42bd635bbf43e1fd41724c666402caa2)
|
|
9
|
-
Thanks [@lukebennett88](https://github.com/lukebennett88)! - Prevent multiple
|
|
10
|
-
versions of React
|
|
11
|
-
|
|
12
|
-
- Updated dependencies
|
|
13
|
-
[[`435779a`](https://github.com/brighte-labs/spark-web/commit/435779aa42bd635bbf43e1fd41724c666402caa2)]:
|
|
14
|
-
- @spark-web/box@1.0.3
|
|
15
|
-
- @spark-web/divider@1.0.3
|
|
16
|
-
- @spark-web/theme@2.0.2
|
|
17
|
-
- @spark-web/utils@1.1.1
|
|
18
|
-
|
|
19
|
-
## 1.0.2
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- [#40](https://github.com/brighte-labs/spark-web/pull/40)
|
|
24
|
-
[`062c8ab`](https://github.com/brighte-labs/spark-web/commit/062c8ab8c7b4120f8d14c269b5f7801288c678ca)
|
|
25
|
-
Thanks [@lukebennett88](https://github.com/lukebennett88)! - Add
|
|
26
|
-
@babel/transform-runtime
|
|
27
|
-
|
|
28
|
-
- Updated dependencies
|
|
29
|
-
[[`062c8ab`](https://github.com/brighte-labs/spark-web/commit/062c8ab8c7b4120f8d14c269b5f7801288c678ca)]:
|
|
30
|
-
- @spark-web/box@1.0.2
|
|
31
|
-
- @spark-web/divider@1.0.2
|
|
32
|
-
- @spark-web/theme@2.0.1
|
|
33
|
-
- @spark-web/utils@1.0.2
|
|
34
|
-
|
|
35
|
-
## 1.0.1
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- [#36](https://github.com/brighte-labs/spark-web/pull/36)
|
|
40
|
-
[`8546f8f`](https://github.com/brighte-labs/spark-web/commit/8546f8f05daaa79ea3ff954c6c4928a7a2d0622d)
|
|
41
|
-
Thanks [@lukebennett88](https://github.com/lukebennett88)! - Update Babel
|
|
42
|
-
config
|
|
43
|
-
|
|
44
|
-
- Updated dependencies
|
|
45
|
-
[[`aebff30`](https://github.com/brighte-labs/spark-web/commit/aebff30c86cb0a9db22b545c46159ce0d1c14afb),
|
|
46
|
-
[`8546f8f`](https://github.com/brighte-labs/spark-web/commit/8546f8f05daaa79ea3ff954c6c4928a7a2d0622d)]:
|
|
47
|
-
- @spark-web/theme@2.0.0
|
|
48
|
-
- @spark-web/box@1.0.1
|
|
49
|
-
- @spark-web/divider@1.0.1
|
|
50
|
-
- @spark-web/utils@1.0.1
|
|
51
|
-
|
|
52
|
-
## 1.0.0
|
|
53
|
-
|
|
54
|
-
### Major Changes
|
|
55
|
-
|
|
56
|
-
- [#27](https://github.com/brighte-labs/spark-web/pull/27)
|
|
57
|
-
[`4c8e398`](https://github.com/brighte-labs/spark-web/commit/4c8e3988f8a59d3dab60a6b67b1128b6ff2a5f2c)
|
|
58
|
-
Thanks [@JedWatson](https://github.com/JedWatson)! - Initial Version
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- Updated dependencies
|
|
63
|
-
[[`4c8e398`](https://github.com/brighte-labs/spark-web/commit/4c8e3988f8a59d3dab60a6b67b1128b6ff2a5f2c)]:
|
|
64
|
-
- @spark-web/box@1.0.0
|
|
65
|
-
- @spark-web/divider@1.0.0
|
|
66
|
-
- @spark-web/theme@1.0.0
|
|
67
|
-
- @spark-web/utils@1.0.0
|
package/src/Stack.stories.tsx
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Placeholder } from '../../../docs/components/example-helpers';
|
|
4
|
-
import type { StackProps } from './Stack';
|
|
5
|
-
import { Stack } from './Stack';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Page & Layout / Stack',
|
|
9
|
-
component: Stack,
|
|
10
|
-
} as ComponentMeta<typeof Stack>;
|
|
11
|
-
|
|
12
|
-
const StackStory: ComponentStory<typeof Stack> = (args: StackProps) => (
|
|
13
|
-
<Stack {...args} />
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
export const Default = StackStory.bind({});
|
|
17
|
-
|
|
18
|
-
Default.args = {
|
|
19
|
-
gap: 'large',
|
|
20
|
-
children: (
|
|
21
|
-
<>
|
|
22
|
-
<Placeholder height={40} />
|
|
23
|
-
<Placeholder height={40} />
|
|
24
|
-
<Placeholder height={40} />
|
|
25
|
-
</>
|
|
26
|
-
),
|
|
27
|
-
} as StackProps;
|
package/src/Stack.tsx
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { BoxProps } from '@spark-web/box';
|
|
2
|
-
import { Box } from '@spark-web/box';
|
|
3
|
-
import { Divider } from '@spark-web/divider';
|
|
4
|
-
import type { ResponsiveProp } from '@spark-web/theme';
|
|
5
|
-
import { forwardRefWithAs } from '@spark-web/utils/ts';
|
|
6
|
-
import type { ReactElement } from 'react';
|
|
7
|
-
import { Children, Fragment } from 'react';
|
|
8
|
-
|
|
9
|
-
import type { Align } from './alignment';
|
|
10
|
-
import { alignToAlignItems } from './alignment';
|
|
11
|
-
|
|
12
|
-
type ValidBoxProps = Omit<
|
|
13
|
-
BoxProps,
|
|
14
|
-
| 'display'
|
|
15
|
-
| 'className'
|
|
16
|
-
| 'alignItems'
|
|
17
|
-
| 'flexDirection'
|
|
18
|
-
| 'justifyContent'
|
|
19
|
-
| 'flexWrap'
|
|
20
|
-
>;
|
|
21
|
-
|
|
22
|
-
export type StackProps = {
|
|
23
|
-
/** Horizontally align items within the stack. */
|
|
24
|
-
align?: ResponsiveProp<Align>;
|
|
25
|
-
/** Place a divider between each element. */
|
|
26
|
-
dividers?: boolean;
|
|
27
|
-
} & ValidBoxProps;
|
|
28
|
-
|
|
29
|
-
export const Stack = forwardRefWithAs<'div', StackProps>(
|
|
30
|
-
({ align = 'stretch', children, dividers, ...props }, forwardedRef) => {
|
|
31
|
-
const alignItems = alignToAlignItems(align);
|
|
32
|
-
const rootProps = {
|
|
33
|
-
ref: forwardedRef,
|
|
34
|
-
alignItems,
|
|
35
|
-
display: 'flex',
|
|
36
|
-
flexDirection: 'column',
|
|
37
|
-
...props,
|
|
38
|
-
} as const;
|
|
39
|
-
|
|
40
|
-
// bail early w/o dividers to avoid unnecessary map
|
|
41
|
-
if (!dividers) {
|
|
42
|
-
return <Box {...rootProps}>{children}</Box>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// map over children to insert dividers
|
|
46
|
-
// remove falsy values before mapping, keeps the index in sync
|
|
47
|
-
const childArray = Children.toArray(children) as ReactElement[];
|
|
48
|
-
return (
|
|
49
|
-
<Box {...rootProps}>
|
|
50
|
-
{childArray.map((child, idx) => (
|
|
51
|
-
<Fragment key={child.key || idx}>
|
|
52
|
-
{dividers && idx ? <Divider /> : null}
|
|
53
|
-
{child}
|
|
54
|
-
</Fragment>
|
|
55
|
-
))}
|
|
56
|
-
</Box>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
);
|
package/src/alignment.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createResponsiveMapFn } from '@spark-web/theme';
|
|
2
|
-
|
|
3
|
-
const alignLookup = {
|
|
4
|
-
left: 'start',
|
|
5
|
-
center: 'center',
|
|
6
|
-
right: 'end',
|
|
7
|
-
stretch: 'stretch',
|
|
8
|
-
} as const;
|
|
9
|
-
|
|
10
|
-
export type Align = keyof typeof alignLookup;
|
|
11
|
-
|
|
12
|
-
export const alignToAlignItems = createResponsiveMapFn(alignLookup);
|