import * as React from "react"
import styled, { keyframes } from "styled-components"

const Animated = keyframes`
    0% {
        background-position: -468px 0
    }
    100% {
        background-position: 468px 0
    }
`

const AnimatedBackgroundBG = styled.div`

  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  position: absolute;
  z-index: 1;
  box-sizing: border-box;


  .AnimatedBackground__bg {
    border-radius: 5px;
    background: #f6f7f8;
    background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
    background-size: 800px 104px;
    animation-duration: 1s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
    animation-name: ${Animated};
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
`

export const AnimatedBackground: React.SFC<React.StyleHTMLAttributes<{}>> = (props) => {
  return (
    <AnimatedBackgroundBG {...props} >
      <div className="AnimatedBackground__bg" />
    </AnimatedBackgroundBG>
  )
}
