main
vue 39 lines 1.01 KB
Raw
1 <template>
2 <n-button size="small" type="primary" secondary :loading @click="showForm = true">
3 <div class="flex items-center gap-2">
4 <Icon :name="DangerIcon" :size="18" />
5 <span class="xs:block hidden">Custom Alert</span>
6 </div>
7 </n-button>
8
9 <n-modal
10 v-model:show="showForm"
11 display-directive="show"
12 preset="card"
13 :style="{ maxWidth: 'min(600px, 90vw)', minHeight: 'min(300px, 90vh)', overflow: 'hidden' }"
14 title="Create a Custom Alert"
15 :bordered="false"
16 segmented
17 >
18 <CustomAlertForm v-model:loading="loading" @mounted="formCTX = $event" />
19 </n-modal>
20 </template>
21
22 <script setup lang="ts">
23 import { NButton, NModal } from "naive-ui"
24 import { ref, watch } from "vue"
25 import Icon from "@/components/common/Icon.vue"
26 import CustomAlertForm from "./CustomAlertForm.vue"
27
28 const DangerIcon = "majesticons:exclamation-line"
29
30 const formCTX = ref<{ reset: () => void } | null>(null)
31 const showForm = ref(false)
32 const loading = ref(false)
33
34 watch(showForm, val => {
35 if (val) {
36 formCTX.value?.reset()
37 }
38 })
39 </script>