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" >
2019-02-12 11:45:22 +00:00
{ { tagline } }
2019-01-22 17:11:43 +00:00
< / 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'
2019-01-21 10:56:12 +00:00
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 : {
2019-01-21 10:56:12 +00:00
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 ,
2019-01-22 17:11:43 +00:00
currentTaglineIndex : - 1 ,
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
} ,
2019-02-12 11:45:22 +00:00
tagline ( ) {
return this . currentTaglineIndex > - 1 ? this . taglines [ this . currentTaglineIndex ] . text : ''
2019-01-22 12:52:10 +00:00
}
} ,
2019-01-31 10:20:14 +00:00
head ( ) {
return {
title : 'Home' ,
2019-02-04 12:53:18 +00:00
meta : [ {
hid : 'description' ,
name : 'description' ,
2019-02-04 21:28:29 +00:00
content : 'Photographer, Marc Leopold has images in numerous collections and publications. Here is a glimpse of his work, an insight into his philosophy and motivations.'
2019-02-04 12:53:18 +00:00
} ] ,
2019-01-31 10:20:14 +00:00
}
} ,
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
}
} ,
2019-02-12 11:45:22 +00:00
async asyncData ( { $axios } ) {
2019-02-12 12:36:05 +00:00
const { bgImages , taglines } = await $axios . $get ( '/api/v1/home' )
2019-02-12 11:45:22 +00:00
return { bgImages , taglines }
2019-02-04 11:47:25 +00:00
} ,
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 ( )
2019-01-22 15:37:42 +00:00
} , 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 : 4 em ;
$tagline - height : 2.5 em ;
$padding : 1 rem ;
. 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 : .5 rem ;
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 : 1 rem ;
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 ;
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 ) ,
2019-02-13 13:36:27 +00:00
rgba ( $color , 0 ) 20 % ,
rgba ( $color , 0 ) 80 % ,
2019-01-22 17:11:43 +00:00
rgba ( $color , .4 )
2019-02-13 13:36:27 +00:00
) ,
radial - gradient (
at 100 % 100 % ,
rgba ( $color , .4 ) 0 ,
rgba ( $color , 0 ) 40 %
2019-01-22 17:11:43 +00:00
) ;
}
. content {
display : flex ;
flex - direction : column ;
justify - content : space - between ;
height : 100 % ;
width : 100 % ;
max - width : 80 rem ;
margin : 0 auto ;
2019-01-22 17:38:41 +00:00
padding : 1 rem 0 0 ;
@ media ( min - width : $bp _ _layout ) {
padding : 2 rem 3 rem 1 rem ;
}
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 5 s * $timing .5 s ease - in ;
2019-01-22 17:11:43 +00:00
}
& - leave - active {
2019-01-22 17:38:41 +00:00
transition : opacity 2 s * $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 >