Some more a11y
This commit is contained in:
@@ -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}
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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
|
||||||
|
}>
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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={{
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user