-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShowModal.vue
More file actions
83 lines (77 loc) · 1.84 KB
/
ShowModal.vue
File metadata and controls
83 lines (77 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
<div class="modal-demo">
<CodeBlock
v-if="type === 'default'"
:compare="false"
>
<template #preview>
<PUButton @click="show">
show
</PUButton>
<PUModal>
<template #header>
<h2 class="text-xl font-bold">
Demo Modal
</h2>
</template>
<template #content>
<p>Modal content preview with interactive demo</p>
</template>
<template #footer>
<PUButton @click="hide">
Close Preview
</PUButton>
</template>
</PUModal>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
<CodeBlock
v-else
:compare="false"
>
<template #preview>
<PUButton @click="show">
show
</PUButton>
<PUModal v-if="isVisible">
<template #header>
<h2 class="text-2xl">
Custom Header
</h2>
</template>
<template #content>
<div class="custom-content">
<PUIcon name="info" />
<p>Custom modal content here</p>
</div>
</template>
<template #footer>
<div class="flex gap-2">
<PUButton @click="hide">
Confirm
</PUButton>
<PUButton
flavor="ghost"
@click="hide"
>
Cancel
</PUButton>
</div>
</template>
</PUModal>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
</div>
</template>
<script lang="ts" setup>
defineProps<{
type: 'default' | 'custom'
}>()
const { show, hide, isVisible } = useModal()
</script>