marc-leopold/components/BackgroundImageLoader.vue

80 lines
1.3 KiB
Vue
Raw Normal View History

2019-01-18 13:33:13 +00:00
<template>
<div class="background-image-loader">
<div class="background-container">
<div class="background background-loading"
:style="loadingStyle"></div>
<div class="background background-img"
:style="backgroundStyle"></div>
</div>
2019-01-18 13:33:13 +00:00
</div>
</template>
<script>
import imageLoader from '~/mixins/imageLoader.js'
export default {
mixins: [ imageLoader ],
2019-01-18 13:33:13 +00:00
props: {
bgLoading: {
type: String,
required: false,
default: function () {
return 'linear-gradient(310deg, #35405d, #6174aa, #a8b3d0, #e2e5ef)'
}
},
img: {
type: String,
required: false,
default: function () {
return 'url(https://via.placeholder.com/1920x1080)'
}
},
2019-01-18 13:33:13 +00:00
},
data () {
return {
}
},
computed: {
loadingStyle () {
return {
background: this.bgLoading
}
},
backgroundStyle () {
return {
backgroundImage: this.img
}
}
},
2019-01-18 13:33:13 +00:00
methods: {
}
}
</script>
<style lang="scss" scoped>
.background-image-loader {
position: relative;
width: 100%;
height: 100%;
}
.background {
2019-01-18 13:33:13 +00:00
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.background-img {
background-size: cover;
background-position: center center;
opacity: .5;
2019-01-18 13:33:13 +00:00
}
</style>