marc-leopold/pages/index.vue

226 lines
4.8 KiB
Vue
Raw Normal View History

2019-01-02 21:11:40 +00:00
<template>
2019-01-22 17:11:43 +00:00
<section class="home">
<div class="background background-img">
<BackgroundImageLoader slot="background"
:image-url="currentImageUrl"
@imageLoaded="handleImageLoaded"
@imageLoadError="handleImageLoadError"
/>
<div class="background background-overlay"></div>
</div>
<div class="content">
2019-01-22 17:45:30 +00:00
<transition name="fade">
<h1 v-if="showHeading" class="heading">Marc Leopold Photography</h1>
</transition>
2019-01-22 17:11:43 +00:00
<transition name="fade" mode="out-in">
<p class="tagline"
:key="currentTaglineIndex">
{{ taglines[currentTaglineIndex] }}
</p>
</transition>
</div>
</section>
2019-01-02 21:11:40 +00:00
</template>
<script>
2019-01-03 14:06:28 +00:00
import ContentPage from '@/components/ContentPage'
import BackgroundImageLoader from '@/components/BackgroundImageLoader'
2019-01-03 14:06:28 +00:00
2019-01-02 21:11:40 +00:00
export default {
name: 'HomePage',
2019-01-03 14:06:28 +00:00
components: {
ContentPage,
BackgroundImageLoader
2019-01-03 14:06:28 +00:00
},
2019-01-02 21:11:40 +00:00
data() {
return {
2019-01-22 17:45:30 +00:00
showHeading: false,
2019-01-22 12:52:10 +00:00
currentImageIndex: -1,
bgImages: [
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/slider.jpg',
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/slider-2.jpeg',
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/slider-3.jpeg',
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/4-edit-3.jpg',
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/4-edit.jpg',
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/image-1.png',
'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/slider-4.jpeg',
],
2019-01-22 17:11:43 +00:00
currentTaglineIndex: -1,
taglines: [
'the essence of the image',
2019-01-22 17:38:41 +00:00
'an image of the essential',
'a solitary instance',
'an eternal instance',
'I imagine myself',
2019-01-22 17:11:43 +00:00
],
2019-01-02 21:11:40 +00:00
}
2019-01-22 12:52:10 +00:00
},
computed: {
currentImageUrl () {
let url = null
if (this.currentImageIndex > -1) {
url = this.bgImages[this.currentImageIndex]
}
return url
2019-01-22 17:11:43 +00:00
},
tagLine () {
return this.currentTaglineIndex > -1 ? this.taglines[this.currentTaglineIndex] : ''
2019-01-22 12:52:10 +00:00
}
},
2019-01-31 10:20:14 +00:00
head () {
return {
title: 'Home',
// TODO meta - hid, name, content
}
},
2019-01-22 12:52:10 +00:00
mounted () {
if (this.bgImages.length > 1) {
this.setNextIndex()
2019-01-22 17:45:30 +00:00
this.showHeading = true
2019-01-22 12:52:10 +00:00
}
},
methods: {
setNextIndex () {
this.currentImageIndex =
this.currentImageIndex < this.bgImages.length - 1 ? this.currentImageIndex + 1 : 0
},
2019-01-22 17:11:43 +00:00
nextTagline () {
this.currentTaglineIndex =
this.currentTaglineIndex < this.taglines.length - 1 ? this.currentTaglineIndex + 1 : 0
},
2019-01-22 12:52:10 +00:00
handleImageLoaded () {
window.setTimeout(() => {
2019-01-22 17:11:43 +00:00
this.nextTagline()
2019-01-22 17:38:41 +00:00
}, 700)
window.setTimeout(() => {
this.setNextIndex()
}, 6000)
2019-01-22 12:52:10 +00:00
},
handleImageLoadError () {
this.setNextIndex()
},
2019-01-02 21:11:40 +00:00
}
}
</script>
<style scoped lang="scss">
2019-01-22 17:11:43 +00:00
$heading-height: 4em;
$tagline-height: 2.5em;
$padding: 1rem;
.home {
position: relative;
width: 100%;
height: 100%;
padding: $site-menu__header-height + $padding $padding $padding;
2019-01-22 17:38:41 +00:00
font-size: .5rem;
2019-01-22 17:11:43 +00:00
@media (min-width: $bp__layout) {
padding: $padding $padding $padding $site-menu__header-width + $padding;
2019-01-22 17:38:41 +00:00
font-size: 1rem;
2019-01-22 17:11:43 +00:00
}
}
.background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.background-img {
z-index: -1;
}
.background-overlay {
$color: $color__neutral-100;
// $color: red;
background-color: rgba($color, .4);
background: linear-gradient(
to bottom left,
rgba($color, .1),
rgba($color, .5)
),
linear-gradient(
to bottom,
rgba($color, .9),
rgba($color, .7) $heading-height * 1.5,
rgba($color, .4) $heading-height * 3,
rgba($color, 0) $heading-height * 6,
rgba($color, 0)
),
linear-gradient(
to top,
rgba($color, .6),
rgba($color, 0) $tagline-height * 4,
rgba($color, 0)
),
linear-gradient(
to right,
rgba($color, .4),
rgba($color, 0) 10%,
rgba($color, 0) 90%,
rgba($color, .4)
);
}
.content {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
width: 100%;
max-width: 80rem;
margin: 0 auto;
2019-01-22 17:38:41 +00:00
padding: 1rem 0 0;
@media (min-width: $bp__layout) {
padding: 2rem 3rem 1rem;
}
2019-01-22 17:11:43 +00:00
}
.heading {
2019-01-22 17:45:30 +00:00
color: $color__neutral-900;
2019-01-22 17:11:43 +00:00
font-size: $heading-height;
@include font-title(400);
text-align: center;
}
.tagline {
2019-01-22 17:45:30 +00:00
color: $color__neutral-600;
2019-01-22 17:11:43 +00:00
font-size: $tagline-height;
text-align: right;
@include font-cursive;
}
.fade {
$timing: .7;
&-enter-active {
2019-01-22 17:38:41 +00:00
transition: opacity 5s * $timing .5s ease-in;
2019-01-22 17:11:43 +00:00
}
&-leave-active {
2019-01-22 17:38:41 +00:00
transition: opacity 2s * $timing ease-out;
2019-01-22 17:11:43 +00:00
}
&-enter, &-leave-to {
opacity: 0;
}
}
2019-01-02 21:11:40 +00:00
</style>