Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 1x 1x 1x 1x 1x 5x 1x 5x 4x 4x 5x 4x 4x 5x 4x 4x 5x 4x 1x 5x 5x 1x 1x 1x 1x | /** @jsx jsx */ import * as React from "react"; import { keyframes, css, jsx } from "@emotion/core"; import { Keyframes } from "@emotion/serialize"; import onlyUpdateForKeys from "recompose/onlyUpdateForKeys"; import { sizeDefaults, sizeKeys } from "./helpers"; import { StyleFunction, PrecompiledCss, LoaderSizeProps } from "./interfaces"; const climbingBox: Keyframes = keyframes` 0% {transform:translate(0, -1em) rotate(-45deg)} 5% {transform:translate(0, -1em) rotate(-50deg)} 20% {transform:translate(1em, -2em) rotate(47deg)} 25% {transform:translate(1em, -2em) rotate(45deg)} 30% {transform:translate(1em, -2em) rotate(40deg)} 45% {transform:translate(2em, -3em) rotate(137deg)} 50% {transform:translate(2em, -3em) rotate(135deg)} 55% {transform:translate(2em, -3em) rotate(130deg)} 70% {transform:translate(3em, -4em) rotate(217deg)} 75% {transform:translate(3em, -4em) rotate(220deg)} 100% {transform:translate(0, -1em) rotate(-225deg)} `; class Loader extends React.PureComponent<LoaderSizeProps> { public static defaultProps: LoaderSizeProps = sizeDefaults(15); public style: StyleFunction = (): PrecompiledCss => { const { color } = this.props; return css` position: absolute; left: 0; bottom: -0.1em; height: 1em; width: 1em; background-color: transparent; border-radius: 15%; border: 0.25em solid ${color}; transform: translate(0, -1em) rotate(-45deg); animation-fill-mode: both; animation: ${climbingBox} 2.5s infinite cubic-bezier(0.79, 0, 0.47, 0.97); `; }; public wrapper: StyleFunction = (): PrecompiledCss => { const { size, sizeUnit } = this.props; return css` position: absolute; top: 50%; left: 50%; margin-top: -2.7em; margin-left: -2.7em; width: 5.4em; height: 5.4em; font-size: ${`${size}${sizeUnit}`}; `; }; public hill: StyleFunction = (): PrecompiledCss => { const { color } = this.props; return css` position: absolute; width: 7.1em; height: 7.1em; top: 1.7em; left: 1.7em; border-left: 0.25em solid ${color}; transform: rotate(45deg); `; }; public container: StyleFunction = (): PrecompiledCss => { return css` position: relative; width: 7.1em; height: 7.1em; `; }; public render(): JSX.Element | null { const { loading, css } = this.props; return loading ? ( <div css={[this.container(), css]}> <div css={this.wrapper()}> <div css={this.style()} /> <div css={this.hill()} /> </div> </div> ) : null; } } const Component: React.ComponentClass<LoaderSizeProps> = onlyUpdateForKeys(sizeKeys)(Loader); Component.defaultProps = Loader.defaultProps; export default Component; |