Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

propagate-loader

v0.5.1arrow_drop_down
v0.5.1
STATUS
Passing
DOWNLOADS
172
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 years ago
SIZE
9 KB
one dot splits into six dots loader
1 contributor
Install propagate-loader as a package?
Copied
npm i @bit/davidhu2000.react-spinners.propagate-loader
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
PropagateLoader.jsx
105 Lines(91 sloc)
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
100
101
102
103
104
105
106
/** @jsx jsx */
import React from 'react';
import PropTypes from 'prop-types';
import { keyframes, css, jsx } from '@emotion/core';
import onlyUpdateForKeys from 'recompose/onlyUpdateForKeys';

// 1.5 4.5 7.5
let distance = [1, 3, 5];

const propagate = [
  keyframes`
      25% {transform: translateX(-___CSS_0___rem) scale(0.75)} 
      50% {transform: translateX(-___CSS_1___rem) scale(0.6)}
      75% {transform: translateX(-___CSS_2___rem) scale(0.5)}
      95% {transform: translateX(0rem) scale(1)}
    `,
  keyframes`
      25% {transform: translateX(-___CSS_0___rem) scale(0.75)} 
      50% {transform: translateX(-___CSS_1___rem) scale(0.6)}
      75% {transform: translateX(-___CSS_2___rem) scale(0.6)}
      95% {transform: translateX(0rem) scale(1)}
    `,
  keyframes`
      25% {transform: translateX(-___CSS_0___rem) scale(0.75)}
      75% {transform: translateX(-___CSS_1___rem) scale(0.75)}
      95% {transform: translateX(0rem) scale(1)}
    `,
  keyframes`
      25% {transform: translateX(___CSS_0___rem) scale(0.75)}
      75% {transform: translateX(___CSS_1___rem) scale(0.75)}
      95% {transform: translateX(0rem) scale(1)}
    `,
  keyframes`
      25% {transform: translateX(___CSS_0___rem) scale(0.75)} 
      50% {transform: translateX(___CSS_1___rem) scale(0.6)}
      75% {transform: translateX(___CSS_2___rem) scale(0.6)}
      95% {transform: translateX(0rem) scale(1)}
    `,
  keyframes`
      25% {transform: translateX(___CSS_0___rem) scale(0.75)} 
      50% {transform: translateX(___CSS_1___rem) scale(0.6)}
      75% {transform: translateX(___CSS_2___rem) scale(0.5)}
      95% {transform: translateX(0rem) scale(1)}
    `
];

class Loader extends React.Component {
    style = i => {
      const { size, sizeUnit, color } = this.props;

      return css`{
            position: absolute;
            font-size: ___CSS_0___;
            width: ___CSS_1___;
            height: ___CSS_2___;
            background: ___CSS_3___;
            border-radius: 50%;
            animation: ___CSS_4___ 1.5s  infinite;
            animation-fill-mode: forwards;
        }`;
    };


  wrapper = () => {
    const wrapper = css`{
            position: relative;
        }`;

    return this.props.css ? css`___CSS_0___;___CSS_1___` : wrapper;
  };

  render() {
    const { loading } = this.props;

    return loading ?
      <div css={this.wrapper()}>
        <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 css={this.style(5)} />
      </div> : null;
  }
}

Loader.propTypes = {
  loading: PropTypes.bool,
  size: PropTypes.number,
  color: PropTypes.string,
  sizeUnit: PropTypes.string,
  css: PropTypes.string
};

Loader.defaultProps = {
  loading: true,
  size: 15,
  color: '#000000',
  sizeUnit: 'px',
  css: ''
};

const Component = onlyUpdateForKeys(['loading', 'color', 'size', 'sizeUnit', 'css'])(Loader);
Component.defaultProps = Loader.defaultProps;
export default Component;