Skip to content

Instantly share code, notes, and snippets.

@jepser
Created April 2, 2020 19:01
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 jepser/d779b567a0f4aee1d24cda2a2b3aaf95 to your computer and use it in GitHub Desktop.
Save jepser/d779b567a0f4aee1d24cda2a2b3aaf95 to your computer and use it in GitHub Desktop.
UserView - Vue
<template>
<div>
<div>My portfolio</div>
<div v-if="featureItem" class="feature-item">
<h4>{{featureItem.title}}</h4>
<p>{{featureItem.description}}</p>
<img :src="featureItem.image" />
</div>
<ul class="image-wrapper">
<li
class="image"
v-for="(project, index) in projects"
:key="project.title"
@click="moveToFeature(index)"
>
<img :src="project.image" />
</li>
</ul>
</div>
</template>
<script>
export default {
name: "UserView",
props: ['projects'],
data: () => {
return {
featureItemIndex: -1
}
},
computed: {
featureItem(){
const currentItem = this.projects[this.featureItemIndex]
return currentItem
}
},
methods: {
moveToFeature(index) {
this.featureItemIndex = index
}
}
};
</script>
<style>
.image-wrapper {
margin: 16px;
display: flex;
justify-content: space-between;
}
.image {
max-width: 45%;
margin-bottom: 16px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment