Skip to content

Commit

Permalink
made sure to utilise the defineModal makro instead of defining this m…
Browse files Browse the repository at this point in the history
…yself
  • Loading branch information
CommanderStorm committed Jan 2, 2024
1 parent 711dbd1 commit 6191bcc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion webclient/src/components/DetailsImageSlideshowModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const appURL = import.meta.env.VITE_APP_URL;
</script>

<template>
<Modal v-if="state.data?.imgs" v-model:open="state.image.slideshow_open" :title="t('header')">
<Modal v-if="state.data?.imgs" v-model="state.image.slideshow_open" :title="t('header')">
<div class="carousel">
<template v-for="(_, i) in state.data.imgs" :key="i">
<input
Expand Down
2 changes: 1 addition & 1 deletion webclient/src/components/DetailsRoomfinderMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const modalOpen = ref(false);
</div>
</div>

<Modal v-model:open="modalOpen" :title="t('roomfinder.modal.header')" :classes="{ modal: 'items-baseline' }">
<Modal v-model="modalOpen" :title="t('roomfinder.modal.header')" :classes="{ modal: 'items-baseline' }">
<RoomfinderImageLocation id="rf_modal_image" :map="state.selectedRoomfinderMap()" /> </Modal
></template>
</template>
Expand Down
10 changes: 5 additions & 5 deletions webclient/src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useI18n } from "vue-i18n";
export interface Props {
title: string;
open: boolean;
disableClose?: boolean;
classes?: {
background?: string;
Expand All @@ -21,11 +20,12 @@ const props = withDefaults(defineProps<Props>(), {
modal: "",
}),
});
const emit = defineEmits(["close", "update:open"]);
const emit = defineEmits(["close"]);
const isOpen = defineModel<boolean>({ required: true });
const { t } = useI18n({ useScope: "local" });
watch(props, () => {
if (props.open) {
if (isOpen) {
return document.querySelector("body")?.classList.add("overflow-hidden");
} else {
return document.querySelector("body")?.classList.remove("overflow-hidden");
Expand All @@ -45,7 +45,7 @@ onBeforeUnmount(() => document.querySelector("body")?.classList.remove("overflow
function close() {
document.querySelector("body")?.classList.remove("overflow-hidden");
emit("close");
emit("update:open", false);
isOpen.value = false;
}
function closeIfShown() {
Expand All @@ -63,7 +63,7 @@ function closeIfShown() {
leave-active-class="transition duration-75"
>
<div
v-if="props.open"
v-if="isOpen"
class="bg-smoke-800 fixed inset-0 z-50 m-5 flex h-screen w-full items-center justify-center"
:class="props.classes.background"
@click.self="closeIfShown"
Expand Down
4 changes: 2 additions & 2 deletions webclient/src/components/PreferencesPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function setLang(lang: string) {
class="absolute -right-2 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
>
<MenuItem as="div" class="block px-4 py-2 text-xs font-semibold text-slate-500">
<SelectionSwitch v-model:selected="theme" label="Theme" :values="['dark', 'light']">
<SelectionSwitch v-model="theme" label="Theme" :values="['dark', 'light']">
<template #option1><MoonIcon class="h-3 w-3" /></template>
<template #option2><SunIcon class="h-3 w-3" /></template>
</SelectionSwitch>
<SelectionSwitch v-model:selected="locale" label="Language" :values="['de', 'en']">
<SelectionSwitch v-model="locale" label="Language" :values="['de', 'en']">
<template #option1>de</template>
<template #option2>en</template>
</SelectionSwitch>
Expand Down
9 changes: 4 additions & 5 deletions webclient/src/components/SelectionSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { computed } from "vue";
interface Props {
label?: string;
selected: string;
values: [string, string];
}
const props = withDefaults(defineProps<Props>(), { label: "" });
const emit = defineEmits(["update:selected"]);
const firstValueSelected = computed(() => props.selected === props.values[0]);
const selected = defineModel<string>({ required: true });
const firstValueSelected = computed(() => selected.value === props.values[0]);
</script>

<template>
Expand All @@ -20,7 +19,7 @@ const firstValueSelected = computed(() => props.selected === props.values[0]);
<Switch
class="relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent text-slate-400 transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-tumBlue-500 focus:ring-offset-2"
:class="[firstValueSelected ? 'bg-tumBlue-500' : 'bg-slate-200']"
@update:model-value="(value: boolean) => emit('update:selected', value ? props.values[0] : props.values[1])"
@update:model-value="(value: boolean) => (selected = props.values[value ? 0 : 1])"
>
<span class="sr-only">Use setting</span>
<span
Expand Down
2 changes: 1 addition & 1 deletion webclient/src/components/ShareButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const shareOptions = computed<UseShareOptions>(() => ({

<template>
<a type="button" :title="t('external_link')" @click="modalOpen = true"><ShareIcon class="h-4 w-4" /></a>
<Modal v-model:open="modalOpen" :title="t('share')">
<Modal v-model="modalOpen" :title="t('share')">
<div class="flex flex-col gap-5">
<div class="flex flex-col gap-2">
<strong>{{ t("open_in") }}</strong>
Expand Down
2 changes: 1 addition & 1 deletion webclient/src/components/TinyModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const modalOpen = ref(false);
<a class="cursor-pointer" :aria-label="t('show_more_information')" @click="() => (modalOpen = true)">
<slot name="icon" />
</a>
<Modal v-model:open="modalOpen" :title="props.content.title">
<Modal v-model="modalOpen" :title="props.content.title">
<p v-if="props.content.body">{{ props.content.body }}</p>
<p v-if="props.content.footer">{{ props.content.footer }}</p>
</Modal>
Expand Down
4 changes: 2 additions & 2 deletions webclient/src/components/feedback/TokenBasedModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function sendForm() {
<template>
<Modal
v-if="!successUrl"
v-model:open="global.feedback.open"
v-model="global.feedback.open"
data-cy="feedback-modal"
:title="t('title')"
@close="closeForm"
Expand Down Expand Up @@ -170,7 +170,7 @@ function sendForm() {
</Modal>
<Modal
v-if="successUrl"
v-model:open="global.feedback.open"
v-model="global.feedback.open"
data-cy="feedback-success-modal"
:title="t('thank_you')"
@close="closeForm"
Expand Down

0 comments on commit 6191bcc

Please sign in to comment.