Skip to content

Instantly share code, notes, and snippets.

@noaione
Last active May 10, 2023 01:54
Show Gist options
  • Save noaione/818ea08274a2e03975e64fd553274eb1 to your computer and use it in GitHub Desktop.
Save noaione/818ea08274a2e03975e64fd553274eb1 to your computer and use it in GitHub Desktop.
src/components/Dialogs/GenericDialog.vue
<template>
<v-dialog
:model-value="model"
:fullscreen="$vuetify.display.mobile"
:height="$vuetify.display.mobile ? undefined : 'auto'"
:width="$vuetify.display.mobile ? undefined : '70vw'"
@after-leave="emit('close')">
<v-card :loading="isLoading" height="100%" class="d-flex flex-column">
<slot name="loader" />
<v-toolbar color="transparent">
<template v-if="slots.toolbarPrepend" #prepend>
<slot name="toolbarPrepend" />
</template>
<template #append>
<v-btn icon @click="model = false">
<i-mdi-close />
</v-btn>
</template>
<v-toolbar-title>
{{ title }}
</v-toolbar-title>
</v-toolbar>
<v-card-subtitle v-if="subtitle" class="pb-3">
{{ subtitle }}
</v-card-subtitle>
<v-divider />
<slot />
<v-divider v-if="slots.actions" />
<v-card-actions
v-if="slots.actions"
class="d-flex align-center pa-3"
:class="{
'justify-end': !$vuetify.display.mobile,
'justify-center': $vuetify.display.mobile
}">
<slot name="actions" />
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup lang="ts">
import { computed, defineProps, ref, useSlots } from 'vue';
const props = defineProps<{
modelValue: boolean;
title: string;
subtitle?: string;
isLoading?: boolean;
}>();
const emit = defineEmits<{
(e: 'close'): void;
}>();
const slots = useSlots();
const model = ref(props.modelValue);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment