-
-
Notifications
You must be signed in to change notification settings - Fork 766
/
Copy pathspinner.tsx
55 lines (46 loc) · 1.19 KB
/
spinner.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { FC, memo } from "react";
import styled from "styled-components";
import { FULL_ROTATION, THEME_COLORS, ThemeColors } from "@/style";
export interface SpinnerProps {
readonly colorSelector?: (colors: ThemeColors) => string;
}
export const Spinner: FC<SpinnerProps> = memo(({ colorSelector }) => {
const color = colorSelector?.(THEME_COLORS);
return (
<Wrapper>
<Quarter color={color} />
<Quarter color={color} />
<Quarter color={color} />
<Quarter color={color} />
</Wrapper>
);
});
const Quarter = styled.div<{
readonly color?: string;
}>`
position: absolute;
display: block;
box-sizing: border-box;
width: 40px;
height: 40px;
margin: 4px;
border-color: ${({ color }) => color || THEME_COLORS.spinner} transparent
transparent transparent;
border-radius: 100%;
border-style: solid;
border-width: 4px;
animation: ${FULL_ROTATION} 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
`;
const Wrapper = styled.div`
width: 48px;
height: 48px;
> ${Quarter}:nth-child(1) {
animation-delay: -0.45s;
}
> ${Quarter}:nth-child(2) {
animation-delay: -0.3s;
}
> ${Quarter}:nth-child(3) {
animation-delay: -0.15s;
}
`;