-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ARIA roles to child content container (#315)
* initial add of choice children example for React (WIP) * Add checkedChildren to the choice example and remove from choiceList. * Add ARIA roles to container of checkedChildren * Update example radio names and values * Fix jest snapshot of Month picker * Update choice example - add fieldsets and make naming consistent. * Explicitly set the locale to 'en' in the snapshot test for MonthPicker
- Loading branch information
Showing
4 changed files
with
146 additions
and
43 deletions.
There are no files selected for viewing
96 changes: 79 additions & 17 deletions
96
packages/core/src/components/ChoiceList/Choice.example.jsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,94 @@ | ||
import Choice from './Choice'; | ||
import ChoiceList from './ChoiceList'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const selectChoices = [ | ||
{ label: 'A', value: 'A' }, | ||
{ defaultChecked: true, label: 'B', value: 'B' }, | ||
{ label: 'C', value: 'C' }, | ||
{ label: 'D', value: 'D' }, | ||
{ label: 'E', value: 'E' }, | ||
{ label: 'F', value: 'F' }, | ||
{ label: 'G', value: 'G' }, | ||
{ label: 'H', value: 'H' } | ||
]; | ||
|
||
const childSelect = ( | ||
<ChoiceList | ||
choices={selectChoices} | ||
label="Select example" | ||
className="" | ||
name="select_choices_field" | ||
/> | ||
); | ||
|
||
ReactDOM.render( | ||
<div> | ||
<Choice | ||
defaultChecked | ||
hint="Checkbox A hint" | ||
name="checkbox_choice" | ||
value="a" | ||
> | ||
Checkbox A | ||
</Choice> | ||
<Choice name="checkbox_choice" value="b"> | ||
Checkbox B | ||
</Choice> | ||
<Choice name="checkbox_choice" value="c"> | ||
Checkbox C | ||
</Choice> | ||
<fieldset className="ds-c-fieldset"> | ||
<legend className="ds-c-label">Checkbox example</legend> | ||
<Choice | ||
defaultChecked | ||
hint="Checkbox A hint" | ||
name="checkbox_choice" | ||
value="a" | ||
> | ||
Checkbox A | ||
</Choice> | ||
<Choice name="checkbox_choice" value="b"> | ||
Checkbox B | ||
</Choice> | ||
<Choice name="checkbox_choice" value="c"> | ||
Checkbox C | ||
</Choice> | ||
</fieldset> | ||
|
||
<fieldset className="ds-c-fieldset"> | ||
<legend className="ds-c-label">Checkbox example with children</legend> | ||
<Choice | ||
hint="Checkbox A hint" | ||
defaultChecked | ||
name="checkbox_choice_children" | ||
value="a" | ||
> | ||
Checkbox A | ||
</Choice> | ||
<Choice | ||
name="checkbox_choice_children" | ||
value="b" | ||
checkedChildren={childSelect} | ||
> | ||
Checkbox B - with children | ||
</Choice> | ||
<Choice name="checkbox_choice_children" value="c"> | ||
Checkbox C | ||
</Choice> | ||
</fieldset> | ||
|
||
<div className="ds-u-margin-top--4"> | ||
<Choice defaultChecked name="radio_choice" type="radio" value="a"> | ||
<fieldset className="ds-c-fieldset"> | ||
<legend className="ds-c-label">Radio example</legend> | ||
<Choice name="radio_choice" type="radio" value="a"> | ||
Radio A | ||
</Choice> | ||
<Choice name="radio_choice" type="radio" value="b"> | ||
Radio B | ||
</Choice> | ||
</div> | ||
</fieldset> | ||
|
||
<fieldset className="ds-c-fieldset"> | ||
<legend className="ds-c-label">Radio example with children</legend> | ||
<Choice name="radio_choice_children" type="radio" value="c"> | ||
Radio A | ||
</Choice> | ||
<Choice | ||
name="radio_choice_children" | ||
type="radio" | ||
value="d" | ||
checkedChildren={childSelect} | ||
> | ||
Radio B - with children | ||
</Choice> | ||
</fieldset> | ||
</div>, | ||
document.getElementById('js-example') | ||
); |
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
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
Oops, something went wrong.