puzzle/src/frontend/components/ImageTeaser.vue

47 lines
929 B
Vue
Raw Normal View History

2021-05-17 00:27:47 +02:00
<template>
2021-05-22 14:26:04 +02:00
<div
class="imageteaser"
:style="style"
@click="onClick">
<div class="btn edit" @click.stop="onEditClick"></div>
</div>
2021-05-17 00:27:47 +02:00
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'image-teaser',
props: {
image: {
type: Object,
required: true,
},
},
computed: {
style (): object {
const url = this.image.url.replace('uploads/', 'uploads/r/') + '-150x100.webp'
return {
'backgroundImage': `url("${url}")`,
}
},
},
2021-05-22 14:26:04 +02:00
emits: {
click: null,
editClick: null,
},
2021-05-17 00:27:47 +02:00
methods: {
onClick() {
this.$emit('click')
},
2021-05-22 14:26:04 +02:00
onEditClick() {
this.$emit('editClick')
},
2021-05-17 00:27:47 +02:00
},
})
</script>
2021-05-22 14:26:04 +02:00
<style type="css">
.imageteaser { position: relative; }
.imageteaser .edit { display: none; position: absolute; }
.imageteaser:hover .edit { display: inline-block; }
</style>