-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo7.html
More file actions
68 lines (60 loc) · 1.42 KB
/
demo7.html
File metadata and controls
68 lines (60 loc) · 1.42 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
<html>
<head>
<meta charset="UTF-8">
<title>Top Layer:showPopover() でカレンダーを Top Layer に配置する</title>
<link rel="stylesheet" href="https://esm.sh/flatpickr/dist/flatpickr.min.css">
<style>
body {
font-family: sans-serif;
}
dialog {
padding: 32px;
border: 1px solid #ccc;
max-width: 380px;
}
dialog::backdrop {
background: rgb(0 0 0 / 0.4);
}
.modal-content {
display: flex;
flex-direction: column;
gap: 1rem;
}
#calendar-popover {
position: fixed;
inset: 0;
padding: 0;
border: 0;
width: 100%;
height: 100%;
background: transparent;
}
</style>
<script type="module">
import flatpickr from 'https://esm.sh/flatpickr';
const calendarPopover = document.getElementById('calendar-popover');
const fp = flatpickr('#datepicker', {
onReady(_, __, fp) {
calendarPopover.appendChild(fp.calendarContainer);
},
onOpen(_, __, fp) {
calendarPopover.showPopover();
},
onClose() {
calendarPopover.hidePopover();
},
});
</script>
</head>
<body>
<button onclick="modal7.showModal()">モーダルを開く</button>
<dialog id="modal7">
<div class="modal-content">
<p>日付を選択してください。カレンダーが Top Layer に表示されます。</p>
<input id="datepicker" type="text" placeholder="日付を選択">
<button autofocus onclick="modal7.close()">閉じる</button>
</div>
</dialog>
<div id="calendar-popover" popover="manual"></div>
</body>
</html>