import { Card } from '@automattic/components';
import clsx from 'clsx';
import { translate } from 'i18n-calypso';
import { forwardRef, useMemo } from 'react';
import type { Ref } from 'react';
import './style.scss';
interface ThemeCardProps {
className?: string;
name: string;
image: React.ReactNode;
imageClickUrl?: string;
imageActionLabel?: string;
banner?: React.ReactNode;
badge?: React.ReactNode;
optionsMenu?: React.ReactNode;
isActive?: boolean;
isLoading?: boolean;
isSoftLaunched?: boolean;
onClick?: () => void;
onImageClick?: () => void;
}
const ActiveBadge = () => {
return (
{ translate( 'Active', {
context: 'singular noun, the currently active theme',
} ) }
);
};
const ThemeCard = forwardRef(
(
{
className,
name,
image,
imageClickUrl,
imageActionLabel,
banner,
badge,
optionsMenu,
isActive,
isLoading,
isSoftLaunched,
onClick,
onImageClick,
}: ThemeCardProps,
forwardedRef: Ref< any > // eslint-disable-line @typescript-eslint/no-explicit-any
) => {
const e2eName = useMemo( () => name?.toLowerCase?.().replace( /\s+/g, '-' ), [ name ] );
const isActionable = imageClickUrl || onImageClick;
const themeClasses = clsx( 'theme-card', {
'theme-card--is-active': isActive,
'theme-card--is-actionable': isActionable,
} );
return (
{ banner &&
{ banner }
}
{ isLoading && (
) }
{ isSoftLaunched && (
{ translate( 'A8C Only' ) }
) }
{ name }
{ ! isActive && badge && (
{ badge }
) }
{ isActive &&
}
{ optionsMenu &&
{ optionsMenu }
}
);
}
);
export default ThemeCard;