Skip to content

Commit ffa1a18

Browse files
authored
DOP-5979: Migrate Spinner (#14756)
* Add Spinner component * use Spinner in layout * use client * Remove usage of Spinnar
1 parent 04e5df4 commit ffa1a18

File tree

1 file changed

+52
-0
lines changed
  • platform/docs-nextjs/src/components/spinner

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use client';
2+
3+
import { keyframes } from '@emotion/react';
4+
import styled from '@emotion/styled';
5+
import { palette } from '@leafygreen-ui/palette';
6+
7+
const rotate = keyframes`
8+
0% {
9+
transform: rotate(0);
10+
}
11+
12+
100% {
13+
transform: rotate(360deg);
14+
}
15+
`;
16+
17+
export type SpinnerProps = {
18+
className?: string;
19+
size: number;
20+
};
21+
22+
// Modified version of Redoc's Spinner used for their loading screen; sets the svg's width and height
23+
// so that it doesn't flash a large size on render
24+
// Source: https://github.com/Redocly/redoc/blob/master/src/components/Loading/Spinner.svg.tsx
25+
const SpinnerIcon = ({ className, size }: SpinnerProps) => {
26+
return (
27+
<svg className={className} width={size} height={size} viewBox="0 0 512 512">
28+
<path d="M275.682 147.999c0 10.864-8.837 19.661-19.682 19.661v0c-10.875 0-19.681-8.796-19.681-19.661v-96.635c0-10.885 8.806-19.661 19.681-19.661v0c10.844 0 19.682 8.776 19.682 19.661v96.635z" />
29+
<path d="M275.682 460.615c0 10.865-8.837 19.682-19.682 19.682v0c-10.875 0-19.681-8.817-19.681-19.682v-96.604c0-10.885 8.806-19.681 19.681-19.681v0c10.844 0 19.682 8.796 19.682 19.682v96.604z" />
30+
<path d="M147.978 236.339c10.885 0 19.681 8.755 19.681 19.641v0c0 10.885-8.796 19.702-19.681 19.702h-96.624c-10.864 0-19.661-8.817-19.661-19.702v0c0-10.885 8.796-19.641 19.661-19.641h96.624z" />
31+
<path d="M460.615 236.339c10.865 0 19.682 8.755 19.682 19.641v0c0 10.885-8.817 19.702-19.682 19.702h-96.584c-10.885 0-19.722-8.817-19.722-19.702v0c0-10.885 8.837-19.641 19.722-19.641h96.584z" />
32+
<path d="M193.546 165.703c7.69 7.66 7.68 20.142 0 27.822v0c-7.701 7.701-20.162 7.701-27.853 0.020l-68.311-68.322c-7.68-7.701-7.68-20.142 0-27.863v0c7.68-7.68 20.121-7.68 27.822 0l68.342 68.342z" />
33+
<path d="M414.597 386.775c7.7 7.68 7.7 20.163 0.021 27.863v0c-7.7 7.659-20.142 7.659-27.843-0.062l-68.311-68.26c-7.68-7.7-7.68-20.204 0-27.863v0c7.68-7.7 20.163-7.7 27.842 0l68.291 68.322z" />
34+
<path d="M165.694 318.464c7.69-7.7 20.153-7.7 27.853 0v0c7.68 7.659 7.69 20.163 0 27.863l-68.342 68.322c-7.67 7.659-20.142 7.659-27.822-0.062v0c-7.68-7.68-7.68-20.122 0-27.801l68.311-68.322z" />
35+
<path d="M386.775 97.362c7.7-7.68 20.142-7.68 27.822 0v0c7.7 7.68 7.7 20.183 0.021 27.863l-68.322 68.311c-7.68 7.68-20.163 7.68-27.843-0.020v0c-7.68-7.68-7.68-20.162 0-27.822l68.322-68.332z" />
36+
</svg>
37+
);
38+
};
39+
40+
const Spinner = styled(SpinnerIcon)`
41+
animation: 2s ${rotate} linear infinite;
42+
43+
path {
44+
fill: ${palette.gray.dark3};
45+
46+
.dark-theme & {
47+
fill: ${palette.gray.light2};
48+
}
49+
}
50+
`;
51+
52+
export default Spinner;

0 commit comments

Comments
 (0)