Skip to content

Commit c708af1

Browse files
committed
Finish adding aria labels
1 parent cee22c3 commit c708af1

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

client/modules/User/components/Collection.jsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ const ShareURL = ({ value }) => {
5353
<button
5454
className="collection-share__button"
5555
onClick={() => setShowURL(!showURL)}
56+
aria-label="Show collection share URL"
5657
>
5758
<span>Share</span>
58-
<DropdownArrowIcon className="collection-share__arrow" />
59+
<DropdownArrowIcon className="collection-share__arrow" focusable="false" aria-hidden="true" />
5960
</button>
6061
{ showURL &&
6162
<div className="collection__share-dropdown">
@@ -97,8 +98,9 @@ class CollectionItemRowBase extends React.Component {
9798
<button
9899
className="collection-row__remove-button"
99100
onClick={this.handleSketchRemove}
101+
aria-label="Remove sketch from collection"
100102
>
101-
<RemoveIcon title="Remove" />
103+
<RemoveIcon focusable="false" aria-hidden="true" />
102104
</button>
103105
</td>
104106
</tr>);
@@ -295,21 +297,43 @@ class Collection extends React.Component {
295297
return null;
296298
}
297299

300+
_getButtonLabel = (fieldName, displayName) => {
301+
const { field, direction } = this.props.sorting;
302+
let buttonLabel;
303+
if (field !== fieldName) {
304+
if (field === 'name') {
305+
buttonLabel = `Sort by ${displayName} ascending.`;
306+
} else {
307+
buttonLabel = `Sort by ${displayName} descending.`;
308+
}
309+
} else if (direction === SortingActions.DIRECTION.ASC) {
310+
buttonLabel = `Sort by ${displayName} descending.`;
311+
} else {
312+
buttonLabel = `Sort by ${displayName} ascending.`;
313+
}
314+
return buttonLabel;
315+
}
316+
298317
_renderFieldHeader(fieldName, displayName) {
299318
const { field, direction } = this.props.sorting;
300319
const headerClass = classNames({
301320
'sketches-table__header': true,
302321
'sketches-table__header--selected': field === fieldName
303322
});
323+
const buttonLabel = this._getButtonLabel(fieldName, displayName);
304324
return (
305325
<th scope="col">
306-
<button className="sketch-list__sort-button" onClick={() => this.props.toggleDirectionForField(fieldName)}>
326+
<button
327+
className="sketch-list__sort-button"
328+
onClick={() => this.props.toggleDirectionForField(fieldName)}
329+
aria-label={buttonLabel}
330+
>
307331
<span className={headerClass}>{displayName}</span>
308332
{field === fieldName && direction === SortingActions.DIRECTION.ASC &&
309-
<ArrowUpIcon />
333+
<ArrowUpIcon role="img" aria-label="Ascending" focusable="false" />
310334
}
311335
{field === fieldName && direction === SortingActions.DIRECTION.DESC &&
312-
<ArrowDownIcon />
336+
<ArrowDownIcon role="img" aria-label="Descending" focusable="false" />
313337
}
314338
</button>
315339
</th>

client/modules/User/components/GithubButton.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function GithubButton(props) {
99
className="github-button"
1010
href="/auth/github"
1111
>
12-
<GithubIcon className="github-icon" />
12+
<GithubIcon className="github-icon" role="img" aria-label="GitHub Logo" focusable="false" />
1313
<span>{props.buttonText}</span>
1414
</a>
1515
);

client/modules/User/components/GoogleButton.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function GoogleButton(props) {
99
className="google-button"
1010
href="/auth/google/"
1111
>
12-
<GoogleIcon className="google-icon" />
12+
<GoogleIcon className="google-icon" role="img" aria-label="Google Logo" focusable="false" />
1313
<span>{props.buttonText}</span>
1414
</a>
1515
);

0 commit comments

Comments
 (0)