@spark-web/spinner 1.0.0 → 1.0.1
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 +13 -0
- package/dist/declarations/src/Spinner.d.ts +4 -1
- package/dist/spark-web-spinner.cjs.dev.js +6 -8
- package/dist/spark-web-spinner.cjs.prod.js +6 -8
- package/dist/spark-web-spinner.esm.js +6 -8
- package/package.json +7 -4
- package/CHANGELOG.md +0 -18
- package/src/Spinner.stories.tsx +0 -43
- package/src/Spinner.tsx +0 -55
- package/src/index.ts +0 -5
package/README.md
CHANGED
|
@@ -55,3 +55,16 @@ Defaults to `xsmall`.
|
|
|
55
55
|
</Row>
|
|
56
56
|
</Inline>
|
|
57
57
|
```
|
|
58
|
+
|
|
59
|
+
## Props
|
|
60
|
+
|
|
61
|
+
### Spinner
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Default | Description |
|
|
64
|
+
| ----- | -------------------------------------- | --------- | ----------------------------------------------------------------- |
|
|
65
|
+
| size? | 'xxsmall' \| 'xsmall' | | The size of the nested radios. |
|
|
66
|
+
| tone? | 'critical' \| 'positive' \| 'neutral' | 'neutral' | Provide a tone to influence elements of the field, and its input. |
|
|
67
|
+
| data? | [DataAttributeMap][data-attribute-map] | | Sets data attributes on the component. |
|
|
68
|
+
|
|
69
|
+
[data-attribute-map]:
|
|
70
|
+
https://github.com/brighte-labs/spark-web/blob/e7f6f4285b4cfd876312cc89fbdd094039aa239a/packages/utils/src/internal/buildDataAttributes.ts#L1
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IconProps } from '@spark-web/icon';
|
|
3
|
+
import type { DataAttributeMap } from '@spark-web/utils/internal';
|
|
3
4
|
export declare type SpinnerProps = {
|
|
4
5
|
tone?: IconProps['tone'];
|
|
5
6
|
size?: 'xxsmall' | 'xsmall';
|
|
7
|
+
/** Allows setting of data attributes on the underlying element. */
|
|
8
|
+
data?: DataAttributeMap;
|
|
6
9
|
};
|
|
7
|
-
export declare function Spinner({ tone, size }: SpinnerProps): JSX.Element;
|
|
10
|
+
export declare function Spinner({ tone, size, data }: SpinnerProps): JSX.Element;
|
|
8
11
|
export declare namespace Spinner {
|
|
9
12
|
var displayName: string;
|
|
10
13
|
}
|
|
@@ -11,7 +11,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
11
11
|
function Spinner(_ref) {
|
|
12
12
|
var tone = _ref.tone,
|
|
13
13
|
_ref$size = _ref.size,
|
|
14
|
-
size = _ref$size === void 0 ? 'xxsmall' : _ref$size
|
|
14
|
+
size = _ref$size === void 0 ? 'xxsmall' : _ref$size,
|
|
15
|
+
data = _ref.data;
|
|
15
16
|
var spinAnimationRef = utils.useSynchronizedAnimation(spinAnimation);
|
|
16
17
|
var strokeAnimationRef = utils.useSynchronizedAnimation(strokeDashAnimation);
|
|
17
18
|
var styles = useSpinnerStyles();
|
|
@@ -24,6 +25,7 @@ function Spinner(_ref) {
|
|
|
24
25
|
display: "inline-flex",
|
|
25
26
|
alignItems: "center",
|
|
26
27
|
justifyContent: "center",
|
|
28
|
+
data: data,
|
|
27
29
|
children: /*#__PURE__*/jsxRuntime.jsx(SpinnerIcon, {
|
|
28
30
|
size: size,
|
|
29
31
|
tone: tone,
|
|
@@ -50,13 +52,9 @@ var strokeDashAnimation = css.keyframes({
|
|
|
50
52
|
strokeDasharray: '1px, 200px',
|
|
51
53
|
strokeDashoffset: 0
|
|
52
54
|
},
|
|
53
|
-
'50%': {
|
|
54
|
-
strokeDasharray: '100px, 200px',
|
|
55
|
-
strokeDashoffset: '-15px'
|
|
56
|
-
},
|
|
57
55
|
'100%': {
|
|
58
|
-
strokeDasharray: '
|
|
59
|
-
strokeDashoffset: '-
|
|
56
|
+
strokeDasharray: '200px, 200px',
|
|
57
|
+
strokeDashoffset: '-55px'
|
|
60
58
|
}
|
|
61
59
|
});
|
|
62
60
|
|
|
@@ -64,7 +62,7 @@ function useSpinnerStyles() {
|
|
|
64
62
|
return {
|
|
65
63
|
animation: "".concat(spinAnimation, " 1.4s linear infinite"),
|
|
66
64
|
'& circle': {
|
|
67
|
-
animation: "".concat(strokeDashAnimation, " 1.
|
|
65
|
+
animation: "".concat(strokeDashAnimation, " 1.6s cubic-bezier(0.47, 0, 0.75, 0.72) infinite")
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
}
|
|
@@ -11,7 +11,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
11
11
|
function Spinner(_ref) {
|
|
12
12
|
var tone = _ref.tone,
|
|
13
13
|
_ref$size = _ref.size,
|
|
14
|
-
size = _ref$size === void 0 ? 'xxsmall' : _ref$size
|
|
14
|
+
size = _ref$size === void 0 ? 'xxsmall' : _ref$size,
|
|
15
|
+
data = _ref.data;
|
|
15
16
|
var spinAnimationRef = utils.useSynchronizedAnimation(spinAnimation);
|
|
16
17
|
var strokeAnimationRef = utils.useSynchronizedAnimation(strokeDashAnimation);
|
|
17
18
|
var styles = useSpinnerStyles();
|
|
@@ -24,6 +25,7 @@ function Spinner(_ref) {
|
|
|
24
25
|
display: "inline-flex",
|
|
25
26
|
alignItems: "center",
|
|
26
27
|
justifyContent: "center",
|
|
28
|
+
data: data,
|
|
27
29
|
children: /*#__PURE__*/jsxRuntime.jsx(SpinnerIcon, {
|
|
28
30
|
size: size,
|
|
29
31
|
tone: tone,
|
|
@@ -50,13 +52,9 @@ var strokeDashAnimation = css.keyframes({
|
|
|
50
52
|
strokeDasharray: '1px, 200px',
|
|
51
53
|
strokeDashoffset: 0
|
|
52
54
|
},
|
|
53
|
-
'50%': {
|
|
54
|
-
strokeDasharray: '100px, 200px',
|
|
55
|
-
strokeDashoffset: '-15px'
|
|
56
|
-
},
|
|
57
55
|
'100%': {
|
|
58
|
-
strokeDasharray: '
|
|
59
|
-
strokeDashoffset: '-
|
|
56
|
+
strokeDasharray: '200px, 200px',
|
|
57
|
+
strokeDashoffset: '-55px'
|
|
60
58
|
}
|
|
61
59
|
});
|
|
62
60
|
|
|
@@ -64,7 +62,7 @@ function useSpinnerStyles() {
|
|
|
64
62
|
return {
|
|
65
63
|
animation: "".concat(spinAnimation, " 1.4s linear infinite"),
|
|
66
64
|
'& circle': {
|
|
67
|
-
animation: "".concat(strokeDashAnimation, " 1.
|
|
65
|
+
animation: "".concat(strokeDashAnimation, " 1.6s cubic-bezier(0.47, 0, 0.75, 0.72) infinite")
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
}
|
|
@@ -7,7 +7,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
7
7
|
function Spinner(_ref) {
|
|
8
8
|
var tone = _ref.tone,
|
|
9
9
|
_ref$size = _ref.size,
|
|
10
|
-
size = _ref$size === void 0 ? 'xxsmall' : _ref$size
|
|
10
|
+
size = _ref$size === void 0 ? 'xxsmall' : _ref$size,
|
|
11
|
+
data = _ref.data;
|
|
11
12
|
var spinAnimationRef = useSynchronizedAnimation(spinAnimation);
|
|
12
13
|
var strokeAnimationRef = useSynchronizedAnimation(strokeDashAnimation);
|
|
13
14
|
var styles = useSpinnerStyles();
|
|
@@ -20,6 +21,7 @@ function Spinner(_ref) {
|
|
|
20
21
|
display: "inline-flex",
|
|
21
22
|
alignItems: "center",
|
|
22
23
|
justifyContent: "center",
|
|
24
|
+
data: data,
|
|
23
25
|
children: /*#__PURE__*/jsx(SpinnerIcon, {
|
|
24
26
|
size: size,
|
|
25
27
|
tone: tone,
|
|
@@ -46,13 +48,9 @@ var strokeDashAnimation = keyframes({
|
|
|
46
48
|
strokeDasharray: '1px, 200px',
|
|
47
49
|
strokeDashoffset: 0
|
|
48
50
|
},
|
|
49
|
-
'50%': {
|
|
50
|
-
strokeDasharray: '100px, 200px',
|
|
51
|
-
strokeDashoffset: '-15px'
|
|
52
|
-
},
|
|
53
51
|
'100%': {
|
|
54
|
-
strokeDasharray: '
|
|
55
|
-
strokeDashoffset: '-
|
|
52
|
+
strokeDasharray: '200px, 200px',
|
|
53
|
+
strokeDashoffset: '-55px'
|
|
56
54
|
}
|
|
57
55
|
});
|
|
58
56
|
|
|
@@ -60,7 +58,7 @@ function useSpinnerStyles() {
|
|
|
60
58
|
return {
|
|
61
59
|
animation: "".concat(spinAnimation, " 1.4s linear infinite"),
|
|
62
60
|
'& circle': {
|
|
63
|
-
animation: "".concat(strokeDashAnimation, " 1.
|
|
61
|
+
animation: "".concat(strokeDashAnimation, " 1.6s cubic-bezier(0.47, 0, 0.75, 0.72) infinite")
|
|
64
62
|
}
|
|
65
63
|
};
|
|
66
64
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/spinner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/spark-web-spinner.cjs.js",
|
|
6
6
|
"module": "dist/spark-web-spinner.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/icon": "^1.1.
|
|
12
|
-
"@spark-web/utils": "^1.1.
|
|
13
|
+
"@spark-web/box": "^1.0.4",
|
|
14
|
+
"@spark-web/icon": "^1.1.2",
|
|
15
|
+
"@spark-web/utils": "^1.1.2"
|
|
13
16
|
},
|
|
14
17
|
"devDependencies": {
|
|
15
18
|
"@types/react": "^17.0.12",
|
package/CHANGELOG.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# @spark-web/spinner
|
|
2
|
-
|
|
3
|
-
## 1.0.0
|
|
4
|
-
|
|
5
|
-
### Major Changes
|
|
6
|
-
|
|
7
|
-
- [#44](https://github.com/brighte-labs/spark-web/pull/44)
|
|
8
|
-
[`11e7365`](https://github.com/brighte-labs/spark-web/commit/11e73659ff4a01a48a8761821bff34c6ec28568b)
|
|
9
|
-
Thanks [@matildaPan](https://github.com/matildaPan)! - initial release of
|
|
10
|
-
spinner component
|
|
11
|
-
|
|
12
|
-
### Patch Changes
|
|
13
|
-
|
|
14
|
-
- Updated dependencies
|
|
15
|
-
[[`11e7365`](https://github.com/brighte-labs/spark-web/commit/11e73659ff4a01a48a8761821bff34c6ec28568b),
|
|
16
|
-
[`11e7365`](https://github.com/brighte-labs/spark-web/commit/11e73659ff4a01a48a8761821bff34c6ec28568b)]:
|
|
17
|
-
- @spark-web/icon@1.1.0
|
|
18
|
-
- @spark-web/utils@1.1.0
|
package/src/Spinner.stories.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Inline } from '@spark-web/inline';
|
|
2
|
-
import { Stack } from '@spark-web/stack';
|
|
3
|
-
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
4
|
-
|
|
5
|
-
import type { SpinnerProps } from './Spinner';
|
|
6
|
-
import { Spinner } from './Spinner';
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: 'Feedback & Overlays / Spinner',
|
|
10
|
-
component: Spinner,
|
|
11
|
-
} as ComponentMeta<typeof Spinner>;
|
|
12
|
-
|
|
13
|
-
const SpinnerStory: ComponentStory<typeof Spinner> = (args: SpinnerProps) => (
|
|
14
|
-
<Stack align="left" gap="xxlarge">
|
|
15
|
-
<Inline gap="xxlarge">
|
|
16
|
-
<Spinner {...args} />
|
|
17
|
-
</Inline>
|
|
18
|
-
</Stack>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export const Default = SpinnerStory.bind({});
|
|
22
|
-
export const Critical = SpinnerStory.bind({});
|
|
23
|
-
export const Caution = SpinnerStory.bind({});
|
|
24
|
-
export const Positive = SpinnerStory.bind({});
|
|
25
|
-
export const Primary = SpinnerStory.bind({});
|
|
26
|
-
|
|
27
|
-
Default.args = {} as SpinnerProps;
|
|
28
|
-
|
|
29
|
-
Caution.args = {
|
|
30
|
-
tone: 'caution',
|
|
31
|
-
} as SpinnerProps;
|
|
32
|
-
|
|
33
|
-
Critical.args = {
|
|
34
|
-
tone: 'critical',
|
|
35
|
-
} as SpinnerProps;
|
|
36
|
-
|
|
37
|
-
Positive.args = {
|
|
38
|
-
tone: 'positive',
|
|
39
|
-
} as SpinnerProps;
|
|
40
|
-
|
|
41
|
-
Primary.args = {
|
|
42
|
-
tone: 'primary',
|
|
43
|
-
} as SpinnerProps;
|
package/src/Spinner.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { css, keyframes } from '@emotion/css';
|
|
2
|
-
import { Box } from '@spark-web/box';
|
|
3
|
-
import type { IconProps } from '@spark-web/icon';
|
|
4
|
-
import { createIcon } from '@spark-web/icon';
|
|
5
|
-
import { useSynchronizedAnimation } from '@spark-web/utils';
|
|
6
|
-
|
|
7
|
-
export type SpinnerProps = {
|
|
8
|
-
// TODO: match tones to design in Figma
|
|
9
|
-
tone?: IconProps['tone'];
|
|
10
|
-
size?: 'xxsmall' | 'xsmall';
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function Spinner({ tone, size = 'xxsmall' }: SpinnerProps) {
|
|
14
|
-
const spinAnimationRef = useSynchronizedAnimation(spinAnimation);
|
|
15
|
-
const strokeAnimationRef = useSynchronizedAnimation(strokeDashAnimation);
|
|
16
|
-
const styles = useSpinnerStyles();
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Box
|
|
20
|
-
as="span"
|
|
21
|
-
ref={spinAnimationRef}
|
|
22
|
-
className={css(styles)}
|
|
23
|
-
height={size}
|
|
24
|
-
width={size}
|
|
25
|
-
display="inline-flex"
|
|
26
|
-
alignItems="center"
|
|
27
|
-
justifyContent="center"
|
|
28
|
-
>
|
|
29
|
-
<SpinnerIcon size={size} tone={tone} ref={strokeAnimationRef} />
|
|
30
|
-
</Box>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
Spinner.displayName = 'Spinner';
|
|
34
|
-
|
|
35
|
-
const SpinnerIcon = createIcon(<circle cx={12} cy={12} r={9} />, 'SpinnerIcon');
|
|
36
|
-
|
|
37
|
-
const spinAnimation = keyframes({
|
|
38
|
-
from: { transform: 'rotate(0deg)' },
|
|
39
|
-
to: { transform: 'rotate(360deg)' },
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const strokeDashAnimation = keyframes({
|
|
43
|
-
'0%': { strokeDasharray: '1px, 200px', strokeDashoffset: 0 },
|
|
44
|
-
'50%': { strokeDasharray: '100px, 200px', strokeDashoffset: '-15px' },
|
|
45
|
-
'100%': { strokeDasharray: '100px, 200px', strokeDashoffset: '-125px' },
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
function useSpinnerStyles() {
|
|
49
|
-
return {
|
|
50
|
-
animation: `${spinAnimation} 1.4s linear infinite`,
|
|
51
|
-
'& circle': {
|
|
52
|
-
animation: `${strokeDashAnimation} 1.4s ease-in-out infinite`,
|
|
53
|
-
},
|
|
54
|
-
} as const;
|
|
55
|
-
}
|