Last active
May 18, 2019 18:44
-
-
Save trev-dev/f85215a4299dac55c31f9879c8b6235c to your computer and use it in GitHub Desktop.
ES6 friendly Vue setup. Meant to be used with gulp + babel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
"@babel/env", | |
"@vue/babel-preset-jsx", | |
[ | |
"babel-preset-minify", { | |
"mangle": true | |
} | |
] | |
], | |
"plugins": [ | |
"@babel/plugin-proposal-object-rest-spread" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component('hero-banner', { | |
data() { | |
return { | |
loaded: false | |
} | |
}, | |
props: { | |
src: String | |
}, | |
mounted() { | |
this.image = new Image() | |
this.image.src = this.src | |
this.image.onload = () => { | |
this.loaded = true | |
} | |
}, | |
render() { | |
let content = <spinner classes={['spinner-hero']} /> | |
if (this.loaded) { | |
content = ( | |
<div id="hero-banner" | |
style={{ backgroundImage: `url(${this.src})` }} | |
> | |
<p>Talking Text</p> | |
</div> | |
) | |
} | |
return ( | |
<div id="hero-wrapper"> | |
<transition name="fade"> | |
{ content } | |
</transition> | |
</div> | |
) | |
} | |
}) | |
new Vue({ | |
el: "#page" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment