Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

fix(app): label emoji picker emojis and skin tone controls

Hampusac10902b0409
diff --git a/fluxer_app/src/features/channel/components/emoji_picker/EmojiRenderer.tsx b/fluxer_app/src/features/channel/components/emoji_picker/EmojiRenderer.tsx
index fe18fb399..bd92cca61 100644
--- a/fluxer_app/src/features/channel/components/emoji_picker/EmojiRenderer.tsx
+++ b/fluxer_app/src/features/channel/components/emoji_picker/EmojiRenderer.tsx
@@ -169,6 +169,7 @@ export const EmojiRenderer = React.forwardRef<HTMLButtonElement, EmojiRendererPr
onClick={handleClick}
onContextMenu={handleContextMenu}
className={className}
+ aria-label={emoji.name}
aria-disabled={isDisabled}
aria-selected={isHighlighted}
role="option"
diff --git a/fluxer_app/src/features/channel/components/emoji_picker/SkinToneSelector.tsx b/fluxer_app/src/features/channel/components/emoji_picker/SkinToneSelector.tsx
index 16a5d6b86..5cb46b6fa 100644
--- a/fluxer_app/src/features/channel/components/emoji_picker/SkinToneSelector.tsx
+++ b/fluxer_app/src/features/channel/components/emoji_picker/SkinToneSelector.tsx
@@ -8,10 +8,26 @@ import Emoji from '@app/features/emoji/state/Emoji';
import * as EmojiUtils from '@app/features/expressions/utils/EmojiUtils';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {SKIN_TONE_SURROGATES} from '@fluxer/constants/src/EmojiConstants';
+import type {MessageDescriptor} from '@lingui/core';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
import {AnimatePresence, motion} from 'framer-motion';
import {observer} from 'mobx-react-lite';
import {useCallback, useEffect, useRef, useState} from 'react';
+const SKIN_TONE_DESCRIPTOR = msg({
+ message: 'Skin tone',
+ comment: 'Accessible name of the emoji picker button that opens the skin tone choices.',
+});
+const SKIN_TONE_LABELS: Readonly<Record<string, MessageDescriptor>> = {
+ '': msg({message: 'Default skin tone', comment: 'Accessible name of a skin tone choice in the emoji picker.'}),
+ '🏻': msg({message: 'Light skin tone', comment: 'Accessible name of a skin tone choice in the emoji picker.'}),
+ '🏼': msg({message: 'Medium-light skin tone', comment: 'Accessible name of a skin tone choice in the emoji picker.'}),
+ '🏽': msg({message: 'Medium skin tone', comment: 'Accessible name of a skin tone choice in the emoji picker.'}),
+ '🏾': msg({message: 'Medium-dark skin tone', comment: 'Accessible name of a skin tone choice in the emoji picker.'}),
+ '🏿': msg({message: 'Dark skin tone', comment: 'Accessible name of a skin tone choice in the emoji picker.'}),
+};
+
interface SkinTonePickerProps {
isOpen: boolean;
onClose: () => void;
@@ -19,6 +35,7 @@ interface SkinTonePickerProps {
}
const SkinTonePicker = observer(({isOpen, onClose, skinTone}: SkinTonePickerProps) => {
+ const {i18n} = useLingui();
const prefersReducedMotion = Accessibility.useReducedMotion;
const handleSelect = (surrogate: string) => {
Emoji.setSkinTone(surrogate);
@@ -49,6 +66,8 @@ const SkinTonePicker = observer(({isOpen, onClose, skinTone}: SkinTonePickerProp
exit={prefersReducedMotion ? {opacity: 1, scale: 1} : {opacity: 0, scale: 0}}
transition={prefersReducedMotion ? {duration: 0} : undefined}
className={styles.skinTonePickerItem}
+ aria-label={i18n._(SKIN_TONE_LABELS[surrogate] ?? SKIN_TONE_DESCRIPTOR)}
+ aria-pressed={surrogate === skinTone}
onClick={() => handleSelect(surrogate)}
data-flx="channel.emoji-picker.skin-tone-selector.skin-tone-picker.skin-tone-picker-item.select.button"
>
@@ -70,20 +89,26 @@ const SkinTonePicker = observer(({isOpen, onClose, skinTone}: SkinTonePickerProp
interface SkinTonePickerButtonProps {
onClick: () => void;
selectedEmojiURL: string | null;
+ expanded: boolean;
}
-const SkinTonePickerButton = observer(({onClick, selectedEmojiURL}: SkinTonePickerButtonProps) => (
- <motion.button
- type="button"
- className={styles.skinTonePickerButton}
- onClick={onClick}
- style={selectedEmojiURL ? {backgroundImage: `url(${selectedEmojiURL})`} : undefined}
- initial={{opacity: 1, scale: 1}}
- animate={{opacity: 1, scale: 1}}
- exit={{opacity: 0, scale: 0}}
- data-flx="channel.emoji-picker.skin-tone-selector.skin-tone-picker-button.skin-tone-picker-button.click"
- />
-));
+const SkinTonePickerButton = observer(({onClick, selectedEmojiURL, expanded}: SkinTonePickerButtonProps) => {
+ const {i18n} = useLingui();
+ return (
+ <motion.button
+ type="button"
+ className={styles.skinTonePickerButton}
+ aria-label={i18n._(SKIN_TONE_DESCRIPTOR)}
+ aria-expanded={expanded}
+ onClick={onClick}
+ style={selectedEmojiURL ? {backgroundImage: `url(${selectedEmojiURL})`} : undefined}
+ initial={{opacity: 1, scale: 1}}
+ animate={{opacity: 1, scale: 1}}
+ exit={{opacity: 0, scale: 0}}
+ data-flx="channel.emoji-picker.skin-tone-selector.skin-tone-picker-button.skin-tone-picker-button.click"
+ />
+ );
+});
export const SkinToneSelector = observer(() => {
const [isOpen, setIsOpen] = useState(false);
const skinTone = Emoji.skinTone;
@@ -119,6 +144,7 @@ export const SkinToneSelector = observer(() => {
<SkinTonePickerButton
onClick={() => setIsOpen(true)}
selectedEmojiURL={selectedEmojiUrl}
+ expanded={isOpen}
data-flx="channel.emoji-picker.skin-tone-selector.skin-tone-picker-button.set-is-open"
/>
</div>