Skip to content

Commit

Permalink
Merge pull request #15 from thompsongl/betabadge
Browse files Browse the repository at this point in the history
[EuiBetaBadge] A couple TS changes
  • Loading branch information
andreadelrio authored May 27, 2021
2 parents aeb3944 + 36ea7ab commit 7724eb4
Showing 1 changed file with 12 additions and 16 deletions.
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

0 comments on commit 7724eb4

Please sign in to comment.