Skip to content

Commit 164ee85

Browse files
committed
feat: add popconfirm for cache clear
1 parent 2a7a444 commit 164ee85

3 files changed

Lines changed: 434 additions & 14 deletions

File tree

‎web/src/components/MPopconfirm.vue‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<script setup lang="ts">
2+
import MPopover from '@/components/MPopover.vue';
3+
4+
type PopconfirmPlacement =
5+
| 'top'
6+
| 'top-start'
7+
| 'top-end'
8+
| 'right'
9+
| 'bottom'
10+
| 'bottom-start'
11+
| 'bottom-end'
12+
| 'left';
13+
14+
withDefaults(
15+
defineProps<{
16+
title?: string;
17+
message?: string;
18+
confirmText?: string;
19+
cancelText?: string;
20+
placement?: PopconfirmPlacement;
21+
}>(),
22+
{
23+
title: 'Are you sure?',
24+
message: '',
25+
confirmText: 'Confirm',
26+
cancelText: 'Cancel',
27+
placement: 'bottom-end',
28+
},
29+
);
30+
31+
const emit = defineEmits<{
32+
confirm: [];
33+
cancel: [];
34+
}>();
35+
36+
const handleConfirm = (close: () => void) => {
37+
emit('confirm');
38+
close();
39+
};
40+
41+
const handleCancel = (close: () => void) => {
42+
emit('cancel');
43+
close();
44+
};
45+
</script>
46+
47+
<template>
48+
<MPopover :placement="placement" :offset="8" class="min-w-220px">
49+
<template #trigger="{ open, close, toggle, linkPopover }">
50+
<slot
51+
name="trigger"
52+
:open="open"
53+
:close="close"
54+
:toggle="toggle"
55+
:link-popover="linkPopover"
56+
/>
57+
</template>
58+
<template #default="{ close }">
59+
<div p-10px @click.stop>
60+
<div text-gray-900 text-14px font-600 leading-20px whitespace-nowrap>
61+
{{ title }}
62+
</div>
63+
<div
64+
v-if="message"
65+
max-w-260px
66+
mt-4px
67+
text-gray-600
68+
text-12px
69+
leading-18px
70+
>
71+
{{ message }}
72+
</div>
73+
<div flex justify-end gap-8px mt-12px>
74+
<div
75+
h-26px
76+
box-border
77+
px-10px
78+
b-1px
79+
b-solid
80+
b-gray-200
81+
rounded-4px
82+
bg-white
83+
text-gray-700
84+
text-12px
85+
leading-24px
86+
cursor-pointer
87+
transition-colors
88+
hover="b-gray-400 bg-gray-50"
89+
@click="handleCancel(close)"
90+
>
91+
{{ cancelText }}
92+
</div>
93+
<div
94+
h-26px
95+
box-border
96+
px-10px
97+
b-1px
98+
b-solid
99+
b-red-500
100+
rounded-4px
101+
bg-red-500
102+
text-white
103+
text-12px
104+
leading-24px
105+
cursor-pointer
106+
transition-colors
107+
hover="b-red-600 bg-red-600"
108+
@click="handleConfirm(close)"
109+
>
110+
{{ confirmText }}
111+
</div>
112+
</div>
113+
</div>
114+
</template>
115+
</MPopover>
116+
</template>

0 commit comments

Comments
 (0)