Skip to content

Commit 897d9d6

Browse files
♻️ updated spinner styles
1 parent c5c0dd7 commit 897d9d6

File tree

2 files changed

+43
-29
lines changed

2 files changed

+43
-29
lines changed

src/multi-select/dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const Dropdown = ({
131131
>
132132
<DropdownHeading className="dropdown-heading" onClick={toggleExpanded}>
133133
<div className="dropdown-heading-value">{children}</div>
134-
<Loading isLoading={isLoading} />
134+
{isLoading && <Loading />}
135135
<Arrow expanded={expanded} />
136136
</DropdownHeading>
137137
{expanded && (

src/multi-select/loading.tsx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,59 @@
11
import React from "react";
2+
import styled from "@emotion/styled";
23

3-
function Loading({ size = 26, color = "#666", isLoading }) {
4-
return isLoading ? (
4+
const Spinner = styled.svg`
5+
animation: rotate 2s linear infinite;
6+
7+
& .path {
8+
stroke: ${(props: any) => props.theme.border};
9+
stroke-width: 4px;
10+
stroke-linecap: round;
11+
animation: dash 1.5s ease-in-out infinite;
12+
}
13+
14+
@keyframes rotate {
15+
100% {
16+
transform: rotate(360deg);
17+
}
18+
}
19+
20+
@keyframes dash {
21+
0% {
22+
stroke-dasharray: 1, 150;
23+
stroke-dashoffset: 0;
24+
}
25+
50% {
26+
stroke-dasharray: 90, 150;
27+
stroke-dashoffset: -35;
28+
}
29+
100% {
30+
stroke-dasharray: 90, 150;
31+
stroke-dashoffset: -124;
32+
}
33+
}
34+
`;
35+
36+
function Loading({ size = 26 }) {
37+
return (
538
<div
639
style={{
740
cursor: "pointer",
841
display: "table-cell",
942
verticalAlign: "middle",
10-
width: size
43+
width: size,
44+
marginRight: "0.2rem"
1145
}}
1246
>
13-
<svg
14-
xmlns="http://www.w3.org/2000/svg"
47+
<Spinner
1548
width={size}
1649
height={size}
17-
stroke={color}
18-
viewBox="0 0 46 46"
50+
className="spinner"
51+
viewBox="0 0 50 50"
1952
style={{ display: "inline-block", verticalAlign: "middle" }}
2053
>
21-
<g
22-
fill="none"
23-
fillRule="evenodd"
24-
strokeWidth="5"
25-
transform="translate(4 4)"
26-
>
27-
<circle cx="18" cy="18" r="18" strokeOpacity="0.4"></circle>
28-
<path d="M36 18c0-9.94-8.06-18-18-18">
29-
<animateTransform
30-
attributeName="transform"
31-
dur="1s"
32-
from="0 18 18"
33-
repeatCount="indefinite"
34-
to="360 18 18"
35-
type="rotate"
36-
></animateTransform>
37-
</path>
38-
</g>
39-
</svg>
54+
<circle cx="25" cy="25" r="20" fill="none" className="path"></circle>
55+
</Spinner>
4056
</div>
41-
) : (
42-
<></>
4357
);
4458
}
4559

0 commit comments

Comments
 (0)