Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Line Loader #6

Merged
merged 2 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<GridLoader :color="'#be97e8'" class="loader" />
<HeartLoader :color="'#be97e8'" class="loader" />
<HourglassLoader :color="'#be97e8'" class="loader" />
<LineLoader :color="'#be97e8'" class="loader" />
<RingLoader :color="'#be97e8'" class="loader" />
<RippleLoader :color="'#be97e8'" class="loader" />
<RollerLoader :color="'#be97e8'" class="loader" />
Expand All @@ -25,11 +26,12 @@
<CircleLoader :color="'#be97e8'" duration="5s" />
<DefaultLoader :color="'#be97e8'" duration="5s" />
<DualRingLoader :color="'#be97e8'" duration="5s" />
<!-- <EllipsisLoader :color="'#be97e8'" duration="1s" /> -->
<EllipsisLoader :color="'#be97e8'" duration="1s" />
<FacebookLoader :color="'#be97e8'" duration="5s" />
<GridLoader :color="'#be97e8'" duration="5s" />
<HeartLoader :color="'#be97e8'" duration="5s" />
<HourglassLoader :color="'#be97e8'" duration="5s" />
<LineLoader :color="'#be97e8'" duration="5s" />
<RingLoader :color="'#be97e8'" duration="5s" />
<RippleLoader :color="'#be97e8'" duration="5s" />
<RollerLoader :color="'#be97e8'" duration="5s" />
Expand Down Expand Up @@ -79,6 +81,11 @@
<HourglassLoader :color="'#be97e8'" />
<HourglassLoader />
</div>
<div class="block">
<LineLoader :color="'#54f1d2'" />
<LineLoader :color="'#be97e8'" />
<LineLoader />
</div>
<div class="block">
<RingLoader :color="'#54f1d2'" />
<RingLoader :color="'#be97e8'" />
Expand Down Expand Up @@ -143,6 +150,11 @@
<HourglassLoader :color="'#be97e8'" :size="32" />
<HourglassLoader :color="'#be97e8'" :size="16" />
</div>
<div class="block">
<LineLoader :color="'#be97e8'" />
<LineLoader :color="'#be97e8'" :size="32" />
<LineLoader :color="'#be97e8'" :size="16" />
</div>
<div class="block">
<RingLoader :color="'#be97e8'" />
<RingLoader :color="'#be97e8'" :size="32" />
Expand Down Expand Up @@ -182,6 +194,7 @@ import FacebookLoader from './components/FacebookLoader'
import GridLoader from './components/GridLoader.vue'
import HeartLoader from './components/HeartLoader.vue'
import HourglassLoader from './components/HourglassLoader.vue'
import LineLoader from './components/LineLoader.vue'
import RingLoader from './components/RingLoader.vue'
import RippleLoader from './components/RippleLoader.vue'
import RollerLoader from './components/RollerLoader.vue'
Expand All @@ -199,6 +212,7 @@ export default {
GridLoader,
HeartLoader,
HourglassLoader,
LineLoader,
RingLoader,
RippleLoader,
RollerLoader,
Expand Down
90 changes: 90 additions & 0 deletions src/components/LineLoader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<template>
<div v-show="loading" class="lds-line" :style="{ width: `${size}px`, height: `${size}px` }">
<div class="lds-line-before" v-bind:style="[spinnerStyle]"></div>
<div class="lds-line-after" v-bind:style="[spinnerStyle]"></div>
</div>
</template>

<script>
import validateDuration from '../helpers/validateDuration.js'

export default {
name: 'LineLoader',
props: {
loading: {
type: Boolean,
default: true,
},
size: {
type: Number,
default: 80,
},
color: {
type: String,
default: '#7f58af',
},
duration: {
type: String,
default: '1.2s',
validator: validateDuration,
},
},
data() {
return {
spinnerStyle: {
background: this.color,
animationDuration: this.duration,
},
}
},
}
</script>

<style scoped>
.lds-line {
display: inline-block;
position: relative;
overflow: hidden;

}

.lds-line-after,
.lds-line-before {
content: ' ';
display: block;
height: 10%;
margin: 0 10%;
position: absolute;
top: 50%;
transform: translateY(-50%);
}

.lds-line-after {
width: 0;
animation-name: lds-line;
animation-iteration-count: infinite;
}

.lds-line-before {
width: 100%;
opacity: 0.5;

}

@keyframes lds-line {
0% {
width: 0px;
transform: translate(0%, -50%);
}

50% {
width: 100%;
transform: translate(0%, -50%);
}

100% {
transform: translate(100%, -50%);
width: 100%
}
}
</style>
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FacebookLoader from './FacebookLoader.vue'
import GridLoader from './GridLoader.vue'
import HeartLoader from './HeartLoader.vue'
import HourglassLoader from './HourglassLoader.vue'
import LineLoader from './LineLoader.vue'
import RingLoader from './RingLoader.vue'
import RippleLoader from './RippleLoader.vue'
import RollerLoader from './RollerLoader.vue'
Expand All @@ -21,6 +22,7 @@ export {
GridLoader,
HeartLoader,
HourglassLoader,
LineLoader,
RingLoader,
RippleLoader,
RollerLoader,
Expand Down