-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathExampleDialog.vue
74 lines (66 loc) · 1.41 KB
/
ExampleDialog.vue
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
<script setup lang="ts">
import { ref } from 'vue'
import {
VueScrollPicker,
VueScrollPickerOption,
VueScrollPickerValue,
} from 'vue-scroll-picker'
import CurrentValue from './CurrentValue.vue'
defineProps<{
options: VueScrollPickerOption[]
}>()
const currentValue = ref<VueScrollPickerValue>(null)
function handleClick() {
const dialog = document.querySelector('dialog')
dialog?.showModal()
}
function handleClose() {
const dialog = document.querySelector('dialog')
dialog?.close()
}
</script>
<template>
<div>
<div class="controller">
<CurrentValue :value="currentValue" />
<button type="button" class="button" @click="handleClick">
Open Dialog
</button>
</div>
<dialog>
<VueScrollPicker v-model="currentValue" :options="options" />
<button type="button" class="button" @click="handleClose">
Close Dialog
</button>
</dialog>
</div>
</template>
<style scoped>
dialog {
width: 600px;
transition: all 0.3s allow-discrete;
border: 0;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
outline: none;
}
dialog::backdrop {
transition: all 0.3s allow-discrete;
background-color: rgba(0, 0, 0, 0.2);
opacity: 0;
}
dialog[open],
dialog[open]::backdrop {
opacity: 1;
}
@starting-style {
dialog[open],
dialog[open]::backdrop {
opacity: 0;
}
}
dialog:not([open]),
dialog:not([open])::backdrop {
opacity: 0;
}
</style>