@zendeskgarden/react-loaders 9.0.0-next.7 → 9.0.0-next.9
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/elements/Dots.js +93 -0
- package/dist/esm/elements/Inline.js +51 -0
- package/dist/esm/elements/Progress.js +59 -0
- package/dist/esm/elements/Skeleton.js +42 -0
- package/dist/esm/elements/Spinner.js +99 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/styled/StyledDots.js +52 -0
- package/dist/esm/styled/StyledInline.js +37 -0
- package/dist/esm/styled/StyledLoadingPlaceholder.js +23 -0
- package/dist/esm/styled/StyledProgress.js +47 -0
- package/dist/esm/styled/StyledSVG.js +26 -0
- package/dist/esm/styled/StyledSkeleton.js +52 -0
- package/dist/esm/styled/StyledSpinnerCircle.js +28 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/utils/animations.js +13 -0
- package/dist/esm/utils/spinner-coordinates.js +71 -0
- package/dist/index.cjs.js +17 -33
- package/package.json +5 -5
- package/dist/index.esm.js +0 -544
|
@@ -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.9',
|
|
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
|
+
customWidth: width,
|
|
28
|
+
customHeight: 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,37 @@
|
|
|
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 PULSE_ANIMATION = keyframes(["0%,100%{opacity:.2;}50%{opacity:.8;}"]);
|
|
12
|
+
const StyledCircle = styled.circle.attrs({
|
|
13
|
+
fill: 'currentColor',
|
|
14
|
+
cy: 2,
|
|
15
|
+
r: 2
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledInline__StyledCircle",
|
|
18
|
+
componentId: "sc-fxsb9l-0"
|
|
19
|
+
})([""]);
|
|
20
|
+
StyledCircle.defaultProps = {
|
|
21
|
+
theme: DEFAULT_THEME
|
|
22
|
+
};
|
|
23
|
+
const StyledInline = styled.svg.attrs(props => ({
|
|
24
|
+
'data-garden-id': COMPONENT_ID,
|
|
25
|
+
'data-garden-version': '9.0.0-next.9',
|
|
26
|
+
viewBox: '0 0 16 4',
|
|
27
|
+
width: props.size,
|
|
28
|
+
height: props.size * 0.25
|
|
29
|
+
})).withConfig({
|
|
30
|
+
displayName: "StyledInline",
|
|
31
|
+
componentId: "sc-fxsb9l-1"
|
|
32
|
+
})(["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, PULSE_ANIMATION, props => props.theme.rtl ? 'unset' : '0.4s', PULSE_ANIMATION, PULSE_ANIMATION, props => props.theme.rtl ? '0.4s' : 'unset', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
33
|
+
StyledInline.defaultProps = {
|
|
34
|
+
theme: DEFAULT_THEME
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
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.9',
|
|
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,47 @@
|
|
|
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 { getColorV8, retrieveComponentStyles, DEFAULT_THEME } 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 StyledProgressBackground = styled.div.attrs(props => ({
|
|
23
|
+
'data-garden-id': PROGRESS_BACKGROUND_COMPONENT_ID,
|
|
24
|
+
'data-garden-version': '9.0.0-next.9',
|
|
25
|
+
borderRadius: props.borderRadius || sizeToBorderRadius(props.size, props.theme)
|
|
26
|
+
})).withConfig({
|
|
27
|
+
displayName: "StyledProgress__StyledProgressBackground",
|
|
28
|
+
componentId: "sc-2g8w4s-0"
|
|
29
|
+
})(["margin:", "px 0;border-radius:", "px;background-color:", ";color:", ";", ""], props => props.theme.space.base * 2, props => props.borderRadius, props => getColorV8('neutralHue', 200, props.theme), props => props.color || getColorV8('successHue', 600, props.theme), props => retrieveComponentStyles(PROGRESS_BACKGROUND_COMPONENT_ID, props));
|
|
30
|
+
StyledProgressBackground.defaultProps = {
|
|
31
|
+
theme: DEFAULT_THEME
|
|
32
|
+
};
|
|
33
|
+
const PROGESS_INDICATOR_COMPONENT_ID = 'loaders.progress_indicator';
|
|
34
|
+
const StyledProgressIndicator = styled.div.attrs(props => ({
|
|
35
|
+
'data-garden-id': PROGESS_INDICATOR_COMPONENT_ID,
|
|
36
|
+
'data-garden-version': '9.0.0-next.9',
|
|
37
|
+
height: props.height || sizeToHeight(props.size, props.theme),
|
|
38
|
+
borderRadius: props.borderRadius || sizeToBorderRadius(props.size, props.theme)
|
|
39
|
+
})).withConfig({
|
|
40
|
+
displayName: "StyledProgress__StyledProgressIndicator",
|
|
41
|
+
componentId: "sc-2g8w4s-1"
|
|
42
|
+
})(["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));
|
|
43
|
+
StyledProgressIndicator.defaultProps = {
|
|
44
|
+
theme: DEFAULT_THEME
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
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.9',
|
|
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,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, { keyframes, css } from 'styled-components';
|
|
8
|
+
import { rgba } from 'polished';
|
|
9
|
+
import { getLineHeight, retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'loaders.skeleton';
|
|
12
|
+
const fadeInAnimation = keyframes(["0%,60%{opacity:0;}100%{opacity:1;}"]);
|
|
13
|
+
const skeletonAnimation = keyframes(["0%{transform:translateX(-100%);}100%{transform:translateX(100%);}"]);
|
|
14
|
+
const skeletonRtlAnimation = keyframes(["0%{transform:translateX(100%);}100%{transform:translateX(-100%)}"]);
|
|
15
|
+
const retrieveSkeletonBackgroundColor = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
theme,
|
|
18
|
+
isLight
|
|
19
|
+
} = _ref;
|
|
20
|
+
if (isLight) {
|
|
21
|
+
return css(["background-color:", ";"], rgba(getColorV8('background', 600 , theme), 0.2));
|
|
22
|
+
}
|
|
23
|
+
return css(["background-color:", ";"], getColorV8('neutralHue', 800, theme, 0.1));
|
|
24
|
+
};
|
|
25
|
+
const retrieveSkeletonAnimation = _ref2 => {
|
|
26
|
+
let {
|
|
27
|
+
theme
|
|
28
|
+
} = _ref2;
|
|
29
|
+
if (theme.rtl) {
|
|
30
|
+
return css(["animation:", " 1.5s ease-in-out 300ms infinite;"], skeletonRtlAnimation);
|
|
31
|
+
}
|
|
32
|
+
return css(["animation:", " 1.5s ease-in-out 300ms infinite;"], skeletonAnimation);
|
|
33
|
+
};
|
|
34
|
+
const retrieveSkeletonGradient = _ref3 => {
|
|
35
|
+
let {
|
|
36
|
+
theme,
|
|
37
|
+
isLight
|
|
38
|
+
} = _ref3;
|
|
39
|
+
return css(["background-image:linear-gradient( ", ",transparent,", ",transparent );"], theme.rtl ? '-45deg' : '45deg', isLight ? getColorV8('chromeHue', 700, theme, 0.4) : rgba(getColorV8('background', 600 , theme), 0.6));
|
|
40
|
+
};
|
|
41
|
+
const StyledSkeleton = styled.div.attrs({
|
|
42
|
+
'data-garden-id': COMPONENT_ID,
|
|
43
|
+
'data-garden-version': '9.0.0-next.9'
|
|
44
|
+
}).withConfig({
|
|
45
|
+
displayName: "StyledSkeleton",
|
|
46
|
+
componentId: "sc-1raozze-0"
|
|
47
|
+
})(["display:inline-block;position:relative;animation:", " 750ms linear;border-radius:", ";width:", ";height:", ";overflow:hidden;line-height:", ";", " &::before{position:absolute;top:0;width:1000px;height:100%;content:'';", " ", "}", ";"], fadeInAnimation, props => props.theme.borderRadii.md, props => props.customWidth, props => props.customHeight, props => getLineHeight(props.theme.fontSizes.sm, props.theme.space.base * 5), retrieveSkeletonBackgroundColor, retrieveSkeletonAnimation, retrieveSkeletonGradient, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
48
|
+
StyledSkeleton.defaultProps = {
|
|
49
|
+
theme: DEFAULT_THEME
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
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,13 @@
|
|
|
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 { keyframes } from 'styled-components';
|
|
8
|
+
|
|
9
|
+
const dotOneKeyframes = keyframes(["0%{transform:translate(0,5px);}3%{transform:translate(1px,-5px);}6%{transform:translate(3px,-15px);}8%{transform:translate(5px,-18px);}9%{transform:translate(7px,-21px);}11%{transform:translate(8px,-22px);}13%{transform:translate(9px,-23px);}16%{transform:translate(12px,-25px);}18%{transform:translate(13px,-26px);}23%{transform:translate(18px,-26px);}24%{transform:translate(19px,-25px);}28%{transform:translate(22px,-23px);}31%{transform:translate(24px,-21px);}33%{transform:translate(26px,-18px);}34%{transform:translate(28px,-14px);}36%{transform:translate(29px,-12px);}38%{transform:translate(30px,-5px);}39%{transform:translate(31px,5px);}54%{transform:translate(31px,3px);}59%{transform:translate(33px);}61%{transform:translate(43px);}63%{transform:translate(48px);}64%{transform:translate(51px);}66%{transform:translate(53px);}68%{transform:translate(55px);}69%{transform:translate(57px);}76%{transform:translate(60px);}81%{transform:translate(61px);}83%,100%{transform:translate(62px);}"]);
|
|
10
|
+
const dotTwoKeyframes = keyframes(["4%{transform:translate(0);}6%{transform:translate(-1px);}8%{transform:translate(-2px);}9%{transform:translate(-5px);}11%{transform:translate(-7px);}13%{transform:translate(-12px);}14%{transform:translate(-17px);}16%{transform:translate(-19px);}18%{transform:translate(-22px);}19%{transform:translate(-25px);}21%{transform:translate(-26px);}23%{transform:translate(-27px);}24%{transform:translate(-28px);}26%{transform:translate(-29px);}29%{transform:translate(-30px);}33%,89%{transform:translate(-31px);}91%{transform:translate(-31px,1px);}94%{transform:translate(-31px,2px);}98%{transform:translate(-31px,3px);}99%{transform:translate(-31px,4px);}100%{transform:translate(-31px,5px);}"]);
|
|
11
|
+
const dotThreeKeyframes = keyframes(["39%{transform:translate(0);}44%{transform:translate(0,1px);}46%{transform:translate(0,2px);}48%{transform:translate(0,3px);}49%{transform:translate(0,4px);}51%{transform:translate(0,5px);}53%{transform:translate(-1px,-6px);}54%{transform:translate(-2px,-13px);}56%{transform:translate(-3px,-15px);}58%{transform:translate(-5px,-19px);}59%{transform:translate(-7px,-21px);}61%{transform:translate(-8px,-22px);}63%{transform:translate(-9px,-24px);}64%{transform:translate(-11px,-25px);}66%{transform:translate(-12px,-26px);}74%{transform:translate(-19px,-26px);}76%{transform:translate(-20px,-25px);}78%{transform:translate(-22px,-24px);}81%{transform:translate(-24px,-21px);}83%{transform:translate(-26px,-19px);}84%{transform:translate(-28px,-15px);}86%{transform:translate(-29px,-13px);}88%{transform:translate(-30px,-6px);}89%{transform:translate(-31px,5px);}91%{transform:translate(-31px,4px);}93%{transform:translate(-31px,3px);}94%{transform:translate(-31px,2px);}98%{transform:translate(-31px,1px);}100%{transform:translate(-31px);}"]);
|
|
12
|
+
|
|
13
|
+
export { dotOneKeyframes, dotThreeKeyframes, dotTwoKeyframes };
|