advent22/ui/src/components/ImageModal.vue

35 lines
745 B
Vue
Raw Normal View History

2022-10-30 02:35:39 +00:00
<template>
2022-12-21 23:51:01 +00:00
<div class="modal is-active" v-if="active" @click="set_active(false)">
2022-10-30 02:35:39 +00:00
<div class="modal-background" />
<div class="modal-content">
2022-11-04 01:11:20 +00:00
<div class="image is-square">
2022-12-21 23:51:01 +00:00
<img :src="image_src" alt="Kalender-Bild" />
2022-11-04 01:11:20 +00:00
</div>
2022-10-30 02:35:39 +00:00
</div>
</div>
</template>
<script lang="ts">
2022-12-21 23:51:01 +00:00
import { Vue } from "vue-class-component";
2022-10-30 02:35:39 +00:00
export default class ImageModal extends Vue {
2022-12-21 23:51:01 +00:00
private active = false;
public image_src = "";
2022-10-30 02:35:39 +00:00
public created(): void {
window.addEventListener("keydown", (e) => {
2022-12-21 23:51:01 +00:00
if (e.key == "Escape") this.set_active(false);
2022-10-30 02:35:39 +00:00
});
}
2022-12-21 23:51:01 +00:00
public set_active(state: boolean): void {
this.active = state;
}
public set_src(src: string): void {
this.image_src = src;
2022-10-30 02:35:39 +00:00
}
}
</script>