advent22/ui/src/components/ImageModal.vue

36 lines
755 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
2023-01-17 14:28:11 +00:00
public created() {
2022-10-30 02:35:39 +00:00
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
});
}
2023-01-17 14:28:11 +00:00
public set_active(state: boolean) {
2022-12-21 23:51:01 +00:00
this.active = state;
}
2023-01-17 14:28:11 +00:00
public show_src(src: string) {
2022-12-21 23:51:01 +00:00
this.image_src = src;
2022-12-22 00:16:42 +00:00
this.set_active(true);
2022-10-30 02:35:39 +00:00
}
}
</script>