Skip to content

Instantly share code, notes, and snippets.

@trev-dev
Last active May 18, 2019 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trev-dev/f85215a4299dac55c31f9879c8b6235c to your computer and use it in GitHub Desktop.
Save trev-dev/f85215a4299dac55c31f9879c8b6235c to your computer and use it in GitHub Desktop.
ES6 friendly Vue setup. Meant to be used with gulp + babel.
{
"presets": [
"@babel/env",
"@vue/babel-preset-jsx",
[
"babel-preset-minify", {
"mangle": true
}
]
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
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