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

circles-to-rhombuses-spinner

v1.1.0arrow_drop_down
v1.1.0
STATUS
Passing
DOWNLOADS
1
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
10 months ago
SIZE
3 KB
1 contributor
Install circles-to-rhombuses-spinner as a package?
Copied
npm i @bit/epicmaxco.epic-spinners.circles-to-rhombuses-spinner
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
CirclesToRhombusesSpinner.vue
142 Lines(117 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
  <div class="circles-to-rhombuses-spinner" :style="spinnertStyle">
    <div class="circle" v-for="(cs, index) in circlesStyles" :style="cs" :key="index"></div>
  </div>
</template>

<script>
  export default {
    name: 'CirclesToRhombusesSpinner',

    props: {
      animationDuration: {
        type: Number,
        default: 1200
      },
      circleSize: {
        type: Number,
        default: 15
      },
      color: {
        type: String,
        default: '#fff'
      },
      circlesNum: {
        type: Number,
        default: 3
      }
    },

    computed: {
      circleMarginLeft () {
        return this.circleSize * 1.125
      },

      spinnertStyle () {
        return {
          height: `${this.circleSize}px`,
          width: `${(this.circleSize + this.circleMarginLeft) * this.circlesNum}px`
        }
      },

      circleStyle () {
        return {
          borderColor: this.color,
          animationDuration: `${this.animationDuration}ms`,
          height: `${this.circleSize}px`,
          width: `${this.circleSize}px`,
          marginLeft: `${this.circleMarginLeft}px`
        }
      },

      circlesStyles () {
        const circlesStyles = []
        const delay = 150

        for (let i = 1; i <= this.circlesNum; i++) {
          const style = Object.assign({
            animationDelay: `${i * delay}ms`
          }, this.circleStyle)

          if (i === 1) {
            style.marginLeft = 0
          }

          circlesStyles.push(style)
        }

        return circlesStyles
      }
    }
  }
</script>

<style scoped>
  .circles-to-rhombuses-spinner, .circles-to-rhombuses-spinner * {
    box-sizing: border-box;
  }

  .circles-to-rhombuses-spinner {
    height: 15px;
    width: calc( (15px + 15px * 1.125) * 3);
    display: flex;
    align-items: center;
    justify-content: center
  }

  .circles-to-rhombuses-spinner .circle {
    height: 15px;
    width: 15px;
    margin-left: calc(15px * 1.125);
    transform: rotate(45deg);
    border-radius: 10%;
    border: 3px solid #ff1d5e;
    overflow: hidden;
    background: transparent;

    animation: circles-to-rhombuses-animation 1200ms linear infinite;
  }

  .circles-to-rhombuses-spinner .circle:nth-child(1) {
    animation-delay: calc(150ms * 1);
    margin-left: 0
  }

  .circles-to-rhombuses-spinner .circle:nth-child(2) {
    animation-delay: calc(150ms * 2);
  }

  .circles-to-rhombuses-spinner .circle:nth-child(3) {
    animation-delay: calc(150ms * 3);
  }

  @keyframes circles-to-rhombuses-animation {
    0% {
      border-radius: 10%;
    }

    17.5% {
      border-radius: 10%;
    }

    50% {
      border-radius: 100%;
    }


    93.5% {
      border-radius: 10%;
    }

    100% {
      border-radius: 10%;
    }
  }

  @keyframes circles-to-rhombuses-background-animation {
    50% {
      opacity: 0.4;
    }
  }

</style>