Skip to content

Commit

Permalink
Welcome guide: Improve a11y of page controls
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Nov 22, 2019
1 parent 7748caa commit 0ce1ee1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
19 changes: 12 additions & 7 deletions packages/nux/src/components/guide/page-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { times } from 'lodash';
/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { IconButton } from '@wordpress/components';

/**
Expand All @@ -15,14 +16,18 @@ import { PageControlIcon } from './icons';

export default function PageControl( { currentPage, numberOfPages, setCurrentPage } ) {
return (
<div className="nux-guide__page-control">
<ul className="nux-guide__page-control" aria-label={ __( 'Guide controls' ) }>
{ times( numberOfPages, ( page ) => (
<IconButton
key={ page }
icon={ <PageControlIcon isSelected={ page === currentPage } /> }
onClick={ () => setCurrentPage( page ) }
/>
<li key={ page }>
<IconButton
key={ page }
icon={ <PageControlIcon isSelected={ page === currentPage } /> }
/* translators: %1$d: current page number %2$d: total number of pages */
aria-label={ sprintf( __( 'Page %1$d of %2$d' ), page + 1, numberOfPages ) }
onClick={ () => setCurrentPage( page ) }
/>
</li>
) ) }
</div>
</ul>
);
}
9 changes: 7 additions & 2 deletions packages/nux/src/components/guide/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@
}

&__page-control {
display: flex;
margin: 0;

.components-button {
li {
display: inline-block;
margin: 0 2px;
}

.components-icon-button {
height: 30px;
}
}

&__back-button,
Expand Down

0 comments on commit 0ce1ee1

Please sign in to comment.