Merge pull request #283 from nolanlawson/nolan/issue-220-take-two

fix: makes skin tone picker more accessible
release
Nolan Lawson 2019-03-12 08:14:44 -07:00 committed by GitHub
commit 1347c1765a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 2 deletions

View File

@ -75,6 +75,14 @@ categories: {
custom: 'Custom',
},
categorieslabel: 'Emoji categories', // Accessible title for the list of categories
skintones: {
1: 'Default Skin Tone',
2: 'Light Skin Tone',
3: 'Medium-Light Skin Tone',
4: 'Medium Skin Tone',
5: 'Medium-Dark Skin Tone',
6: 'Dark Skin Tone',
},
```
#### Sheet sizes

View File

@ -35,6 +35,14 @@ const I18N = {
custom: 'Custom',
},
categorieslabel: 'Emoji categories', // Accessible title for the list of categories
skintones: {
1: 'Default Skin Tone',
2: 'Light Skin Tone',
3: 'Medium-Light Skin Tone',
4: 'Medium Skin Tone',
5: 'Medium-Dark Skin Tone',
6: 'Dark Skin Tone',
},
}
export default class NimblePicker extends React.PureComponent {

View File

@ -8,6 +8,14 @@ export default class SkinsDot extends Skins {
super(props)
this.handleClick = this.handleClick.bind(this)
this.handleKeyDown = this.handleKeyDown.bind(this)
}
handleKeyDown(event) {
// if either enter or space is pressed, then execute
if (event.keyCode === 13 || event.keyCode === 32) {
this.handleClick(event)
}
}
render() {
@ -17,6 +25,7 @@ export default class SkinsDot extends Skins {
for (let skinTone = 1; skinTone <= 6; skinTone++) {
const selected = skinTone === skin
const visible = opened || selected
skinToneNodes.push(
<span
key={`skin-tone-${skinTone}`}
@ -24,6 +33,15 @@ export default class SkinsDot extends Skins {
>
<span
onClick={this.handleClick}
onKeyDown={this.handleKeyDown}
role="button"
tabindex={visible ? '0' : ''}
aria-hidden={!visible}
aria-pressed={opened ? !!selected : ''}
aria-haspopup={!!selected}
aria-expanded={selected ? opened : ''}
aria-label={i18n.skintones[skinTone]}
title={i18n.skintones[skinTone]}
data-skin={skinTone}
className={`emoji-mart-skin emoji-mart-skin-tone-${skinTone}`}
/>
@ -32,9 +50,12 @@ export default class SkinsDot extends Skins {
}
return (
<div className={`emoji-mart-skin-swatches${opened ? ' opened' : ''}`}>
<section
className={`emoji-mart-skin-swatches${opened ? ' opened' : ''}`}
aria-label={i18n.skintext}
>
{skinToneNodes}
</div>
</section>
)
}
}