Skip to content

Commit 414e7b6

Browse files
committed
Improve accessible content article
1 parent 87ab4a0 commit 414e7b6

File tree

1 file changed

+23
-11
lines changed
  • apps/components_guide_web/lib/components_guide_web/templates/accessibility_first

1 file changed

+23
-11
lines changed

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function* surroundingSourceElements(el) {
4545

4646
const outputEls = document.querySelectorAll('article output');
4747

48-
function colorFor(index) {
49-
return ['orange-500', 'purple-500', 'green-500'][index];
48+
function classNamesFor(index) {
49+
return ['border-yellow-500', 'border-green-500 border-dotted', 'border-purple-500 border-double'][index].split(' ');
5050
}
5151

5252
for (const outputEl of outputEls.values()) {
@@ -65,13 +65,13 @@ for (const outputEl of outputEls.values()) {
6565
}
6666

6767
if (type === 'javascript') {
68-
const color = colorFor(javascriptIndex);
68+
const classNames = classNamesFor(javascriptIndex);
6969

70-
el.classList.add('border-l-4', `border-${color}`);
70+
el.classList.add('border-l-4', ...classNames);
7171

7272
const screen = DOMTesting.within(div);
7373
const testFunction = new Function('screen', `return ${code}`);
74-
testFunction(screen).classList.add('border-2', `border-${color}`);
74+
[].concat(testFunction(screen)).forEach(el => el.classList.add('border-4', ...classNames));
7575

7676
javascriptIndex++;
7777
}
@@ -167,19 +167,31 @@ screen.getByRole('list');
167167

168168
```html
169169
<dl>
170-
<dt>Name</dt>
171-
<dd>The Lion King</dd>
170+
<dt id=movie-1-name>Name</dt>
171+
<dd aria-labelledby=movie-1-name>The Lion King</dd>
172172

173-
<dt>Year Released</dt>
174-
<dd>1994</dd>
173+
<dt id=movie-1-year>Year Released</dt>
174+
<dd aria-labelledby=movie-1-year>1994</dd>
175175

176-
<dt>Runtime</dt>
177-
<dd>88 min</dd>
176+
<dt id=movie-1-runtime>Runtime</dt>
177+
<dd aria-labelledby=movie-1-runtime>88 min</dd>
178178
</dl>
179179
```
180180

181181
<output></output>
182182

183+
```javascript
184+
screen.getByRole('definition', { name: 'Name' });
185+
```
186+
187+
```javascript
188+
screen.getByRole('definition', { name: 'Year Released' });
189+
```
190+
191+
```javascript
192+
screen.getByRole('definition', { name: 'Runtime' });
193+
```
194+
183195
## Images
184196

185197
```html

0 commit comments

Comments
 (0)