Some more a11y

This commit is contained in:
Eric Bailey
2024-01-16 11:04:54 -06:00
parent 1e02cde581
commit 7315b0d714
6 changed files with 26 additions and 7 deletions
+1
View File
@@ -327,6 +327,7 @@ export function Button({
role="button" role="button"
{...rest} {...rest}
aria-label={accessibilityLabel} aria-label={accessibilityLabel}
aria-pressed={state.pressed}
accessibilityLabel={accessibilityLabel} accessibilityLabel={accessibilityLabel}
accessibilityHint={accessibilityHint} accessibilityHint={accessibilityHint}
disabled={disabled || false} disabled={disabled || false}
+4 -1
View File
@@ -120,6 +120,7 @@ export function Outer({
export function Inner({ export function Inner({
children, children,
style, style,
label,
accessibilityLabelledBy, accessibilityLabelledBy,
accessibilityDescribedBy, accessibilityDescribedBy,
}: DialogInnerProps) { }: DialogInnerProps) {
@@ -128,9 +129,11 @@ export function Inner({
return ( return (
<FocusScope loop enabled trapped> <FocusScope loop enabled trapped>
<Animated.View <Animated.View
aria-modal
aria-role="dialog"
aria-label={label}
aria-labelledby={accessibilityLabelledBy} aria-labelledby={accessibilityLabelledBy}
aria-describedby={accessibilityDescribedBy} aria-describedby={accessibilityDescribedBy}
aria-role="dialog"
// @ts-ignore web only -prf // @ts-ignore web only -prf
onClick={stopPropagation} onClick={stopPropagation}
onStartShouldSetResponder={_ => true} onStartShouldSetResponder={_ => true}
+14 -4
View File
@@ -26,8 +26,18 @@ export type DialogOuterProps = {
webOptions?: {} webOptions?: {}
} }
export type DialogInnerProps = React.PropsWithChildren<{ type DialogInnerPropsBase<T> = React.PropsWithChildren<{
style?: ViewStyle style?: ViewStyle
accessibilityLabelledBy: A11yProps['aria-labelledby'] }> &
accessibilityDescribedBy: string T
}> export type DialogInnerProps =
| DialogInnerPropsBase<{
label?: undefined
accessibilityLabelledBy: A11yProps['aria-labelledby']
accessibilityDescribedBy: string
}>
| DialogInnerPropsBase<{
label: string
accessibilityLabelledBy?: undefined
accessibilityDescribedBy?: undefined
}>
+2
View File
@@ -166,6 +166,8 @@ export function createTextInput(Input: typeof TextInput) {
testID={testID} testID={testID}
aria-labelledby={labelId} aria-labelledby={labelId}
aria-label={label} aria-label={label}
aria-invalid={hasError}
aria-placeholder={props.placeholder}
accessibilityLabel={accessibilityLabel} accessibilityLabel={accessibilityLabel}
accessibilityHint={accessibilityHint} accessibilityHint={accessibilityHint}
placeholderTextColor={t.atoms.text_contrast_400.color} placeholderTextColor={t.atoms.text_contrast_400.color}
+3
View File
@@ -41,6 +41,7 @@ type ItemProps = Omit<PressableProps, 'children' | 'style' | 'onPress'> & {
name: string name: string
value?: boolean value?: boolean
onChange?: ({name, value}: {name: string; value: boolean}) => void onChange?: ({name, value}: {name: string; value: boolean}) => void
hasError?: boolean
style?: (state: ItemState) => ViewStyle style?: (state: ItemState) => ViewStyle
children: ((props: ItemState) => React.ReactNode) | React.ReactNode children: ((props: ItemState) => React.ReactNode) | React.ReactNode
} }
@@ -51,6 +52,7 @@ function Item({
value = false, value = false,
disabled, disabled,
onChange, onChange,
hasError,
style, style,
role, role,
}: ItemProps) { }: ItemProps) {
@@ -92,6 +94,7 @@ function Item({
aria-disabled={disabled ?? false} aria-disabled={disabled ?? false}
aria-checked={value} aria-checked={value}
aria-labelledby={labelId} aria-labelledby={labelId}
aria-invalid={hasError}
role={role} role={role}
accessibilityRole={role as AccessibilityRole} accessibilityRole={role as AccessibilityRole}
accessibilityState={{ accessibilityState={{
+2 -2
View File
@@ -51,8 +51,8 @@ export function Dialogs() {
<Dialog.Handle /> <Dialog.Handle />
<Dialog.ScrollableInner <Dialog.ScrollableInner
accessibilityLabelledBy="dialog-title" accessibilityDescribedBy="dialog-description"
accessibilityDescribedBy="dialog-description"> accessibilityLabelledBy="dialog-title">
<View style={[a.relative, a.gap_md, a.w_full]}> <View style={[a.relative, a.gap_md, a.w_full]}>
<H3 nativeID="dialog-title">Dialog</H3> <H3 nativeID="dialog-title">Dialog</H3>
<P nativeID="dialog-description">Description</P> <P nativeID="dialog-description">Description</P>