Created
June 27, 2019 17:12
-
-
Save kennygoff/a6f18ad4ab7d79f7157dc64d1ebc8f0e to your computer and use it in GitHub Desktop.
Skeleton placeholder for text
This file contains hidden or 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
import React from 'react'; | |
import styled from '@emotion/styled'; | |
import { keyframes } from '@emotion/core'; | |
const pulse = props => keyframes` | |
0% { | |
background-color: ${props.theme.colors.placeholder}; | |
} | |
70% { | |
background-color: ${props.theme.colors.placeholderAccent}; | |
} | |
100% { | |
background-color: ${props.theme.colors.placeholder}; | |
} | |
`; | |
const Text = styled.span` | |
&::before { | |
content: "${props => '_'.repeat(props.contentWidth)}"; | |
background-color: ${props => props.theme.colors.placeholder}; | |
color: transparent; | |
border-radius: 3px; | |
animation: ${props => pulse(props)} 4s ease infinite; | |
} | |
`; | |
export default Text; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment