Skip to content

Commit

Permalink
Remove NonInteractiveCardComponentProps and use BaseCardComponentProps
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeorge committed Jan 14, 2025
1 parent 3c14e7e commit f1a065d
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions app/scripts/components/common/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,10 @@ interface ClickCardComponentProps extends BaseCardComponentProps {
onClick: MouseEventHandler;
}

interface NonInteractiveCardComponentProps extends BaseCardComponentProps {
to?: never;
onClick?: never;
}

export type CardComponentProps =
| LinkCardComponentProps
| ClickCardComponentProps
| NonInteractiveCardComponentProps;
| BaseCardComponentProps;

export interface DeprecatedCardComponentProps {
linkProperties?: LinkProperties & { linkTo?: string };
Expand Down Expand Up @@ -318,22 +313,22 @@ function CardComponent(
parentTo,
footerContent,
hideExternalLinkBadge,
onCardClickCapture,
onClick
onCardClickCapture
} = props;

const { Link } = useVedaUI();

// For backwards compatibility with deprecated props
const to = props.to || props.linkTo || props.linkProperties?.linkTo;
const to =
('to' in props && props.to) || props.linkTo || props.linkProperties?.linkTo;

if (props.linkProperties || props.linkTo) {
// eslint-disable-next-line no-console
console.warn(
'linkProperties and linkTo are deprecated in Card component. Please use the "to" prop instead.'
);

if (onClick) {
if ('onClick' in props && props.onClick) {
// eslint-disable-next-line no-console
console.warn(
'onClick and linkProperties/linkTo are mutually exclusive. Please use only one of them.'
Expand Down Expand Up @@ -424,8 +419,8 @@ function CardComponent(
}

// Clickable variant
if (onClick) {
return <ElementInteractive {...baseProps} onClick={onClick} />;
if ('onClick' in props && props.onClick) {
return <ElementInteractive {...baseProps} onClick={props.onClick} />;
}

// Non-interactive variant
Expand Down

0 comments on commit f1a065d

Please sign in to comment.