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

bounce-loader

v0.5.1arrow_drop_down
v0.5.1
STATUS
Passing
DOWNLOADS
129
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 years ago
SIZE
8 KB
bouncing dot loader
1 contributor
Install bounce-loader as a package?
Copied
npm i @bit/davidhu2000.react-spinners.bounce-loader
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
BounceLoader.jsx
71 Lines(59 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
/** @jsx jsx */
import React from 'react';
import PropTypes from 'prop-types';
import { keyframes, css, jsx } from '@emotion/core';
import onlyUpdateForKeys from 'recompose/onlyUpdateForKeys';

const bounce = keyframes`
  0%, 100% {transform: scale(0)} 
  50% {transform: scale(1.0)}
`;

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

      return css`{
            position: absolute;
            height: ___CSS_0___;
            width: ___CSS_1___;
            background-color: ___CSS_2___;
            border-radius: 100%;
            opacity: 0.6;        
            top: 0;
            left: 0;
            animation-fill-mode: both;
            animation: ___CSS_3___ 2.1s ___CSS_4___ infinite ease-in-out;
        }`;
    };

    wrapper = () => {
      const { size, sizeUnit } = this.props;

      const wrapper = css`{        
            position: relative;
            width: ___CSS_0___;
            height: ___CSS_1___;
        }`;

      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(1)} />
          <div css={this.style(2)} />
        </div> : null;
    }
}

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

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

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