Skip to content

Commit 5f6c00f

Browse files
committed
Various improvements to guides
1 parent 41b8cc6 commit 5f6c00f

File tree

8 files changed

+121
-53
lines changed

8 files changed

+121
-53
lines changed

apps/components_guide_web/assets/css/app.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ blockquote {
102102
}
103103
hr {
104104
margin: var(--separator-spacing);
105-
color: var(--separator-color);
105+
border-color: var(--separator-color);
106+
opacity: var(--separator-opacity);
106107
}
107108

108109
input {
@@ -136,6 +137,7 @@ pre {
136137
--blockquote-background: rgba(255, 255, 255, 0.1);
137138
--separator-spacing: var(--size-5xl) 0;
138139
--separator-color: currentColor;
140+
--separator-opacity: 0.333;
139141
}
140142

141143
.row {

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/_nav.html.eex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<ul y-y x-x=md class="text-lg font-bold text-shadow" style="--link-padding: 0.75em">
33
<li><%= link("Why?", to: '/accessibility-first') %>
44
<li><%= link("Navigation", to: '/accessibility-first/navigation') %>
5-
<li><%= link("Roles", to: '/accessibility-first/roles') %>
6-
<li><%= link("Accessible Name", to: '/accessibility-first/accessible-name') %>
5+
<li><%= link("Content", to: '/accessibility-first/content') %>
76
<li><%= link("Forms", to: '/accessibility-first/forms') %>
7+
<li><%= link("All Roles", to: '/accessibility-first/roles') %>
8+
<li><%= link("Accessible Name", to: '/accessibility-first/accessible-name') %>
89
<li><%= link("Properties", to: '/accessibility-first/properties-cheatsheet') %>
9-
<li><%= link("Content", to: '/accessibility-first/content') %>
1010
</ul>
1111
</nav>

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/content.html.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,51 @@
1-
# Content
1+
# Semantic Content
22

3-
Coming soon…
3+
<table class="text-left table-fixed">
4+
<caption class="text-3xl pb-4 text-left">Content roles cheatsheet</caption>
5+
<thead>
6+
<tr>
7+
<th style="width: 12em">Role name</th>
8+
<th>HTML element</th>
9+
</tr>
10+
</thead>
11+
<tbody class="text-white bg-purple-900 border border-purple-700">
12+
<%= table_rows([
13+
["**link**", "`<a href=…>`"],
14+
["_none!_", "`<a>`"],
15+
["**heading**", "`<h1>`, `<h2>`, `<h3>`, etc"],
16+
["**list**", "`<ul>`, `<ol>`"],
17+
["**listitem**", "`<li>`"],
18+
["**term**", "`<dt>`"],
19+
["**definition**", "`<dd>`"],
20+
["**img**", "`<img alt=\"Some description\">`"],
21+
["_none!_", "`<img alt=\"\">`"],
22+
["**figure**", "`<figure>`"],
23+
["**separator**", "`<hr>`, `<li role=separator>`"],
24+
["_none!_", "`<p>`"],
25+
["_none!_", "`<div>`"],
26+
["_none!_", "`<span>`"],
27+
["**group**", "`<details>`"],
28+
["**button**", "`<summary>`"],
29+
]) %>
30+
</tbody>
31+
</table>
32+
33+
## Search engines and other crawlers
34+
35+
A crawler service that visits your website on behalf of a search engine like Google or social network like Instagram expects semantic content.
36+
37+
Semantic HTML elements allow meaning and structure to be determined.
38+
39+
More coming soon…
440

541
## Headings
642

743
## Lists
844

945
## Term & Definition
1046

47+
## Images
48+
1149
## Figure
1250

1351
## Details & Summary

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/forms.html.md

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
# Accessible Forms with Tests
2+
3+
<table class="text-left table-fixed">
4+
<caption class="text-3xl pb-4 text-left">Form roles cheatsheet</caption>
5+
<thead>
6+
<tr>
7+
<th style="width: 12em">Role name</th>
8+
<th>HTML snippet</th>
9+
</tr>
10+
</thead>
11+
<tbody class="text-white bg-purple-900 border border-purple-700">
12+
<%= table_rows([
13+
["**form**", "`<form>`"],
14+
["**search**", "`<form role=search>`"],
15+
["**group**", "`<fieldset>`"],
16+
["**button**", "`<button>`"],
17+
["**button**", "`<input type=button>`"],
18+
["**button**", "`<button type=submit>`, `<input type=submit>`"],
19+
["**textbox**", "`<textarea>`"],
20+
["**textbox**", "`<input type=text>`"],
21+
["**textbox**", "`<input type=email>`"],
22+
["**textbox**", "`<input type=tel>`"],
23+
["**textbox**", "`<input type=url>`"],
24+
["**searchbox**", "`<input type=search>` without `list` attribute"],
25+
["**radiogroup**", "`<fieldset role=radiogroup>`"],
26+
["**radio**", "`<input type=radio>`"],
27+
["**checkbox**", "`<input type=checkbox>`"],
28+
["**combobox**", "`<select>` without `multiple` attribute"],
29+
["**listbox**", "`<select>` with `multiple` attribute"],
30+
["**option**", "`<option>`"],
31+
["**slider**", "`<input type=range>`"],
32+
["_none_", "`<input type=password>`"],
33+
["**progressbar**", "`<progress>`"],
34+
["**status**", "`<output>`"],
35+
]) %>
36+
</tbody>
37+
</table>
38+
39+
_Note: The code examples here use [Testing Library](https://testing-library.com/), which works with React, Vue, Preact, Angular, Puppeteer, and more._
40+
41+
----
42+
143
## Form
244

345
```html
@@ -8,17 +50,19 @@
850
```
951

1052
```js
11-
getByRole('form', { name: 'Sign up' });
53+
screen.getByRole('form', { name: 'Sign up' });
1254
```
1355

56+
----
57+
1458
## Button
1559

1660
```html
1761
<button>Save</button>
1862
```
1963

2064
```js
21-
getByRole('button', { name: 'Save' });
65+
screen.getByRole('button', { name: 'Save' });
2266
```
2367

2468
### Disabled
@@ -28,17 +72,19 @@ getByRole('button', { name: 'Save' });
2872
```
2973

3074
```js
31-
expect(getByRole('button', { name: 'Save' })).toBeDisabled();
75+
expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
3276
```
3377

78+
----
79+
3480
## Textbox
3581

3682
```html
3783
<label>Name <input type=text></label>
3884
```
3985

4086
```js
41-
getByRole('textbox', { name: 'Name' });
87+
screen.getByRole('textbox', { name: 'Name' });
4288
```
4389

4490
### Multilined
@@ -48,7 +94,7 @@ getByRole('textbox', { name: 'Name' });
4894
```
4995

5096
```js
51-
getByRole('textbox', { name: 'Bio' });
97+
screen.getByRole('textbox', { name: 'Bio' });
5298
```
5399

54100
### Specific types
@@ -60,9 +106,9 @@ getByRole('textbox', { name: 'Bio' });
60106
```
61107

62108
```js
63-
const emailTextbox = getByRole('textbox', { name: 'Email' });
64-
const websiteTextbox = getByRole('textbox', { name: 'Website' });
65-
const phoneTextbox = getByRole('textbox', { name: 'Phone' });
109+
const emailTextbox = screen.getByRole('textbox', { name: 'Email' });
110+
const websiteTextbox = screen.getByRole('textbox', { name: 'Website' });
111+
const phoneTextbox = screen.getByRole('textbox', { name: 'Phone' });
66112
```
67113

68114
### Expect value to match
@@ -73,28 +119,32 @@ const phoneTextbox = getByRole('textbox', { name: 'Phone' });
73119

74120
```js
75121
expect(
76-
getByRole('textbox', { name: 'Bio' })
122+
screen.getByRole('textbox', { name: 'Bio' })
77123
).toHaveValue("Some bio");
78124
```
79125

126+
----
127+
80128
## Searchbox
81129

82130
```html
83131
<label>Search <input type=search></label>
84132
```
85133

86134
```js
87-
getByRole('searchbox', { name: 'Search' });
135+
screen.getByRole('searchbox', { name: 'Search' });
88136
```
89137

138+
----
139+
90140
## Checkbox
91141

92142
```html
93143
<label><input type=checkbox> Receive email alerts</label>
94144
```
95145

96146
```js
97-
getByRole('checkbox', { name: 'Receive email alerts' });
147+
screen.getByRole('checkbox', { name: 'Receive email alerts' });
98148
```
99149

100150
### Expect to be checked
@@ -105,10 +155,11 @@ getByRole('checkbox', { name: 'Receive email alerts' });
105155

106156
```js
107157
expect(
108-
getByRole('checkbox', { name: 'Receive email alerts' })
158+
screen.getByRole('checkbox', { name: 'Receive email alerts' })
109159
).toBeChecked();
110160
```
111161

162+
----
112163

113164
## Radio & Radiogroup
114165

@@ -123,15 +174,15 @@ expect(
123174
```
124175

125176
```js
126-
getByRole('radiogroup', { name: 'Favorite color' });
177+
screen.getByRole('radiogroup', { name: 'Favorite color' });
127178
```
128179

129180
```js
130-
expect(getByRole('radio', { name: 'Red' })).toBeChecked();
181+
expect(screen.getByRole('radio', { name: 'Red' })).toBeChecked();
131182
```
132183

133184
```js
134185
expect(
135-
getByRole('radiogroup', { name: 'Favorite color' })
186+
screen.getByRole('radiogroup', { name: 'Favorite color' })
136187
).toHaveFormValues({ 'fave-color': 'red' });
137188
```
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# Why Consider Accessibility First?
22

3-
A mobile-first approach ensures that a phone experience, which many users now prefer and use regularly, is prioritised and is great. It helps combat the natural tendency for the mobile experience to be left behind.
3+
A mobile-first approach ensures that a phone experience, which many users now prefer and use regularly, is prioritised and is great. This approach helps combat the natural tendency for the mobile experience to be left behind.
44

5-
Similarly, an accessibility-first experience that the accessible experience, using screen readers and other assistive tech, is prioritised and is great.
5+
Similarly, an accessibility-first experience ensures that the experience using screen readers and other assistive tech is prioritised and is great.
66

7-
But the benefit goes further. Developers can use the accessibility affordances to write automated tests. And if they ensure it’s accessible right away, it provides predictable ways to write the tests upfront.
7+
But the benefit goes further, as developers can use the accessibility affordances to write automated tests. And if what they make is accessible immediately, it provides predictable ways to write the tests upfront. This leads to quicker development and greater reliability.
88

99
## Consider your HTML, no matter your framework
1010

1111
HTML is not an after-thought, it’s not a ‘solved problem’, it’s not something you learn once and never have to study again. Especially in the world of web apps, it’s worth surveying the capabilities of today’s HTML and the affordances it can bring to every user.
1212

1313
## Accessibility Checklist for HTML
1414

15-
1. **Landmarks:** provide familiar touch points that users can jump to
16-
2. **Semantics & Roles:** give every element semantic meaning
17-
3. **Widgets:** allow everyone to use your controls
18-
4. **Attributes:** sometimes sprinkling aria- attributes everywhere makes things less accessible
15+
1. **Links vs Buttons:** use links for navigating and buttons for actions.
16+
1. **Landmarks:** provide familiar touch points that users can jump to.
17+
2. **Semantics & Roles:** give every element semantic meaning.
18+
3. **Widgets:** allow everyone to use your controls.
19+
4. **Properties:** hide or mark elements using accessibility attributes.

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/landmarks.html.md

Whitespace-only changes.

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/navigation.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Navigation elements
1+
# Accessible Navigation
22

33
## Link vs Button
44

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/roles.html.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
## Available Roles
22

3-
<table class="text-left table-fixed">
4-
<thead>
5-
<tr>
6-
<th style="width: 12em">Role name</th>
7-
<th>HTML element</th>
8-
</tr>
9-
</thead>
10-
<tbody class="text-white bg-purple-900 border border-purple-700">
11-
<%= table_rows([
12-
["**link**", "`<a href=…>`"],
13-
["_none_", "`<a>`"],
14-
["**button**", "`<button>`"],
15-
["**button**", "`<input type=button>`"],
16-
["**textbox**", "`<textarea>`"],
17-
["**textbox**", "`<input type=text>`"],
18-
["**radio**", "`<input type=radio>`"],
19-
["**heading**", "`<h1>`"],
20-
["**heading**", "`<h2>`"],
21-
["**heading**", "`<h3>`"],
22-
["**document**", "`<body>`"],
23-
]) %>
24-
</tbody>
25-
</table>
26-
273
<table class="text-left table-fixed">
284
<caption class="text-2xl">Landmarks</caption>
295
<thead>

0 commit comments

Comments
 (0)