From 449c29b94b91b1ab2aac5224dae54b280c053af8 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 17 Jan 2024 15:22:28 -0600 Subject: [PATCH] Improve a11y labels --- src/components/Button.tsx | 18 +++++++----------- src/components/Dialog/index.web.tsx | 5 +++-- src/components/Prompt.tsx | 6 ++---- src/components/forms/Toggle.tsx | 2 +- src/view/screens/Storybook/Buttons.tsx | 18 ++++++------------ src/view/screens/Storybook/Forms.tsx | 3 +-- src/view/screens/Storybook/Links.tsx | 15 +++++---------- 7 files changed, 25 insertions(+), 42 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 7c032dbad8..06226ad1e0 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -38,10 +38,8 @@ export type VariantProps = { size?: ButtonSize } -export type ButtonProps = Omit< - PressableProps, - 'children' | 'style' | 'accessibilityLabel' | 'accessibilityHint' -> & +export type ButtonProps = Pick & + AccessibilityProps & VariantProps & { children: | ((props: { @@ -56,8 +54,7 @@ export type ButtonProps = Omit< }) => React.ReactNode) | React.ReactNode | string - accessibilityLabel: Required['accessibilityLabel'] - accessibilityHint: Required['accessibilityHint'] + label: string } export type ButtonTextProps = TextProps & VariantProps & {disabled?: boolean} @@ -66,8 +63,7 @@ export function Button({ variant, color, size, - accessibilityLabel, - accessibilityHint, + label, disabled = false, ...rest }: ButtonProps) { @@ -325,11 +321,11 @@ export function Button({ return ( {children} @@ -108,8 +107,7 @@ export function Action({ variant="solid" color="primary" size="small" - accessibilityLabel="Confirm" - accessibilityHint="Confirm this action" + label="Confirm" onPress={handleOnPress}> {children} diff --git a/src/components/forms/Toggle.tsx b/src/components/forms/Toggle.tsx index ed678e7fd6..8fe43f2f41 100644 --- a/src/components/forms/Toggle.tsx +++ b/src/components/forms/Toggle.tsx @@ -196,6 +196,7 @@ function Item({ return ( + label="Click here"> Button @@ -46,8 +44,7 @@ export function Buttons() { variant="gradient" color={name as ButtonColor} size="large" - accessibilityLabel="Click here" - accessibilityHint="Opens something"> + label="Click here"> Button @@ -71,8 +67,7 @@ export function Buttons() { variant="gradient" color={name as ButtonColor} size="large" - accessibilityLabel="Click here" - accessibilityHint="Opens something"> + label="Click here"> Button diff --git a/src/view/screens/Storybook/Forms.tsx b/src/view/screens/Storybook/Forms.tsx index c7dd998b6e..66268cb802 100644 --- a/src/view/screens/Storybook/Forms.tsx +++ b/src/view/screens/Storybook/Forms.tsx @@ -168,8 +168,7 @@ export function Forms() { variant="solid" color="primary" size="small" - accessibilityLabel="Reset" - accessibilityHint="Reset" + label="Reset" onPress={() => setToggleGroupAValues(['a'])}> Reset diff --git a/src/view/screens/Storybook/Links.tsx b/src/view/screens/Storybook/Links.tsx index b5c183425a..2b9da2a9de 100644 --- a/src/view/screens/Storybook/Links.tsx +++ b/src/view/screens/Storybook/Links.tsx @@ -13,31 +13,27 @@ export function Links() { External

External with custom children

https://blueskyweb.xyz @@ -45,8 +41,7 @@ export function Links() {