Last active
June 25, 2018 08:17
-
-
Save drenther/503206f23293e79a6d4124c03e566007 to your computer and use it in GitHub Desktop.
keyframes and pseudo-elements usage in styled-components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* src/components/Loader.js */ | |
/* line 1 - 39 */ | |
import React from 'react'; | |
import styled, { keyframes } from 'styled-components'; | |
import { getColor } from '../utils/theme' | |
const Loader = ({ className }) => (<div className={className}><Loading/></div>) | |
const loading = keyframes` | |
0% { | |
transform: rotate(0); | |
} 100% { | |
transform: rotate(360deg); | |
} | |
`; | |
const Loading = styled.div` | |
color: transparent; | |
min-height: 2rem; | |
pointer-events: none; | |
position: relative; | |
&::after { | |
content: ""; | |
animation: ${loading} .5s infinite linear; | |
border: .1rem solid ${getColor('primary')}; | |
border-radius: 50%; | |
border-right-color: transparent; | |
border-top-color: transparent; | |
display: block; | |
z-index: 1; | |
left: 50%; | |
position: absolute; | |
top: 50%; | |
height: 1.6rem; | |
width: 1.6rem | |
margin-left: -.8rem; | |
margin-top: -.8rem; | |
} | |
`; | |
. | |
. | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment