Skip to content

Instantly share code, notes, and snippets.

@kennygoff
Created June 27, 2019 17:12
Show Gist options
  • Save kennygoff/a6f18ad4ab7d79f7157dc64d1ebc8f0e to your computer and use it in GitHub Desktop.
Save kennygoff/a6f18ad4ab7d79f7157dc64d1ebc8f0e to your computer and use it in GitHub Desktop.
Skeleton placeholder for text
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