Added Gallery component
This commit is contained in:
parent
460c320e85
commit
c272f12c2f
1 changed files with 109 additions and 0 deletions
109
src/components/Gallery.vue
Normal file
109
src/components/Gallery.vue
Normal file
|
@ -0,0 +1,109 @@
|
|||
<template>
|
||||
<div class="gallery">
|
||||
<div class="big-image">
|
||||
<div class="image-container">
|
||||
<img :src="bigImage" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="thumbnails">
|
||||
<div class="thumbnail" v-for="(img, index) in images" :key="index">
|
||||
<img
|
||||
:src="img"
|
||||
:alt="'Image' + index"
|
||||
@click.prevent="setBigImage(index)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "gallery",
|
||||
props: {
|
||||
images: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
bigImage: ""
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
setBigImage(index) {
|
||||
this.bigImage = this.images[index];
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.bigImage = this.images[0];
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.big-image {
|
||||
width: 100%;
|
||||
height: 480px;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
|
||||
background-color: #444;
|
||||
}
|
||||
|
||||
.image-container {
|
||||
flex: 1;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
align-self: center;
|
||||
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.thumbnails {
|
||||
display: flex;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
|
||||
height: 5em;
|
||||
|
||||
overflow-x: scroll;
|
||||
|
||||
background-color: #888;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
flex: 1 0 auto;
|
||||
|
||||
height: 100%;
|
||||
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
align-self: center;
|
||||
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue