-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathindex.html
110 lines (102 loc) · 4.24 KB
/
index.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>details-menu demo</title>
<style>
details-menu {
background: white;
border: 1px solid;
display: block;
padding: 4px;
width: 200px;
}
button,
label[tabindex] {
font-family: inherit;
font-size: inherit;
display: block;
background: none;
border: 0;
width: 100%;
text-align: left;
padding: 0;
}
[aria-disabled="true"] {
color: gray;
}
</style>
</head>
<body>
<h1>Examples</h1>
<h2>Base examples</h2>
<details>
<summary>Best robot: <span data-menu-button>Unknown</span></summary>
<details-menu>
<button type="button" role="menuitem" data-menu-button-text>Hubot</button>
<button type="button" role="menuitem" data-menu-button-text>Bender</button>
<button type="button" role="menuitem" data-menu-button-text>BB-8</button>
</details-menu>
</details>
<details>
<summary>Best robot: <span data-menu-button>Unknown</span></summary>
<details-menu>
<label tabindex="0" role="menuitemradio" data-menu-button-text>
<span><input type="radio" name="robot" /> Hubot</span>
</label>
<label tabindex="0" role="menuitemradio" data-menu-button-text>
<span><input type="radio" name="robot" /> Bender</span>
</label>
<label tabindex="0" role="menuitemradio" data-menu-button-text>
<span><input type="radio" name="robot" /> BB-8</span>
</label>
</details-menu>
</details>
<details>
<summary>Favorite robots</summary>
<details-menu>
<label tabindex="0" role="menuitemcheckbox"><input type="checkbox" name="robot" /> Hubot</label>
<label tabindex="0" role="menuitemcheckbox"><input type="checkbox" name="robot" /> Bender</label>
<label tabindex="0" role="menuitemcheckbox"><input type="checkbox" name="robot" /> BB-8</label>
</details-menu>
</details>
<details>
<summary data-menu-button>Favorite robots</summary>
<details-menu>
<button type="submit" name="robot" value="Hubot" role="menuitemradio" data-menu-button-text>Hubot</button>
<button type="submit" name="robot" value="Bender" role="menuitemradio" data-menu-button-text>Bender</button>
<button type="submit" name="robot" value="BB-8" role="menuitemradio" data-menu-button-text>BB-8</button>
</details-menu>
</details>
<h2>`aria-disabled="true" example</h2>
<p>menu items with <code>aria-disabled="true"</code> should be keyboard navigable</p>
<details>
<summary data-menu-button autofocus>Least favorite robots</summary>
<details-menu>
<input type="text" autofocus />
<button name="robot" value="Hubot" aria-disabled="true" role="menuitemradio" data-menu-button-text>Hubot</button>
<button name="robot" value="Bender" role="menuitemradio" data-menu-button-text>Bender</button>
<button name="robot" value="BB-8" role="menuitemradio" data-menu-button-text>BB-8</button>
</details-menu>
</details>
<h2>Autofocus example</h2>
<p><code>summary</code> may have <code>autofocus</code> so it's the initially focused element in the page.</p>
<p>
Then any focusable element inside the popup can declare autofocus too, so it gets focus when the popup is opened.
</p>
<details>
<summary data-menu-button autofocus>Autofocus picker</summary>
<details-menu>
<input type="text" autofocus />
<button type="submit" name="robot" value="Hubot" role="menuitemradio" data-menu-button-text>Hubot</button>
<button type="submit" name="robot" value="Bender" role="menuitemradio" data-menu-button-text>Bender</button>
<button type="submit" name="robot" value="BB-8" role="menuitemradio" data-menu-button-text>BB-8</button>
</details-menu>
</details>
<script type="text/javascript">
document.addEventListener('details-menu-selected', e => console.log(e))
</script>
<!-- <script type="module" src="../dist/index.js"></script> -->
<script type="module" src="https://unpkg.com/@github/details-menu-element@latest?module"></script>
</body>
</html>