Improve a11y labels
This commit is contained in:
@@ -38,10 +38,8 @@ export type VariantProps = {
|
|||||||
size?: ButtonSize
|
size?: ButtonSize
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ButtonProps = Omit<
|
export type ButtonProps = Pick<PressableProps, 'disabled' | 'onPress'> &
|
||||||
PressableProps,
|
AccessibilityProps &
|
||||||
'children' | 'style' | 'accessibilityLabel' | 'accessibilityHint'
|
|
||||||
> &
|
|
||||||
VariantProps & {
|
VariantProps & {
|
||||||
children:
|
children:
|
||||||
| ((props: {
|
| ((props: {
|
||||||
@@ -56,8 +54,7 @@ export type ButtonProps = Omit<
|
|||||||
}) => React.ReactNode)
|
}) => React.ReactNode)
|
||||||
| React.ReactNode
|
| React.ReactNode
|
||||||
| string
|
| string
|
||||||
accessibilityLabel: Required<AccessibilityProps>['accessibilityLabel']
|
label: string
|
||||||
accessibilityHint: Required<AccessibilityProps>['accessibilityHint']
|
|
||||||
}
|
}
|
||||||
export type ButtonTextProps = TextProps & VariantProps & {disabled?: boolean}
|
export type ButtonTextProps = TextProps & VariantProps & {disabled?: boolean}
|
||||||
|
|
||||||
@@ -66,8 +63,7 @@ export function Button({
|
|||||||
variant,
|
variant,
|
||||||
color,
|
color,
|
||||||
size,
|
size,
|
||||||
accessibilityLabel,
|
label,
|
||||||
accessibilityHint,
|
|
||||||
disabled = false,
|
disabled = false,
|
||||||
...rest
|
...rest
|
||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
@@ -325,11 +321,11 @@ export function Button({
|
|||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
role="button"
|
role="button"
|
||||||
|
accessibilityHint={undefined} // optional
|
||||||
{...rest}
|
{...rest}
|
||||||
aria-label={accessibilityLabel}
|
aria-label={label}
|
||||||
aria-pressed={state.pressed}
|
aria-pressed={state.pressed}
|
||||||
accessibilityLabel={accessibilityLabel}
|
accessibilityLabel={label}
|
||||||
accessibilityHint={accessibilityHint}
|
|
||||||
disabled={disabled || false}
|
disabled={disabled || false}
|
||||||
accessibilityState={{
|
accessibilityState={{
|
||||||
disabled: disabled || false,
|
disabled: disabled || false,
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ export function Outer({
|
|||||||
<Portal>
|
<Portal>
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
<TouchableWithoutFeedback
|
<TouchableWithoutFeedback
|
||||||
accessibilityRole="button"
|
accessibilityHint={undefined}
|
||||||
|
accessibilityLabel="Close active dialog"
|
||||||
onPress={close}>
|
onPress={close}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -129,7 +130,7 @@ export function Inner({
|
|||||||
return (
|
return (
|
||||||
<FocusScope loop enabled trapped>
|
<FocusScope loop enabled trapped>
|
||||||
<Animated.View
|
<Animated.View
|
||||||
aria-modal
|
role="dialog"
|
||||||
aria-role="dialog"
|
aria-role="dialog"
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
aria-labelledby={accessibilityLabelledBy}
|
aria-labelledby={accessibilityLabelledBy}
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ export function Cancel({
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
accessibilityLabel="Cancel"
|
label="Cancel"
|
||||||
accessibilityHint="Cancel this action"
|
|
||||||
onPress={close}>
|
onPress={close}>
|
||||||
{children}
|
{children}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -108,8 +107,7 @@ export function Action({
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
accessibilityLabel="Confirm"
|
label="Confirm"
|
||||||
accessibilityHint="Confirm this action"
|
|
||||||
onPress={handleOnPress}>
|
onPress={handleOnPress}>
|
||||||
{children}
|
{children}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ function Item({
|
|||||||
return (
|
return (
|
||||||
<ItemContext.Provider value={state}>
|
<ItemContext.Provider value={state}>
|
||||||
<Pressable
|
<Pressable
|
||||||
|
accessibilityHint={undefined} // optional
|
||||||
{...rest}
|
{...rest}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
aria-disabled={disabled ?? false}
|
aria-disabled={disabled ?? false}
|
||||||
@@ -209,7 +210,6 @@ function Item({
|
|||||||
selected: selected,
|
selected: selected,
|
||||||
}}
|
}}
|
||||||
accessibilityLabel={label}
|
accessibilityLabel={label}
|
||||||
accessibilityHint={undefined}
|
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onHoverIn={onHoverIn}
|
onHoverIn={onHoverIn}
|
||||||
onHoverOut={onHoverOut}
|
onHoverOut={onHoverOut}
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ export function Buttons() {
|
|||||||
variant={variant as ButtonVariant}
|
variant={variant as ButtonVariant}
|
||||||
color={color as ButtonColor}
|
color={color as ButtonColor}
|
||||||
size="large"
|
size="large"
|
||||||
accessibilityLabel="Click here"
|
label="Click here">
|
||||||
accessibilityHint="Opens something">
|
|
||||||
Button
|
Button
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -28,8 +27,7 @@ export function Buttons() {
|
|||||||
variant={variant as ButtonVariant}
|
variant={variant as ButtonVariant}
|
||||||
color={color as ButtonColor}
|
color={color as ButtonColor}
|
||||||
size="large"
|
size="large"
|
||||||
accessibilityLabel="Click here"
|
label="Click here">
|
||||||
accessibilityHint="Opens something">
|
|
||||||
Button
|
Button
|
||||||
</Button>
|
</Button>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
@@ -46,8 +44,7 @@ export function Buttons() {
|
|||||||
variant="gradient"
|
variant="gradient"
|
||||||
color={name as ButtonColor}
|
color={name as ButtonColor}
|
||||||
size="large"
|
size="large"
|
||||||
accessibilityLabel="Click here"
|
label="Click here">
|
||||||
accessibilityHint="Opens something">
|
|
||||||
Button
|
Button
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -55,8 +52,7 @@ export function Buttons() {
|
|||||||
variant="gradient"
|
variant="gradient"
|
||||||
color={name as ButtonColor}
|
color={name as ButtonColor}
|
||||||
size="large"
|
size="large"
|
||||||
accessibilityLabel="Click here"
|
label="Click here">
|
||||||
accessibilityHint="Opens something">
|
|
||||||
Button
|
Button
|
||||||
</Button>
|
</Button>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
@@ -71,8 +67,7 @@ export function Buttons() {
|
|||||||
variant="gradient"
|
variant="gradient"
|
||||||
color={name as ButtonColor}
|
color={name as ButtonColor}
|
||||||
size="large"
|
size="large"
|
||||||
accessibilityLabel="Click here"
|
label="Click here">
|
||||||
accessibilityHint="Opens something">
|
|
||||||
Button
|
Button
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -80,8 +75,7 @@ export function Buttons() {
|
|||||||
variant="gradient"
|
variant="gradient"
|
||||||
color={name as ButtonColor}
|
color={name as ButtonColor}
|
||||||
size="large"
|
size="large"
|
||||||
accessibilityLabel="Click here"
|
label="Click here">
|
||||||
accessibilityHint="Opens something">
|
|
||||||
Button
|
Button
|
||||||
</Button>
|
</Button>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|||||||
@@ -168,8 +168,7 @@ export function Forms() {
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
accessibilityLabel="Reset"
|
label="Reset"
|
||||||
accessibilityHint="Reset"
|
|
||||||
onPress={() => setToggleGroupAValues(['a'])}>
|
onPress={() => setToggleGroupAValues(['a'])}>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -13,31 +13,27 @@ export function Links() {
|
|||||||
|
|
||||||
<View style={[a.gap_md, a.align_start]}>
|
<View style={[a.gap_md, a.align_start]}>
|
||||||
<Link
|
<Link
|
||||||
accessibilityLabel="Click here"
|
label="Click here"
|
||||||
accessibilityHint="Opens something"
|
|
||||||
to="https://blueskyweb.xyz"
|
to="https://blueskyweb.xyz"
|
||||||
warnOnMismatchingTextChild
|
warnOnMismatchingTextChild
|
||||||
style={[a.text_md]}>
|
style={[a.text_md]}>
|
||||||
External
|
External
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
accessibilityLabel="Click here"
|
label="Click here"
|
||||||
accessibilityHint="Opens something"
|
|
||||||
to="https://blueskyweb.xyz"
|
to="https://blueskyweb.xyz"
|
||||||
style={[a.text_md]}>
|
style={[a.text_md]}>
|
||||||
<H3>External with custom children</H3>
|
<H3>External with custom children</H3>
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
accessibilityLabel="Click here"
|
label="Click here"
|
||||||
accessibilityHint="Opens something"
|
|
||||||
to="https://blueskyweb.xyz"
|
to="https://blueskyweb.xyz"
|
||||||
warnOnMismatchingTextChild
|
warnOnMismatchingTextChild
|
||||||
style={[a.text_md]}>
|
style={[a.text_md]}>
|
||||||
https://blueskyweb.xyz
|
https://blueskyweb.xyz
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
accessibilityLabel="Click here"
|
label="Click here"
|
||||||
accessibilityHint="Opens something"
|
|
||||||
to="https://bsky.app/profile/bsky.app"
|
to="https://bsky.app/profile/bsky.app"
|
||||||
warnOnMismatchingTextChild
|
warnOnMismatchingTextChild
|
||||||
style={[a.text_md]}>
|
style={[a.text_md]}>
|
||||||
@@ -45,8 +41,7 @@ export function Links() {
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
accessibilityLabel="Click here"
|
label="Click here"
|
||||||
accessibilityHint="Opens something"
|
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="large"
|
size="large"
|
||||||
|
|||||||
Reference in New Issue
Block a user