Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button and link a11y docs #924

Merged
merged 52 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9c9f783
Button accessibility section
dpersing Jan 22, 2019
39d1b54
Fixed Android info placement
dpersing Jan 22, 2019
ecce3ec
Custom key events
dpersing Jan 22, 2019
b9f38f2
Changed key formatting for readability
dpersing Jan 22, 2019
1238cfe
Fixed link
dpersing Jan 22, 2019
ca9e383
Added accessibility section for the link component
dpersing Jan 22, 2019
016c57d
Added line Unreleased.md
dpersing Jan 22, 2019
6ccae15
Re-ordered examples for better flow/wrapping
dpersing Jan 22, 2019
85d1c9a
Removed the native content
dpersing Jan 22, 2019
0eb1e78
Added PR link
dpersing Jan 22, 2019
5da2eae
Update src/components/Button/README.md
kaelig Jan 24, 2019
48f099f
Update src/components/Button/README.md
dpersing Jan 24, 2019
af046ce
Update src/components/Link/README.md
dpersing Jan 24, 2019
e4bf84c
Update src/components/Link/README.md
dpersing Jan 24, 2019
ca42994
Merge branch 'master' into button-link-a11y-docs
dpersing Jan 25, 2019
be04b96
Update UNRELEASED.md
kaelig Jan 28, 2019
de37a49
Update src/components/Link/README.md
kaelig Jan 28, 2019
110e6dd
Update src/components/Link/README.md
kaelig Jan 28, 2019
5d9fab9
Update src/components/Button/README.md
kaelig Jan 28, 2019
e08834b
Update src/components/Button/README.md
kaelig Jan 28, 2019
b59337c
Update src/components/Link/README.md
kaelig Jan 28, 2019
94210c3
Update src/components/Link/README.md
sadieredden Jan 28, 2019
f4c5bde
Update src/components/Link/README.md
sadieredden Jan 28, 2019
d7beb60
Update src/components/Button/README.md
sadieredden Jan 28, 2019
2308160
Update src/components/Button/README.md
sadieredden Jan 28, 2019
1e04789
Update src/components/Button/README.md
sadieredden Jan 28, 2019
3e52023
Update src/components/Button/README.md
sadieredden Jan 28, 2019
f61415b
Update src/components/Button/README.md
dpersing Jan 28, 2019
2690df4
Update src/components/Button/README.md
sadieredden Jan 28, 2019
25feebc
Update src/components/Button/README.md
kaelig Jan 28, 2019
6375184
Update src/components/Button/README.md
kaelig Jan 28, 2019
ee89b26
Update src/components/Button/README.md
kaelig Jan 28, 2019
3670720
Update src/components/Button/README.md
kaelig Jan 28, 2019
c60a031
Update src/components/Button/README.md
kaelig Jan 28, 2019
2779012
Update src/components/Button/README.md
dpersing Jan 28, 2019
cda1178
Update src/components/Button/README.md
dpersing Jan 28, 2019
c20f01b
Update src/components/Link/README.md
kaelig Jan 28, 2019
a664e02
Update src/components/Link/README.md
kaelig Jan 28, 2019
d27cdfe
Update src/components/Link/README.md
kaelig Jan 28, 2019
3b9f974
Update src/components/Button/README.md
kaelig Jan 28, 2019
ebe8ddb
Merge branch 'master' into button-link-a11y-docs
dpersing Jan 28, 2019
023c599
Content and Prettier updates
dpersing Jan 30, 2019
ece28ed
Update src/components/Link/README.md
sadieredden Jan 30, 2019
f5ff638
Update src/components/Link/README.md
sadieredden Jan 30, 2019
f0c7e43
Merge branch 'master' into button-link-a11y-docs
dpersing Feb 7, 2019
1b536bb
Update src/components/Link/README.md
kaelig Feb 7, 2019
5a70def
Update src/components/Link/README.md
kaelig Feb 7, 2019
6ce31b7
Removed Structure heading and added item about ariaPressed/pressed
dpersing Feb 7, 2019
b602322
Restructured headings
dpersing Feb 7, 2019
e4f56cd
Tweaked guidance based on decision around the pressed prop
dpersing Feb 7, 2019
b75ec5c
Merge branch 'master' into button-link-a11y-docs
dpersing Feb 19, 2019
39c31e2
Merge branch 'master' into button-link-a11y-docs
dpersing Feb 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
### Documentation

- Added `Stack.Item` properties and description to [style guide](https://polaris.shopify.com)’s ([#772](https://github.com/Shopify/polaris-react/pull/772))
- Added accessibility documentation for the button and link components ([#924](https://github.com/Shopify/polaris-react/pull/924))
- Added accessibility documentation to the resource list and data table components ([#927](https://github.com/Shopify/polaris-react/pull/927))
- Added accessibility recommendations for the caption component ([#928](https://github.com/Shopify/polaris-react/pull/928/))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused as to why some of these unrelated entries are in this PR?


Expand Down
129 changes: 128 additions & 1 deletion src/components/Button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ keywords:

# Button

Buttons are used to make common actions immediately visible and easy to perform with one click or tap. Merchants can use it to navigate, or take action.
Buttons are used to make common actions immediately visible and easy to perform with one click, tap, or keypress. Merchants can use them to navigate or to take action.

---

Expand Down Expand Up @@ -289,3 +289,130 @@ Use when a button has been pressed and the associated action is in progress.

- To learn how to combine or lay out multiple buttons, [use the button group component](/components/actions/button-group)
- To embed an action into a line of text, [use the link component](/components/navigation/link)

---

## Accessibility

<!-- content-for: android -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS and Android content for the button page, since there are separate tabs. We don't currently have native-specific guidance so I've linked to the platform best practices.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's a bit awkward from the "Web" perspective to begin the section with external resources that don't apply to web, my understanding is that this will eventually change, when we have native-specific guidance.

To make it more clear what content applies to the reader:

  • We could add an intro sentence under the Accessibility heading that lets readers know that the accessibility guidelines for the button component differ for Web, Android, and iOS. This sets the reader up to expect to look for the content that applies to them.

  • Perhaps rearrange the leading sentences to start with "For Android, see Material Design ... " and "For iOS, see Apple's ..."

  • Perhaps add Android, iOS, and Web headings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sadiesaurus The sections here display on the web, iOS, and Android tabs in the UI in the style guide, which is what the <! content-for: ...> tags are doing in the file. The Mobile-specific example screenshot is showing what would show up for Android on that tab, while the other specific content shows up for each tab specified. That's what the first item in the 🎩 recommendations is doing, pulling from the PR that @kaelig worked on to do this formatting. Let me know if that's clear!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh, yes now I see. I didn't 🎩 it properly last time. This works well!

Please disregard my comment! 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that headings would help with the Markdown readability in GitHub itself. I couldn't find a solid and elegant way to make it work :/

@BPScott and I might have cycles to look into it later this year.


See Material Design and development documentation about accessibility for Android:

- [Accessible design on Android](https://material.io/design/usability/accessibility.html)
- [Accessible development on Android](https://developer.android.com/guide/topics/ui/accessibility/)

<!-- /content-for -->

<!-- content-for: ios -->

See Apple’s Human Interface Guidelines and API documentation about accessibility for iOS:

- [Accessible design on iOS](https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/accessibility/)
- [Accessible development on iOS](https://developer.apple.com/accessibility/ios/)

<!-- /content-for -->

<!-- content-for: web -->

### Structure

Buttons can have different states that are visually and programmatically conveyed to merchants.

- Use the `ariaControls` prop to add an `aria-controls` attribute to the button. Use the attribute to point to the unique `id` of the content that the button manages.
- If a button expands or collapses adjacent content, then use the `ariaExpanded` prop to add the `aria-expanded` attribute to the button. Set the value to convey the current expanded (`true`) or collapsed (`false`) state of the content.
- Use the `disabled` prop to set the `disabled` state of the button. This prevents merchants from being able to interact with the button, and conveys its inactive state to assistive technologies.

#### Navigation

Merchants generally expect buttons to submit data or take action, and for links to navigate. If navigation is required for the button component, use the `url` prop. The control will output an anchor styled as a button, instead of a button in HTML, to help convey this difference.

For more information on making accessible links, see the [link component](/components/navigation/link).

### Labeling

The `accessibilityLabel` prop adds an `aria-label` attribute to the button, which can be accessed by assistive technologies like screen readers. Typically, this label text replaces the visible text on the button for merchants who use assistive technology.

Use `accessibilityLabel` for a button if:

- The button’s visible text doesn’t adequately convey the purpose of the button to non-visual merchants
- The button has no text and relies on an icon alone to convey its purpose

To help support merchants who use speech activation software as well as sighted screen reader users, make sure that the `aria-label` text includes any button text that’s visible. Mismatches between visible and programmatic labeling can cause confusion, and might prevent voice recognition commands from working.

When possible, give the button visible text that clearly conveys its purpose without the use of `accessibilityLabel`. When no additional content is needed, duplicating the button text with `accessibilityLabel` isn’t necessary.

<!-- usageblock -->

#### Do

```jsx
<Button>Edit shipping address</Button>
```

```jsx
<Heading>Shipping address</Heading>
<Button accessibilityLabel="Edit shipping address">Edit</Button>
```

#### Don’t

```jsx
<Button accessibilityLabel="Change your shipping address">Edit</Button>
```

```jsx
<Button accessibilityLabel="Edit">Edit</Button>
```

<!-- end -->

#### External links

When you use the button component to create a link to an external resource:

- Use the `external` prop to make the link open in a new tab (or window, depending on the merchant’s browser settings)
- Use the `icon` prop to add the `external` icon to the button
- Use the `accessibilityLabel` prop to include the warning about opening a new tab in the button text for non-visual screen reader users

For more information on making accessible links, see the [link component](/components/navigation/link).

<!-- usageblock -->

#### Do

```jsx
<Button
accessibilityLabel="Terms and conditions (opens a new window)"
icon="external"
url="http://example.com"
external
>
Terms and conditions
</Button>
```

#### Don’t

```jsx
<Button url="http://example.com" external>Terms and conditions</Button>
<Button url="http://example.com" external>
Terms and conditions
</Button>
```

<!-- end -->

### Keyboard support

Buttons use browser defaults for keyboard interactions.

- Give buttons keyboard focus with the <kbd>tab</kbd> key (or <kbd>shift</kbd> + <kbd>tab</kbd> when tabbing backwards)
- Activate buttons with the <kbd>enter</kbd>/<kbd>return</kbd> key or the <kbd>space</kbd> key

#### Custom key events

Use the `onKeyDown`, `onKeyPress`, and `onKeyUp` props to create custom events for buttons. With these props, you can use buttons to create complex, custom interactions like drag-and-drop interfaces.

Since these props introduce non-standard features to buttons, make sure to include accessible instructions so that merchants can understand how to use these features.

<!-- /content-for -->
67 changes: 67 additions & 0 deletions src/components/Link/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,70 @@ Use for text links that are the same color as the surrounding text.
## Related components

- To create navigational actions that aren’t part of a line of text, [use the button component](/components/actions/button)

---

## Accessibility

<!-- content-for: web -->

### Structure

Use the `url` prop to give the link component a valid `href` value. This allows the element to be identified as a link to assistive technologies and gives it default keyboard support.

#### Submitting data

Merchants generally expect links to navigate, and not to submit data or take action. If you need a component that doesn’t have a URL associated with it, then use the [button component](/components/actions/button) instead.

### Labeling

Give links text that clearly describes their purpose.

To provide consistency and clarity:

- Use the same text for links that navigate to the same content
- Use different text for links that navigate to different content

<!-- usageblock -->

#### Do

```jsx
<Link url="https://help.shopify.com/manual">fulfilling orders</Link>
```

#### Don’t

```jsx
<Link>fulfilling orders</Link>
```

#### Don’t

```JSX
<Link url="https://help.shopify.com/manual">fulfilling orders</Link>
```

```JSX
<Link url="https://help.shopify.com/manual">order fulfillment section</Link>
```

<!-- end -->

#### External links

Use the `external` prop to make the link open in a new tab (or window, depending on the merchant’s browser settings). Open a page in a new tab only when opening a page in the same tab might disrupt the merchant’s workflow.

To make the external link functionality clear to all merchants:

- Use the [icon component](/components/images-and-icons/icon) to add the `external` icon to the link
- Use the `accessibilityLabel` on the icon prop to include the warning about opening a new tab in the button text for non-visual screen reader users

### Keyboard support

Links use browser defaults for keyboard interaction.

- Give links keyboard focus with the <kbd>tab</kbd> key (or <kbd>shift</kbd> + <kbd>tab</kbd> when tabbing backwards)
- Activate links with the <kbd>enter</kbd>/<kbd>return</kbd> key

<!-- /content-for -->