@artsy/palette 20.0.1 → 20.0.2
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/CHANGELOG.md +13 -0
- package/dist/elements/Spinner/Spinner.d.ts +2 -1
- package/dist/elements/Spinner/Spinner.js +22 -11
- package/dist/elements/Spinner/Spinner.js.map +1 -1
- package/dist/elements/Spinner/Spinner.story.d.ts +6 -5
- package/dist/elements/Spinner/Spinner.story.js +25 -8
- package/dist/elements/Spinner/Spinner.story.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# v20.0.2 (Fri May 20 2022)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- fix(spinner): supports box props; respects theme [#1166](https://github.com/artsy/palette/pull/1166) ([@dzucconi](https://github.com/dzucconi))
|
|
6
|
+
- fix(spinner): supports box props; respects theme ([@dzucconi](https://github.com/dzucconi))
|
|
7
|
+
|
|
8
|
+
#### Authors: 1
|
|
9
|
+
|
|
10
|
+
- Damon ([@dzucconi](https://github.com/dzucconi))
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
1
14
|
# v20.0.1 (Fri May 20 2022)
|
|
2
15
|
|
|
3
16
|
#### 🐛 Bug Fix
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { BoxProps } from "../../../dist";
|
|
2
3
|
import { Color } from "../../Theme";
|
|
3
|
-
export interface SpinnerProps {
|
|
4
|
+
export interface SpinnerProps extends Omit<BoxProps, "size"> {
|
|
4
5
|
/** Delay before spinner appears */
|
|
5
6
|
delay?: number;
|
|
6
7
|
/** Width of the spinner */
|
|
@@ -7,11 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.getSize = exports.Spinner = void 0;
|
|
9
9
|
|
|
10
|
+
var _themeGet = require("@styled-system/theme-get");
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _Box = require("../Box");
|
|
17
|
+
|
|
18
|
+
var _excluded = ["delay"];
|
|
15
19
|
|
|
16
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
21
|
|
|
@@ -29,6 +33,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
29
33
|
|
|
30
34
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
35
|
|
|
36
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
37
|
+
|
|
38
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
39
|
+
|
|
32
40
|
/**
|
|
33
41
|
* Returns width and height of spinner based on size
|
|
34
42
|
* @param props
|
|
@@ -70,8 +78,11 @@ exports.getSize = getSize;
|
|
|
70
78
|
var spin = (0, _styledComponents.keyframes)(["100%{transform:rotate(360deg)}"]);
|
|
71
79
|
/** Generic Spinner component */
|
|
72
80
|
|
|
73
|
-
var Spinner = function Spinner(
|
|
74
|
-
var
|
|
81
|
+
var Spinner = function Spinner(_ref) {
|
|
82
|
+
var delay = _ref.delay,
|
|
83
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
84
|
+
|
|
85
|
+
var _useState = (0, _react.useState)(delay === 0),
|
|
75
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
76
87
|
show = _useState2[0],
|
|
77
88
|
setShow = _useState2[1];
|
|
@@ -79,34 +90,34 @@ var Spinner = function Spinner(props) {
|
|
|
79
90
|
(0, _react.useEffect)(function () {
|
|
80
91
|
var timeout = setTimeout(function () {
|
|
81
92
|
setShow(true);
|
|
82
|
-
},
|
|
93
|
+
}, delay);
|
|
83
94
|
return function () {
|
|
84
95
|
clearTimeout(timeout);
|
|
85
96
|
};
|
|
86
|
-
}, []);
|
|
97
|
+
}, [delay]);
|
|
87
98
|
|
|
88
99
|
if (!show) {
|
|
89
100
|
return null;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
return /*#__PURE__*/_react.default.createElement(SpinnerBar,
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(SpinnerBar, rest);
|
|
93
104
|
};
|
|
94
105
|
|
|
95
106
|
exports.Spinner = Spinner;
|
|
96
107
|
Spinner.displayName = "Spinner";
|
|
97
|
-
|
|
98
|
-
var SpinnerBar = _styledComponents.default.div.withConfig({
|
|
108
|
+
var SpinnerBar = (0, _styledComponents.default)(_Box.Box).withConfig({
|
|
99
109
|
displayName: "Spinner__SpinnerBar",
|
|
100
110
|
componentId: "sc-1t000ax-0"
|
|
101
|
-
})(["animation:", " 1s infinite linear;
|
|
111
|
+
})(["animation:", " 1s infinite linear;", ";"], spin, function (props) {
|
|
102
112
|
var _getSize = getSize(props),
|
|
103
113
|
width = _getSize.width,
|
|
104
114
|
height = _getSize.height;
|
|
105
115
|
|
|
106
|
-
return "\n background-color: ".concat(props.color === "currentColor" ? "currentColor" : (0,
|
|
107
|
-
});
|
|
116
|
+
return "\n background-color: ".concat(props.color === "currentColor" ? "currentColor" : (0, _themeGet.themeGet)("colors.".concat(props.color))(props), ";\n\n width: ").concat(width, "px;\n height: ").concat(height, "px;\n top: calc(50% - ").concat(height, "px / 2);\n left: calc(50% - ").concat(width, "px / 2);\n ");
|
|
117
|
+
}); // TODO: Remove default `position`, `top`, & `left` props
|
|
108
118
|
|
|
109
119
|
Spinner.defaultProps = {
|
|
120
|
+
position: "absolute",
|
|
110
121
|
delay: 0,
|
|
111
122
|
width: 25,
|
|
112
123
|
height: 6,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/elements/Spinner/Spinner.tsx"],"names":["getSize","props","base","width","height","size","spin","keyframes","Spinner","delay","show","setShow","timeout","setTimeout","clearTimeout","SpinnerBar","
|
|
1
|
+
{"version":3,"sources":["../../../src/elements/Spinner/Spinner.tsx"],"names":["getSize","props","base","width","height","size","spin","keyframes","Spinner","delay","rest","show","setShow","timeout","setTimeout","clearTimeout","SpinnerBar","Box","color","defaultProps","position","displayName"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AACA;AACA;AACA;AACO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAyB;AAC9C,MAAMC,IAAI,GAAG;AAAEC,IAAAA,KAAK,EAAE,EAAT;AAAaC,IAAAA,MAAM,EAAE;AAArB,GAAb;;AAEA,UAAQH,KAAK,CAACI,IAAd;AACE,SAAK,OAAL;AACE,aAAO;AACLF,QAAAA,KAAK,EAAED,IAAI,CAACC,KAAL,GAAa,GADf;AAELC,QAAAA,MAAM,EAAEF,IAAI,CAACE,MAAL,GAAc;AAFjB,OAAP;;AAKF,SAAK,QAAL;AACE,aAAO;AACLD,QAAAA,KAAK,EAAED,IAAI,CAACC,KAAL,GAAa,GADf;AAELC,QAAAA,MAAM,EAAEF,IAAI,CAACE,MAAL,GAAc;AAFjB,OA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ASoBA,MATpB,8CAUqBD,KAVrB;AAYD,CAlBa,CAAhB,C,CAoBA;;AACAK,OAAO,CAACW,YAAR,GAAuB;AACrBC,EAAAA,QAAQ,EAAE,UADW;AAErBX,EAAAA,KAAK,EAAE,CAFc;AAGrBN,EAAAA,KAAK,EAAE,EAHc;AAIrBC,EAAAA,MAAM,EAAE,CAJa;AAKrBc,EAAAA,KAAK,EAAE;AALc,CAAvB;AAQAV,OAAO,CAACa,WAAR,GAAsB,SAAtB","sourcesContent":["import { themeGet } from \"@styled-system/theme-get\"\nimport React, { useEffect, useState } from \"react\"\nimport styled, { keyframes } from \"styled-components\"\nimport { BoxProps } from \"../../../dist\"\nimport { Color } from \"../../Theme\"\nimport { Box } from \"../Box\"\n\nexport interface SpinnerProps extends Omit<BoxProps, \"size\"> {\n /** Delay before spinner appears */\n delay?: number\n /** Width of the spinner */\n width?: number\n /** Height of the spinner */\n height?: number\n /** Size of the spinner */\n size?: \"small\" | \"medium\" | \"large\"\n /** Color of the spinner */\n color?: Color | \"currentColor\"\n}\n\n/**\n * Returns width and height of spinner based on size\n * @param props\n */\nexport const getSize = (props: SpinnerProps) => {\n const base = { width: 25, height: 6 }\n\n switch (props.size) {\n case \"small\":\n return {\n width: base.width * 0.5,\n height: base.height * 0.5,\n }\n\n case \"medium\":\n return {\n width: base.width * 0.8,\n height: base.height * 0.8,\n }\n\n case \"large\":\n return {\n width: base.width,\n height: base.height,\n }\n\n default:\n return {\n width: props.width,\n height: props.height,\n }\n }\n}\n\nconst spin = keyframes`\n 100% {\n transform: rotate(360deg)\n }\n`\n\n/** Generic Spinner component */\nexport const Spinner: React.FC<SpinnerProps> = ({ delay, ...rest }) => {\n const [show, setShow] = useState(delay === 0)\n\n useEffect(() => {\n const timeout = setTimeout(() => {\n setShow(true)\n }, delay)\n\n return () => {\n clearTimeout(timeout)\n }\n }, [delay])\n\n if (!show) {\n return null\n }\n\n return <SpinnerBar {...rest} />\n}\n\nconst SpinnerBar = styled(Box)<SpinnerProps>`\n animation: ${spin} 1s infinite linear;\n\n ${(props) => {\n const { width, height } = getSize(props)\n\n return `\n background-color: ${\n props.color === \"currentColor\"\n ? \"currentColor\"\n : themeGet(`colors.${props.color}`)(props)\n };\n\n width: ${width}px;\n height: ${height}px;\n top: calc(50% - ${height}px / 2);\n left: calc(50% - ${width}px / 2);\n `\n }};\n`\n// TODO: Remove default `position`, `top`, & `left` props\nSpinner.defaultProps = {\n position: \"absolute\",\n delay: 0,\n width: 25,\n height: 6,\n color: \"black100\",\n}\n\nSpinner.displayName = \"Spinner\"\n"],"file":"Spinner.js"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
title: string;
|
|
3
|
+
parameters: {
|
|
4
|
+
chromatic: {
|
|
5
|
+
disable: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
3
8
|
};
|
|
4
9
|
export default _default;
|
|
10
|
+
export declare const Default: () => JSX.Element;
|
|
5
11
|
export declare const DefaultSpinner: () => JSX.Element;
|
|
6
12
|
export declare const SpinnerWithDelayedShow: {
|
|
7
13
|
(): JSX.Element;
|
|
8
14
|
story: {
|
|
9
15
|
name: string;
|
|
10
|
-
parameters: {
|
|
11
|
-
chromatic: {
|
|
12
|
-
disable: boolean;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
16
|
};
|
|
16
17
|
};
|
|
@@ -3,19 +3,41 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.SpinnerWithDelayedShow = exports.DefaultSpinner = void 0;
|
|
6
|
+
exports.default = exports.SpinnerWithDelayedShow = exports.DefaultSpinner = exports.Default = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _storybookStates = require("storybook-states");
|
|
11
|
+
|
|
10
12
|
var _Spinner = require("./Spinner");
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
var _default = {
|
|
15
|
-
title: "Components/Spinner"
|
|
17
|
+
title: "Components/Spinner",
|
|
18
|
+
parameters: {
|
|
19
|
+
chromatic: {
|
|
20
|
+
disable: true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
16
23
|
};
|
|
17
24
|
exports.default = _default;
|
|
18
25
|
|
|
26
|
+
var Default = function Default() {
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_storybookStates.States, {
|
|
28
|
+
states: [{}, {
|
|
29
|
+
color: "brand",
|
|
30
|
+
size: "small",
|
|
31
|
+
m: 2
|
|
32
|
+
}]
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement(_Spinner.Spinner, {
|
|
34
|
+
position: "static"
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.Default = Default;
|
|
39
|
+
Default.displayName = "Default";
|
|
40
|
+
|
|
19
41
|
var DefaultSpinner = function DefaultSpinner() {
|
|
20
42
|
return /*#__PURE__*/_react.default.createElement(_Spinner.Spinner, null);
|
|
21
43
|
};
|
|
@@ -32,11 +54,6 @@ var SpinnerWithDelayedShow = function SpinnerWithDelayedShow() {
|
|
|
32
54
|
exports.SpinnerWithDelayedShow = SpinnerWithDelayedShow;
|
|
33
55
|
SpinnerWithDelayedShow.displayName = "SpinnerWithDelayedShow";
|
|
34
56
|
SpinnerWithDelayedShow.story = {
|
|
35
|
-
name: "Spinner with delayed show"
|
|
36
|
-
parameters: {
|
|
37
|
-
chromatic: {
|
|
38
|
-
disable: true
|
|
39
|
-
}
|
|
40
|
-
}
|
|
57
|
+
name: "Spinner with delayed show"
|
|
41
58
|
};
|
|
42
59
|
//# sourceMappingURL=Spinner.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/elements/Spinner/Spinner.story.tsx"],"names":["title","
|
|
1
|
+
{"version":3,"sources":["../../../src/elements/Spinner/Spinner.story.tsx"],"names":["title","parameters","chromatic","disable","Default","color","size","m","DefaultSpinner","SpinnerWithDelayedShow","story","name"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;eAEe;AACbA,EAAAA,KAAK,EAAE,oBADM;AAEbC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,SAAS,EAAE;AAAEC,MAAAA,OAAO,EAAE;AAAX;AAAb;AAFC,C;;;AAKR,IAAMC,OAAO,GAAG,SAAVA,OAAU;AAAA,sBACrB,6BAAC,uBAAD;AAAsB,IAAA,MAAM,EAAE,CAAC,EAAD,EAAK;AAAEC,MAAAA,KAAK,EAAE,OAAT;AAAkBC,MAAAA,IAAI,EAAE,OAAxB;AAAiCC,MAAAA,CAAC,EAAE;AAApC,KAAL;AAA9B,kBACE,6BAAC,gBAAD;AAAS,IAAA,QAAQ,EAAC;AAAlB,IADF,CADqB;AAAA,CAAhB;;;AAAMH,O;;AAMN,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,GAAM;AAClC,sBAAO,6BAAC,gBAAD,OAAP;AACD,CAFM;;;AAAMA,c;;AAIN,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAyB,GAAM;AAC1C,sBAAO,6BAAC,gBAAD;AAAS,IAAA,KAAK,EAAE;AAAhB,IAAP;AACD,CAFM;;;AAAMA,sB;AAIbA,sBAAsB,CAACC,KAAvB,GAA+B;AAC7BC,EAAAA,IAAI,EAAE;AADuB,CAA/B","sourcesContent":["import React from \"react\"\nimport { States } from \"storybook-states\"\nimport { Spinner, SpinnerProps } from \"./Spinner\"\n\nexport default {\n title: \"Components/Spinner\",\n parameters: { chromatic: { disable: true } },\n}\n\nexport const Default = () => (\n <States<SpinnerProps> states={[{}, { color: \"brand\", size: \"small\", m: 2 }]}>\n <Spinner position=\"static\" />\n </States>\n)\n\nexport const DefaultSpinner = () => {\n return <Spinner />\n}\n\nexport const SpinnerWithDelayedShow = () => {\n return <Spinner delay={1000} />\n}\n\nSpinnerWithDelayedShow.story = {\n name: \"Spinner with delayed show\",\n}\n"],"file":"Spinner.story.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.2",
|
|
4
4
|
"description": "Design system library for react components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -178,5 +178,5 @@
|
|
|
178
178
|
"<rootDir>/www/"
|
|
179
179
|
]
|
|
180
180
|
},
|
|
181
|
-
"gitHead": "
|
|
181
|
+
"gitHead": "57539365f7b1731b294303ac9a0643d1b2612f42"
|
|
182
182
|
}
|