-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b65f30d
commit b56467b
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<template> | ||
<div class="c-word-suggest-hint"> | ||
<p>Dieses Wort ist anscheinend noch nicht Teil des Wörterbuchs. Möchtest du es hinzufügen?</p> | ||
<button type="button" class="c-button" @click="getModalLoaded">Wort hinzufügen</button> | ||
|
||
<Modal | ||
v-if="loadModal" | ||
:open="showModal" | ||
position="center" | ||
:disable-scroll="true" | ||
@close="showModal = false" | ||
@mounted="modalMounted = true" | ||
> | ||
<SuggestWordForm /> | ||
</Modal> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, defineAsyncComponent } from "vue"; | ||
const Modal = defineAsyncComponent(() => import("@components/Modal.vue")); | ||
const SuggestWordForm = defineAsyncComponent(() => import("@components/SuggestWordForm.vue")); | ||
const showModal = ref(false); | ||
const loadModal = ref(false); | ||
const modalMounted = ref(false); | ||
/** | ||
* This function is responsible for loading and displaying the modal. | ||
* If the modal is already mounted, it will be displayed immediately. | ||
* If the modal is not yet mounted, it will trigger the loading of the modal. | ||
* It will then keep retrying to display the modal every 100ms until the modal is mounted. | ||
* | ||
* @return {void} | ||
*/ | ||
const getModalLoaded = (): void => { | ||
// If the modal is already mounted, display it immediately | ||
if (modalMounted.value) { | ||
showModal.value = true; | ||
} else { | ||
// If the modal is not yet loading, trigger the loading of the modal | ||
if (!loadModal.value) { | ||
loadModal.value = true; | ||
} | ||
// Retry to display the modal every 100ms until it is mounted | ||
setTimeout(getModalLoaded, 100); | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters