|
1 | 1 | import * as React from 'react' |
| 2 | +import styled, { keyframes } from '../styled' |
2 | 3 |
|
3 | | -export default function Spinner() { |
| 4 | +const Spinner = () => { |
4 | 5 | return ( |
5 | | - <div className="spinner-container"> |
6 | | - <style jsx={true}>{` |
7 | | - .spinner-container { |
8 | | - height: 36px; |
9 | | - left: 50%; |
10 | | - position: absolute; |
11 | | - top: 50%; |
12 | | - transform: translate(-50%, -50%); |
13 | | - width: 36px; |
14 | | - z-index: 10; |
15 | | - } |
16 | | -
|
17 | | - @keyframes rotation { |
18 | | - from { |
19 | | - transform: rotate(0deg); |
20 | | - } |
21 | | - to { |
22 | | - transform: rotate(359deg); |
23 | | - } |
24 | | - } |
25 | | -
|
26 | | - .spinner { |
27 | | - animation: rotation 0.6s infinite linear; |
28 | | - border-bottom: 6px solid rgba(150, 150, 150, .15); |
29 | | - border-left: 6px solid rgba(150, 150, 150, .15); |
30 | | - border-radius: 100%; |
31 | | - border-right: 6px solid rgba(150, 150, 150, .15); |
32 | | - border-top: 6px solid rgba(150, 150, 150, .8); |
33 | | - display: inline-block; |
34 | | - height: 24px; |
35 | | - width: 24px; |
36 | | - position: absolute; |
37 | | - vertical-align: middle; |
38 | | - } |
39 | | - `}</style> |
40 | | - <div className="spinner" /> |
41 | | - </div> |
| 6 | + <Wrapper> |
| 7 | + <SpinnerNode /> |
| 8 | + </Wrapper> |
42 | 9 | ) |
43 | 10 | } |
| 11 | + |
| 12 | +export default Spinner |
| 13 | + |
| 14 | +const rotation = keyframes` |
| 15 | + from { |
| 16 | + transform: rotate(0deg); |
| 17 | + } |
| 18 | + to { |
| 19 | + transform: rotate(359deg); |
| 20 | + } |
| 21 | +` |
| 22 | + |
| 23 | +const Wrapper = styled.div` |
| 24 | + height: 36px; |
| 25 | + left: 50%; |
| 26 | + position: absolute; |
| 27 | + top: 50%; |
| 28 | + transform: translate(-50%, -50%); |
| 29 | + width: 36px; |
| 30 | + z-index: 10; |
| 31 | +` |
| 32 | + |
| 33 | +const SpinnerNode = styled.div` |
| 34 | + position: absolute; |
| 35 | + display: inline-block; |
| 36 | + height: 24px; |
| 37 | + width: 24px; |
| 38 | + vertical-align: middle; |
| 39 | +
|
| 40 | + animation: ${rotation} 0.6s infinite linear; |
| 41 | +
|
| 42 | + border-radius: 100%; |
| 43 | + border-bottom: 6px solid rgba(150, 150, 150, 0.15); |
| 44 | + border-left: 6px solid rgba(150, 150, 150, 0.15); |
| 45 | + border-right: 6px solid rgba(150, 150, 150, 0.15); |
| 46 | + border-top: 6px solid rgba(150, 150, 150, 0.8); |
| 47 | +` |
0 commit comments