<template>
<v-hover v-slot:default="{ hover }">
<div class="img-card">
<div class="img-wrapper">
<img :src="url" alt="image of gallery" />
<transition name="fade">
<div class="cover" :class="{ 'cover-active': hover }">
<v-menu offset-y>
<template v-slot:activator="{ on, attrs }">
<v-text-field
v-bind="attrs"
v-on="on"
solo
append-icon="mdi-chevron-down"
label="Regular"
class="menu"
></v-text-field>
</template>
<v-list>
<v-list-item v-for="(item, index) in items" :key="index">
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<div class="under-wrapper">
<v-btn fab small color="#fff">
<v-icon>mdi-upload</v-icon>
</v-btn>
<v-btn fab small color="#fff">
<v-icon>mdi-dots-horizontal</v-icon>
</v-btn>
</div>
</div>
</transition>
</div>
<p>{{ author }}</p>
</div>
</v-hover>
</template>
<script>
export default {
name: 'ImgCard',
props: ['url', 'author'],
data() {
return {
items: [
{ title: 'Click Me' },
{ title: 'Click Me' },
{ title: 'Click Me' },
{ title: 'Click Me 2' },
],
};
},
methods: {},
};
</script>
<style lang="scss" scoped>
.img-card {
}
.img-wrapper {
position: relative;
border-radius: 16px;
overflow: hidden;
}
.cover {
display: none;
background: rgba($color: #222, $alpha: 0.3);
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 16px;
}
.cover-active {
display: block;
}
.menu {
width: 100%;
border-radius: 12px;
}
img {
display: block;
}
p {
font-weight: bold;
}
//animation
.fade-enter-active,
.fade-leave-active {
transition: opcity 0.3s;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
</style>
I wish make the one component like pinterest's imagee card using Vue, Vuetify, v-menu, v-hover, mouseevnet
I thought it would work, but it's somewhat ambiguous. 'v-menu__content' is rendered outside of element and add mouse event then it worked strange.
If I add function on 'img-card' and try mouse over at drop down menu, it's disappear.. because drop down menu is outside of 'img-card' Or it's switch on and off repeatedly.
I want to fix things that are unnatural. Do i just give up using 'v-menu'? -_-
If my question lacks content, please let me know.