import React, { useMemo } from 'react' import { RiCheckLine, RiVerifiedBadgeLine } from '@remixicon/react' import type { FC } from 'react' import { LeftCorner } from '../base/icons/src/vender/plugin' import type { Plugin } from './types' import { getLocaleOnServer } from '@/i18n/server' import cn from '@/utils/classnames' export const CornerMark = ({ text }: { text: string }) => { return (
{text}
) } export const Icon = ({ className, src, installed = false, }: { className?: string src: string installed?: boolean }) => { return (
{installed &&
}
) } export const Title = ({ title, }: { title: string }) => { return (
{title}
) } export const OrgInfo = ({ className, orgName, packageName, }: { className?: string orgName: string packageName: string }) => { return
{orgName} / {packageName}
} type DescriptionProps = { className?: string text: string descriptionLineRows: number } export const Description: FC = ({ className, text, descriptionLineRows, }) => { const lineClassName = useMemo(() => { if (descriptionLineRows === 1) return 'truncate' else if (descriptionLineRows === 2) return 'line-clamp-2' else return 'line-clamp-3' }, [descriptionLineRows]) return (
{text}
) } type Props = { className?: string payload: Plugin installed?: boolean descriptionLineRows?: number footer?: React.ReactNode } const Card = ({ className, payload, installed, descriptionLineRows = 2, footer, }: Props) => { const locale = getLocaleOnServer() const { type, name, org, label } = payload return (
{/* Header */}
<RiVerifiedBadgeLine className="shrink-0 ml-0.5 w-4 h-4 text-text-accent" /> </div> <OrgInfo className="mt-0.5" orgName={org} packageName={name} /> </div> </div> <Description className="mt-3" text={payload.brief[locale]} descriptionLineRows={descriptionLineRows} /> {footer && <div>{footer}</div>} </div> ) } export default Card