Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiBetaBadge] A couple TS changes #15

Merged
merged 1 commit into from
May 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/components/badge/beta_badge/beta_badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ type WithSpanProps = Omit<
>;

// `label` prop can be a `ReactNode` only if `title` or `tooltipContent` is provided
type LabelAsNode = (
| {
title: string;
tooltipContent?: ReactNode;
}
| {
tooltipContent: ReactNode;
title?: string;
}
) & {
type LabelAsNode = ExclusiveUnion<
{
title: string;
tooltipContent?: ReactNode;
},
{
tooltipContent: ReactNode;
title?: string;
}
> & {
label: ReactNode;
};

Expand Down Expand Up @@ -203,12 +203,11 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({

let content;
if (onClick || href) {
const spanTitle = title || label;
content = (
<Element
aria-label={onClickAriaLabel}
className={classes}
title={spanTitle as string | undefined}
title={typeof label === 'string' ? label : title}
{...(relObj as HTMLAttributes<HTMLElement>)}
{...(rest as HTMLAttributes<HTMLElement>)}>
{icon || label}
Expand Down Expand Up @@ -246,10 +245,7 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({
);
}
return (
<span
className={classes}
title={spanTitle as string | undefined}
{...rest}>
<span className={classes} title={spanTitle as string} {...rest}>
{icon || label}
</span>
);
Expand Down