Created
July 15, 2022 16:08
-
-
Save connorrose/7ae8201200a8e61865d3da8b2da63920 to your computer and use it in GitHub Desktop.
A11y talk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bad Code | |
const No = () => ( | |
<div> | |
<DivSoup /> | |
<ForDinner /> | |
</div> | |
); | |
const DivSoup = () => ( | |
<div className="heading-1"> | |
Some Headline!! | |
</div> | |
); | |
const ForDinner = (checkboxes) => ( | |
<div> | |
Choices | |
{checkboxes.map((value, i) => ( | |
<div | |
className="fancy-checkbox" | |
onClick={handler} | |
> | |
{`Option ${i}`} | |
</div> | |
))} | |
<div onClick={submit}> | |
Submit | |
</div> | |
</div> | |
); | |
// Semantic Refactor | |
const No = () => ( | |
<> | |
<DivSoup /> | |
<ForDinner /> | |
</> | |
); | |
const DivSoup = () => ( | |
<h1> | |
Some Headline!! | |
</h1> | |
); | |
const ForDinner = (checkboxes) => ( | |
<form> | |
<fieldset> | |
<legend> | |
Choices | |
</legend> | |
{checkboxes.map(({ value, id }) => ( | |
<input | |
type="checkbox" | |
id={id} | |
name={value} | |
onClick={handler} | |
/> | |
<label htmlFor={id}> | |
{value} | |
</label> | |
))} | |
</fieldset> | |
<button type="submit" onClick={submit}> | |
Submit | |
</button> | |
</form> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment