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 | 1x 1x 1x 1x 1x 6x 1x 6x 25x 25x 6x 5x 5x 1x 6x 6x 1x 1x 1x 1x | /** @jsx jsx */ import * as React from "react"; import { keyframes, css, jsx } from "@emotion/core"; import onlyUpdateForKeys from "recompose/onlyUpdateForKeys"; import { sizeDefaults, sizeKeys } from "./helpers"; import { Keyframes } from "@emotion/serialize"; import { StyleFunction, PrecompiledCss, LoaderSizeProps, StyleFunctionWithIndex } from "./interfaces"; const circle: Keyframes = keyframes` 0% {transform: rotate(0deg)} 50% {transform: rotate(180deg)} 100% {transform: rotate(360deg)} `; class Loader extends React.PureComponent<LoaderSizeProps> { public static defaultProps: LoaderSizeProps = sizeDefaults(50); public style: StyleFunctionWithIndex = (i: number): PrecompiledCss => { const { size, color, sizeUnit } = this.props; return css` position: absolute; height: ${`${size! * (1 - i / 10)}${sizeUnit}`}; width: ${`${size! * (1 - i / 10)}${sizeUnit}`}; border: 1px solid ${color}; border-radius: 100%; transition: 2s; border-bottom: none; border-right: none; top: ${i * 0.7 * 2.5}%; left: ${i * 0.35 * 2.5}%; animation-fill-mode: ""; animation: ${circle} 1s ${i * 0.2}s infinite linear; `; }; public wrapper: StyleFunction = (): PrecompiledCss => { const { size, sizeUnit } = this.props; return css` position: relative; width: ${`${size}${sizeUnit}`}; height: ${`${size}${sizeUnit}`}; `; }; public render(): JSX.Element | null { const { loading, css } = this.props; return loading ? ( <div css={[this.wrapper(), css]}> <div css={this.style(0)} /> <div css={this.style(1)} /> <div css={this.style(2)} /> <div css={this.style(3)} /> <div css={this.style(4)} /> </div> ) : null; } } const Component: React.ComponentClass<LoaderSizeProps> = onlyUpdateForKeys(sizeKeys)(Loader); Component.defaultProps = Loader.defaultProps; export default Component; |