Skip to content

Commit

Permalink
Make label required in link components (bluesky-social#4844)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored Jul 25, 2024
1 parent 4437b9a commit 43ba0f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export type ButtonProps = Pick<
AccessibilityProps &
VariantProps & {
testID?: string
/**
* For a11y, try to make this descriptive and clear
*/
label: string
style?: StyleProp<ViewStyle>
hoverStyle?: StyleProp<ViewStyle>
Expand Down
13 changes: 4 additions & 9 deletions src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ type BaseLinkProps = Pick<
> & {
testID?: string

/**
* Label for a11y. Defaults to the href.
*/
label?: string

/**
* The React Navigation `StackAction` to perform when the link is pressed.
*/
Expand Down Expand Up @@ -197,7 +192,7 @@ export function useLink({
}

export type LinkProps = Omit<BaseLinkProps, 'disableMismatchWarning'> &
Omit<ButtonProps, 'onPress' | 'disabled' | 'label'>
Omit<ButtonProps, 'onPress' | 'disabled'>

/**
* A interactive element that renders as a `<a>` tag on the web. On mobile it
Expand All @@ -224,7 +219,6 @@ export function Link({

return (
<Button
label={href}
{...rest}
style={[a.justify_start, flatten(rest.style)]}
role="link"
Expand All @@ -249,7 +243,8 @@ export function Link({

export type InlineLinkProps = React.PropsWithChildren<
BaseLinkProps & TextStyleProp & Pick<TextProps, 'selectable'>
>
> &
Pick<ButtonProps, 'label'>

export function InlineLinkText({
children,
Expand Down Expand Up @@ -291,7 +286,7 @@ export function InlineLinkText({
<Text
selectable={selectable}
accessibilityHint=""
accessibilityLabel={label || href}
accessibilityLabel={label}
{...rest}
style={[
{color: t.palette.primary_500},
Expand Down

0 comments on commit 43ba0f2

Please sign in to comment.