@zendeskgarden/react-loaders 9.0.0-next.2 → 9.0.0-next.20

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.
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React, { forwardRef, useContext, useRef, useEffect } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { ThemeContext } from 'styled-components';
10
+ import { useSchedule } from '@zendeskgarden/container-schedule';
11
+ import { useDocument } from '@zendeskgarden/react-theming';
12
+ import { StyledDotsCircleOne, StyledDotsCircleTwo, StyledDotsCircleThree } from '../styled/StyledDots.js';
13
+ import { StyledLoadingPlaceholder } from '../styled/StyledLoadingPlaceholder.js';
14
+ import '../styled/StyledProgress.js';
15
+ import '../styled/StyledSkeleton.js';
16
+ import '../styled/StyledSpinnerCircle.js';
17
+ import { StyledSVG } from '../styled/StyledSVG.js';
18
+ import '../styled/StyledInline.js';
19
+
20
+ const COMPONENT_ID = 'loaders.dots';
21
+ const Dots = forwardRef((_ref, ref) => {
22
+ let {
23
+ size,
24
+ color,
25
+ duration,
26
+ delayMS,
27
+ ...other
28
+ } = _ref;
29
+ const theme = useContext(ThemeContext);
30
+ const environment = useDocument(theme);
31
+ const canTransformSVG = useRef(null);
32
+ if (environment && canTransformSVG.current === null) {
33
+ const svg = environment.createElementNS('http://www.w3.org/2000/svg', 'svg');
34
+ canTransformSVG.current = 'transform' in svg;
35
+ }
36
+ const {
37
+ delayComplete
38
+ } = useSchedule({
39
+ duration,
40
+ delayMS,
41
+ loop: true
42
+ });
43
+ const dotOne = useRef(null);
44
+ const dotTwo = useRef(null);
45
+ const dotThree = useRef(null);
46
+ useEffect(() => {
47
+ if (!canTransformSVG.current && delayComplete) {
48
+ const transforms = [window.getComputedStyle(dotOne.current).getPropertyValue('transform'), window.getComputedStyle(dotTwo.current).getPropertyValue('transform'), window.getComputedStyle(dotThree.current).getPropertyValue('transform')];
49
+ dotOne.current.setAttribute('transform', transforms[0]);
50
+ dotTwo.current.setAttribute('transform', transforms[1]);
51
+ dotThree.current.setAttribute('transform', transforms[2]);
52
+ }
53
+ });
54
+ if (!delayComplete && delayMS !== 0) {
55
+ return React.createElement(StyledLoadingPlaceholder, {
56
+ fontSize: size
57
+ }, "\xA0");
58
+ }
59
+ return React.createElement(StyledSVG, Object.assign({
60
+ ref: ref,
61
+ fontSize: size,
62
+ color: color,
63
+ width: "80",
64
+ height: "72",
65
+ dataGardenId: COMPONENT_ID
66
+ }, other), React.createElement("g", {
67
+ fill: "currentColor"
68
+ }, React.createElement(StyledDotsCircleOne, {
69
+ duration: duration,
70
+ ref: dotOne
71
+ }), React.createElement(StyledDotsCircleTwo, {
72
+ duration: duration,
73
+ ref: dotTwo
74
+ }), React.createElement(StyledDotsCircleThree, {
75
+ duration: duration,
76
+ ref: dotThree
77
+ })));
78
+ });
79
+ Dots.displayName = 'Dots';
80
+ Dots.propTypes = {
81
+ size: PropTypes.any,
82
+ duration: PropTypes.number,
83
+ color: PropTypes.string,
84
+ delayMS: PropTypes.number
85
+ };
86
+ Dots.defaultProps = {
87
+ size: 'inherit',
88
+ color: 'inherit',
89
+ duration: 1250,
90
+ delayMS: 750
91
+ };
92
+
93
+ export { Dots };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { useText } from '@zendeskgarden/react-theming';
10
+ import '../styled/StyledDots.js';
11
+ import '../styled/StyledLoadingPlaceholder.js';
12
+ import '../styled/StyledProgress.js';
13
+ import '../styled/StyledSkeleton.js';
14
+ import '../styled/StyledSpinnerCircle.js';
15
+ import '../styled/StyledSVG.js';
16
+ import { StyledInline, StyledCircle } from '../styled/StyledInline.js';
17
+
18
+ const Inline = forwardRef((_ref, ref) => {
19
+ let {
20
+ size,
21
+ color,
22
+ ...other
23
+ } = _ref;
24
+ const ariaLabel = useText(Inline, other, 'aria-label', 'loading');
25
+ return (
26
+ React.createElement(StyledInline, Object.assign({
27
+ ref: ref,
28
+ size: size,
29
+ color: color,
30
+ "aria-label": ariaLabel,
31
+ role: "img"
32
+ }, other), React.createElement(StyledCircle, {
33
+ cx: "14"
34
+ }), React.createElement(StyledCircle, {
35
+ cx: "8"
36
+ }), React.createElement(StyledCircle, {
37
+ cx: "2"
38
+ }))
39
+ );
40
+ });
41
+ Inline.displayName = 'Inline';
42
+ Inline.propTypes = {
43
+ size: PropTypes.number,
44
+ color: PropTypes.string
45
+ };
46
+ Inline.defaultProps = {
47
+ size: 16,
48
+ color: 'inherit'
49
+ };
50
+
51
+ export { Inline };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { useText } from '@zendeskgarden/react-theming';
10
+ import { SIZE } from '../types/index.js';
11
+ import '../styled/StyledDots.js';
12
+ import '../styled/StyledLoadingPlaceholder.js';
13
+ import { StyledProgressBackground, StyledProgressIndicator } from '../styled/StyledProgress.js';
14
+ import '../styled/StyledSkeleton.js';
15
+ import '../styled/StyledSpinnerCircle.js';
16
+ import '../styled/StyledSVG.js';
17
+ import '../styled/StyledInline.js';
18
+
19
+ const COMPONENT_ID = 'loaders.progress';
20
+ const Progress = React.forwardRef((_ref, ref) => {
21
+ let {
22
+ value,
23
+ size,
24
+ 'aria-label': label,
25
+ ...other
26
+ } = _ref;
27
+ const percentage = Math.max(0, Math.min(100, value));
28
+ const ariaLabel = useText(Progress, {
29
+ 'aria-label': label
30
+ }, 'aria-label', 'Progress');
31
+ return (
32
+ React.createElement(StyledProgressBackground, Object.assign({
33
+ "data-garden-id": COMPONENT_ID,
34
+ "data-garden-version": '9.0.0-next.20',
35
+ "aria-valuemax": 100,
36
+ "aria-valuemin": 0,
37
+ "aria-valuenow": percentage,
38
+ role: "progressbar",
39
+ size: size,
40
+ ref: ref,
41
+ "aria-label": ariaLabel
42
+ }, other), React.createElement(StyledProgressIndicator, {
43
+ value: percentage,
44
+ size: size
45
+ }))
46
+ );
47
+ });
48
+ Progress.displayName = 'Progress';
49
+ Progress.propTypes = {
50
+ color: PropTypes.string,
51
+ value: PropTypes.number.isRequired,
52
+ size: PropTypes.oneOf(SIZE)
53
+ };
54
+ Progress.defaultProps = {
55
+ value: 0,
56
+ size: 'medium'
57
+ };
58
+
59
+ export { Progress };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import '../styled/StyledDots.js';
10
+ import '../styled/StyledLoadingPlaceholder.js';
11
+ import '../styled/StyledProgress.js';
12
+ import { StyledSkeleton } from '../styled/StyledSkeleton.js';
13
+ import '../styled/StyledSpinnerCircle.js';
14
+ import '../styled/StyledSVG.js';
15
+ import '../styled/StyledInline.js';
16
+
17
+ const Skeleton = forwardRef((_ref, ref) => {
18
+ let {
19
+ width,
20
+ height,
21
+ isLight,
22
+ ...other
23
+ } = _ref;
24
+ return React.createElement(StyledSkeleton, Object.assign({
25
+ ref: ref,
26
+ $isLight: isLight,
27
+ $width: width,
28
+ $height: height
29
+ }, other), "\xA0");
30
+ });
31
+ Skeleton.displayName = 'Skeleton';
32
+ Skeleton.propTypes = {
33
+ width: PropTypes.string,
34
+ height: PropTypes.string,
35
+ isLight: PropTypes.bool
36
+ };
37
+ Skeleton.defaultProps = {
38
+ width: '100%',
39
+ height: '100%'
40
+ };
41
+
42
+ export { Skeleton };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { useSchedule } from '@zendeskgarden/container-schedule';
10
+ import { STROKE_WIDTH_FRAMES, ROTATION_FRAMES, DASHARRAY_FRAMES } from '../utils/spinner-coordinates.js';
11
+ import '../styled/StyledDots.js';
12
+ import { StyledLoadingPlaceholder } from '../styled/StyledLoadingPlaceholder.js';
13
+ import '../styled/StyledProgress.js';
14
+ import '../styled/StyledSkeleton.js';
15
+ import { StyledSpinnerCircle } from '../styled/StyledSpinnerCircle.js';
16
+ import { StyledSVG } from '../styled/StyledSVG.js';
17
+ import '../styled/StyledInline.js';
18
+
19
+ const COMPONENT_ID = 'loaders.spinner';
20
+ const TOTAL_FRAMES = 100;
21
+ const computeFrames = (frames, duration) => {
22
+ return Object.entries(frames).reduce((acc, item, index, arr) => {
23
+ const [frame, value] = item;
24
+ const [nextFrame, nextValue] = arr[index + 1] || [TOTAL_FRAMES, arr[0][1]];
25
+ const diff = parseInt(nextFrame, 10) - parseInt(frame, 10);
26
+ const frameHz = 1000 / 60;
27
+ let subDuration = duration / (TOTAL_FRAMES - 1) * diff;
28
+ let lastValue = value;
29
+ acc[frame] = value;
30
+ for (let idx = 0; idx < diff; idx++) {
31
+ lastValue = lastValue + (nextValue - lastValue) * (frameHz / subDuration);
32
+ subDuration = duration / (TOTAL_FRAMES - 1) * (diff - idx);
33
+ acc[parseInt(frame, 10) + idx + 1] = lastValue;
34
+ }
35
+ acc[nextFrame] = nextValue;
36
+ return acc;
37
+ }, {});
38
+ };
39
+ const Spinner = forwardRef((_ref, ref) => {
40
+ let {
41
+ size,
42
+ duration,
43
+ color,
44
+ delayMS,
45
+ ...other
46
+ } = _ref;
47
+ const strokeWidthValues = computeFrames(STROKE_WIDTH_FRAMES, duration);
48
+ const rotationValues = computeFrames(ROTATION_FRAMES, duration);
49
+ const dasharrayValues = computeFrames(DASHARRAY_FRAMES, duration);
50
+ const {
51
+ elapsed,
52
+ delayComplete
53
+ } = useSchedule({
54
+ duration,
55
+ delayMS
56
+ });
57
+ const frame = (elapsed * 100).toFixed(0);
58
+ const strokeWidthValue = strokeWidthValues[frame];
59
+ const rotationValue = rotationValues[frame];
60
+ const dasharrayValue = dasharrayValues[frame];
61
+ const WIDTH = 80;
62
+ const HEIGHT = 80;
63
+ if (!delayComplete && delayMS !== 0) {
64
+ return React.createElement(StyledLoadingPlaceholder, {
65
+ width: "1em",
66
+ height: "1em",
67
+ fontSize: size
68
+ }, "\xA0");
69
+ }
70
+ return React.createElement(StyledSVG, Object.assign({
71
+ ref: ref,
72
+ fontSize: size,
73
+ color: color,
74
+ width: WIDTH,
75
+ height: HEIGHT,
76
+ dataGardenId: COMPONENT_ID,
77
+ containerHeight: "1em",
78
+ containerWidth: "1em"
79
+ }, other), React.createElement(StyledSpinnerCircle, {
80
+ dasharrayValue: dasharrayValue,
81
+ strokeWidthValue: strokeWidthValue,
82
+ transform: `rotate(${rotationValue}, ${WIDTH / 2}, ${HEIGHT / 2})`
83
+ }));
84
+ });
85
+ Spinner.displayName = 'Spinner';
86
+ Spinner.propTypes = {
87
+ size: PropTypes.any,
88
+ duration: PropTypes.number,
89
+ color: PropTypes.string,
90
+ delayMS: PropTypes.number
91
+ };
92
+ Spinner.defaultProps = {
93
+ size: 'inherit',
94
+ duration: 1250,
95
+ color: 'inherit',
96
+ delayMS: 750
97
+ };
98
+
99
+ export { Spinner };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ export { Dots } from './elements/Dots.js';
8
+ export { Progress } from './elements/Progress.js';
9
+ export { Skeleton } from './elements/Skeleton.js';
10
+ export { Spinner } from './elements/Spinner.js';
11
+ export { Inline } from './elements/Inline.js';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled, { css } from 'styled-components';
8
+ import { dotOneKeyframes, dotTwoKeyframes, dotThreeKeyframes } from '../utils/animations.js';
9
+ import { DEFAULT_THEME } from '@zendeskgarden/react-theming';
10
+
11
+ const StyledDotsCircle = styled.circle.attrs({
12
+ cy: 36,
13
+ r: 9
14
+ }).withConfig({
15
+ displayName: "StyledDots__StyledDotsCircle",
16
+ componentId: "sc-1ltah7e-0"
17
+ })([""]);
18
+ StyledDotsCircle.defaultProps = {
19
+ theme: DEFAULT_THEME
20
+ };
21
+ const animationStyles = (animationName, props) => {
22
+ return css(["animation:", " ", "ms linear infinite;"], animationName, props.duration);
23
+ };
24
+ const StyledDotsCircleOne = styled(StyledDotsCircle).attrs({
25
+ cx: 9
26
+ }).withConfig({
27
+ displayName: "StyledDots__StyledDotsCircleOne",
28
+ componentId: "sc-1ltah7e-1"
29
+ })(["", ";"], props => animationStyles(dotOneKeyframes, props));
30
+ StyledDotsCircleOne.defaultProps = {
31
+ theme: DEFAULT_THEME
32
+ };
33
+ const StyledDotsCircleTwo = styled(StyledDotsCircle).attrs(() => ({
34
+ cx: 40
35
+ })).withConfig({
36
+ displayName: "StyledDots__StyledDotsCircleTwo",
37
+ componentId: "sc-1ltah7e-2"
38
+ })(["", ";"], props => animationStyles(dotTwoKeyframes, props));
39
+ StyledDotsCircleTwo.defaultProps = {
40
+ theme: DEFAULT_THEME
41
+ };
42
+ const StyledDotsCircleThree = styled(StyledDotsCircle).attrs(() => ({
43
+ cx: 71
44
+ })).withConfig({
45
+ displayName: "StyledDots__StyledDotsCircleThree",
46
+ componentId: "sc-1ltah7e-3"
47
+ })(["", ";"], props => animationStyles(dotThreeKeyframes, props));
48
+ StyledDotsCircleThree.defaultProps = {
49
+ theme: DEFAULT_THEME
50
+ };
51
+
52
+ export { StyledDotsCircleOne, StyledDotsCircleThree, StyledDotsCircleTwo };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled, { keyframes } from 'styled-components';
8
+ import { DEFAULT_THEME, retrieveComponentStyles } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'loaders.inline';
11
+ const retrieveAnimation = _ref => {
12
+ let {
13
+ theme
14
+ } = _ref;
15
+ return keyframes(["0%,100%{opacity:", ";}50%{opacity:", ";}"], theme.opacity[200], theme.opacity[600]);
16
+ };
17
+ const StyledCircle = styled.circle.attrs({
18
+ fill: 'currentColor',
19
+ cy: 2,
20
+ r: 2
21
+ }).withConfig({
22
+ displayName: "StyledInline__StyledCircle",
23
+ componentId: "sc-fxsb9l-0"
24
+ })([""]);
25
+ StyledCircle.defaultProps = {
26
+ theme: DEFAULT_THEME
27
+ };
28
+ const StyledInline = styled.svg.attrs(props => ({
29
+ 'data-garden-id': COMPONENT_ID,
30
+ 'data-garden-version': '9.0.0-next.20',
31
+ viewBox: '0 0 16 4',
32
+ width: props.size,
33
+ height: props.size * 0.25
34
+ })).withConfig({
35
+ displayName: "StyledInline",
36
+ componentId: "sc-fxsb9l-1"
37
+ })(["color:", ";", "{opacity:0.2;&:nth-child(1){animation:", " 1s infinite;animation-delay:", ";}&:nth-child(2){animation:", " 1s infinite;animation-delay:0.2s;}&:nth-child(3){animation:", " 1s infinite;animation-delay:", ";}}", ""], props => props.color, StyledCircle, retrieveAnimation, props => props.theme.rtl ? 'unset' : '0.4s', retrieveAnimation, retrieveAnimation, props => props.theme.rtl ? '0.4s' : 'unset', props => retrieveComponentStyles(COMPONENT_ID, props));
38
+ StyledInline.defaultProps = {
39
+ theme: DEFAULT_THEME
40
+ };
41
+
42
+ export { StyledCircle, StyledInline };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'loaders.loading_placeholder';
11
+ const StyledLoadingPlaceholder = styled.div.attrs({
12
+ 'data-garden-id': COMPONENT_ID,
13
+ 'data-garden-version': '9.0.0-next.20',
14
+ role: 'progressbar'
15
+ }).withConfig({
16
+ displayName: "StyledLoadingPlaceholder",
17
+ componentId: "sc-x3bwsx-0"
18
+ })(["display:inline-block;width:", ";height:", ";font-size:", ";", ""], props => props.width || '1em', props => props.height || '0.9em', props => props.fontSize, props => retrieveComponentStyles(COMPONENT_ID, props));
19
+ StyledLoadingPlaceholder.defaultProps = {
20
+ theme: DEFAULT_THEME
21
+ };
22
+
23
+ export { StyledLoadingPlaceholder };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
9
+
10
+ const sizeToHeight = (size, theme) => {
11
+ switch (size) {
12
+ case 'small':
13
+ return theme.space.base / 2;
14
+ case 'medium':
15
+ return theme.space.base * 1.5;
16
+ default:
17
+ return theme.space.base * 3;
18
+ }
19
+ };
20
+ const sizeToBorderRadius = (size, theme) => sizeToHeight(size, theme) / 2;
21
+ const PROGRESS_BACKGROUND_COMPONENT_ID = 'loaders.progress_background';
22
+ const colorStyles = _ref => {
23
+ let {
24
+ theme,
25
+ color
26
+ } = _ref;
27
+ const backgroundColor = getColor({
28
+ theme,
29
+ hue: 'neutralHue',
30
+ transparency: theme.opacity[200],
31
+ light: {
32
+ shade: 700
33
+ },
34
+ dark: {
35
+ shade: 500
36
+ }
37
+ });
38
+ const foregroundColor = color || getColor({
39
+ theme,
40
+ variable: 'border.successEmphasis'
41
+ });
42
+ return css(["background-color:", ";color:", ";"], backgroundColor, foregroundColor);
43
+ };
44
+ const StyledProgressBackground = styled.div.attrs(props => ({
45
+ 'data-garden-id': PROGRESS_BACKGROUND_COMPONENT_ID,
46
+ 'data-garden-version': '9.0.0-next.20',
47
+ borderRadius: props.borderRadius || sizeToBorderRadius(props.size, props.theme)
48
+ })).withConfig({
49
+ displayName: "StyledProgress__StyledProgressBackground",
50
+ componentId: "sc-2g8w4s-0"
51
+ })(["margin:", "px 0;border-radius:", "px;", ";", ""], props => props.theme.space.base * 2, props => props.borderRadius, colorStyles, props => retrieveComponentStyles(PROGRESS_BACKGROUND_COMPONENT_ID, props));
52
+ StyledProgressBackground.defaultProps = {
53
+ theme: DEFAULT_THEME
54
+ };
55
+ const PROGESS_INDICATOR_COMPONENT_ID = 'loaders.progress_indicator';
56
+ const StyledProgressIndicator = styled.div.attrs(props => ({
57
+ 'data-garden-id': PROGESS_INDICATOR_COMPONENT_ID,
58
+ 'data-garden-version': '9.0.0-next.20',
59
+ height: props.height || sizeToHeight(props.size, props.theme),
60
+ borderRadius: props.borderRadius || sizeToBorderRadius(props.size, props.theme)
61
+ })).withConfig({
62
+ displayName: "StyledProgress__StyledProgressIndicator",
63
+ componentId: "sc-2g8w4s-1"
64
+ })(["transition:width 0.1s ease-in-out;border-radius:", "px;background:currentcolor;width:", "%;height:", "px;", ""], props => props.borderRadius, props => props.value, props => props.height, props => retrieveComponentStyles(PROGESS_INDICATOR_COMPONENT_ID, props));
65
+ StyledProgressIndicator.defaultProps = {
66
+ theme: DEFAULT_THEME
67
+ };
68
+
69
+ export { StyledProgressBackground, StyledProgressIndicator };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const StyledSVG = styled.svg.attrs(props => ({
11
+ 'data-garden-version': '9.0.0-next.20',
12
+ xmlns: 'http://www.w3.org/2000/svg',
13
+ width: props.width,
14
+ height: props.height,
15
+ focusable: 'false',
16
+ viewBox: `0 0 ${props.width} ${props.height}`,
17
+ role: 'img'
18
+ })).withConfig({
19
+ displayName: "StyledSVG",
20
+ componentId: "sc-1xtc3kx-0"
21
+ })(["width:", ";height:", ";color:", ";font-size:", ";", ";"], props => props.containerWidth || '1em', props => props.containerHeight || '0.9em', props => props.color || 'inherit', props => props.fontSize || 'inherit', props => retrieveComponentStyles(props.dataGardenId, props));
22
+ StyledSVG.defaultProps = {
23
+ theme: DEFAULT_THEME
24
+ };
25
+
26
+ export { StyledSVG };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled, { keyframes, css } from 'styled-components';
8
+ import { getLineHeight, retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'loaders.skeleton';
11
+ const fadeInAnimation = keyframes(["0%,60%{opacity:0;}100%{opacity:1;}"]);
12
+ const skeletonAnimation = keyframes(["0%{transform:translateX(-100%);}100%{transform:translateX(100%);}"]);
13
+ const skeletonRtlAnimation = keyframes(["0%{transform:translateX(100%);}100%{transform:translateX(-100%)}"]);
14
+ const getBackgroundColor = _ref => {
15
+ let {
16
+ theme,
17
+ $isLight
18
+ } = _ref;
19
+ let backgroundColor;
20
+ if ($isLight) {
21
+ backgroundColor = getColor({
22
+ theme,
23
+ hue: 'white',
24
+ transparency: theme.opacity[200]
25
+ });
26
+ } else {
27
+ backgroundColor = getColor({
28
+ theme,
29
+ hue: 'neutralHue',
30
+ transparency: theme.opacity[200],
31
+ light: {
32
+ shade: 700
33
+ },
34
+ dark: {
35
+ shade: 500
36
+ }
37
+ });
38
+ }
39
+ return backgroundColor;
40
+ };
41
+ const animationStyles = _ref2 => {
42
+ let {
43
+ theme
44
+ } = _ref2;
45
+ if (theme.rtl) {
46
+ return css(["animation:", " 1.5s ease-in-out 300ms infinite;"], skeletonRtlAnimation);
47
+ }
48
+ return css(["animation:", " 1.5s ease-in-out 300ms infinite;"], skeletonAnimation);
49
+ };
50
+ const gradientStyles = props => {
51
+ return css(["background-image:linear-gradient( ", ",transparent,", ",transparent );"], props.theme.rtl ? '-45deg' : '45deg', getBackgroundColor);
52
+ };
53
+ const StyledSkeleton = styled.div.attrs({
54
+ 'data-garden-id': COMPONENT_ID,
55
+ 'data-garden-version': '9.0.0-next.20'
56
+ }).withConfig({
57
+ displayName: "StyledSkeleton",
58
+ componentId: "sc-1raozze-0"
59
+ })(["display:inline-block;position:relative;animation:", " 750ms linear;border-radius:", ";background-color:", ";width:", ";height:", ";overflow:hidden;line-height:", ";&::before{position:absolute;top:0;width:1000px;height:100%;content:'';", " ", "}", ";"], fadeInAnimation, props => props.theme.borderRadii.md, getBackgroundColor, props => props.$width, props => props.$height, props => getLineHeight(props.theme.fontSizes.sm, props.theme.space.base * 5), animationStyles, gradientStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
60
+ StyledSkeleton.defaultProps = {
61
+ theme: DEFAULT_THEME
62
+ };
63
+
64
+ export { StyledSkeleton };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const StyledSpinnerCircle = styled.circle.attrs(props => ({
11
+ cx: 40,
12
+ cy: 40,
13
+ r: 34,
14
+ fill: 'none',
15
+ stroke: 'currentColor',
16
+ strokeLinecap: 'round',
17
+ strokeWidth: props.strokeWidthValue,
18
+ strokeDasharray: `${props.dasharrayValue} 250`,
19
+ transform: props.transform
20
+ })).withConfig({
21
+ displayName: "StyledSpinnerCircle",
22
+ componentId: "sc-o4kd70-0"
23
+ })([""]);
24
+ StyledSpinnerCircle.defaultProps = {
25
+ theme: DEFAULT_THEME
26
+ };
27
+
28
+ export { StyledSpinnerCircle };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ const SIZE = ['small', 'medium', 'large'];
8
+
9
+ export { SIZE };