-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtab-order.stories.ts
More file actions
101 lines (96 loc) · 2.58 KB
/
tab-order.stories.ts
File metadata and controls
101 lines (96 loc) · 2.58 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { html } from 'lit';
import '../src/index.js';
export default {
title: 'TabOrder',
};
export const NoDelegateNoTabIndex = () => html`
<style>
.styled-div {
border-width: 1px;
border-color: green;
border-style: solid;
padding: 1rem;
margin: 1rem;
}
.styled-div:focus {
outline: 4px dashed green;
}
</style>
<ul>
<li>The whole component is skipped in tab order</li>
<li>
Can click on one of the divs inside, and then tab order works linearly.
</li>
</ul>
<div tabindex="0" class="styled-div">Before component</div>
<x-tab-order-no-delegate tabindex="-1"></x-tab-order-no-delegate>
<div tabindex="0" class="styled-div">After component</div>
`;
export const NoDelegateWithTabIndex = () => html`
<style>
.styled-div {
border-width: 1px;
border-color: green;
border-style: solid;
padding: 1rem;
margin: 1rem;
}
.styled-div:focus {
outline: 4px dashed green;
}
</style>
<ul>
<li>
Tab order stops on the component itself before going in. So, component is
added before (slotted) children in tab order.
</li>
</ul>
<div tabindex="0" class="styled-div">Before component</div>
<x-tab-order-no-delegate tabindex="0"></x-tab-order-no-delegate>
<div tabindex="0" class="styled-div">After component</div>
`;
export const DelegateNoTabIndex = () => html`
<style>
.styled-div {
border-width: 1px;
border-color: green;
border-style: solid;
padding: 1rem;
margin: 1rem;
}
.styled-div:focus {
outline: 4px dashed green;
}
</style>
<ul>
<li>Same behavior as NoDelegateNoTabIndex</li>
<li>The whole component is skipped in tab order</li>
<li>
Can click on one of the divs inside, and then tab order works linearly.
</li>
</ul>
<div tabindex="0" class="styled-div">Before component</div>
<x-tab-order-delegate tabindex="-1"></x-tab-order-delegate>
<div tabindex="0" class="styled-div">After component</div>
`;
export const DelegateWithTabIndex = () => html`
<style>
.styled-div {
border-width: 1px;
border-color: green;
border-style: solid;
padding: 1rem;
margin: 1rem;
}
.styled-div:focus {
outline: 4px dashed green;
}
</style>
<ul>
<li>Linear tab order, does not stop on the component itself.</li>
<li>What you want in most cases</li>
</ul>
<div tabindex="0" class="styled-div">Before component</div>
<x-tab-order-delegate tabindex="0"></x-tab-order-delegate>
<div tabindex="0" class="styled-div">After component</div>
`;