Skip to content

Commit

Permalink
feat: add dialog component
Browse files Browse the repository at this point in the history
  • Loading branch information
kingyue737 committed Jan 24, 2024
1 parent 2173a07 commit 7538522
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 132 deletions.
60 changes: 60 additions & 0 deletions components/DialogConfirm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script lang="ts">
export default defineComponent({
data: () => ({
dialog: false,
confirmed: false,
resolve: (confirmed: boolean) => {
confirmed
},
reject: (val: unknown) => {
val
},
message: '',
}),
watch: {
dialog(value) {
if (value === false) {
this.resolve(this.confirmed)
}
},
},
methods: {
open(message: string) {
this.confirmed = false
this.dialog = true
this.message = message
return new Promise<boolean>((resolve, reject) => {
this.resolve = resolve
this.reject = reject
})
},
confirm() {
this.confirmed = true
this.dialog = false
},
cancel() {
this.confirmed = false
this.dialog = false
},
},
})
</script>

<template>
<v-dialog v-model="dialog" max-width="400px">
<v-card style="z-index: -1">
<!-- <v-card-title class="font-weight-bold d-flex justify-center pt-5">
</v-card-title> -->
<v-card-text class="font-weight-bold d-flex">
<v-icon class="mr-2" color="warning">$warning</v-icon>
<span>{{ message }}</span>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary darken-1" @click="cancel">Cancel</v-btn>
<v-btn color="primary darken-1" @click="confirm">Confirm</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
</v-dialog>
</template>
3 changes: 0 additions & 3 deletions components/PageWrapper.vue

This file was deleted.

127 changes: 0 additions & 127 deletions pages/labs.vue

This file was deleted.

2 changes: 1 addition & 1 deletion pages/nested.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ definePageMeta({
})
</script>
<template>
<PageWrapper />
<NuxtPage />
</template>
2 changes: 1 addition & 1 deletion pages/nested/menu2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ definePageMeta({
})
</script>
<template>
<PageWrapper />
<NuxtPage />
</template>
Loading

0 comments on commit 7538522

Please sign in to comment.