({
tool,
onClick,
isInStack = false,
onAddToStack,
}: ToolCardProps)
| 35 | |
| 36 | // The anchor stretches over the card; the stack button is a sibling above it. |
| 37 | export const ToolCard = ({ |
| 38 | tool, |
| 39 | onClick, |
| 40 | isInStack = false, |
| 41 | onAddToStack, |
| 42 | }: ToolCardProps): ReactElement => { |
| 43 | const formattedCount = largeNumberFormat(tool.stackCount) ?? tool.stackCount; |
| 44 | |
| 45 | return ( |
| 46 | <div className="group relative flex items-center gap-4 rounded-16 border border-border-subtlest-tertiary p-4 transition-colors hover:border-border-subtlest-secondary"> |
| 47 | <Link href={`/tools/${tool.slug}`} passHref> |
| 48 | <a |
| 49 | href={`/tools/${tool.slug}`} |
| 50 | className="absolute inset-0 rounded-16" |
| 51 | onClick={onClick} |
| 52 | aria-label={`${tool.title}, ${formattedCount} in stacks`} |
| 53 | /> |
| 54 | </Link> |
| 55 | <ToolLogo |
| 56 | title={tool.title} |
| 57 | faviconUrl={tool.faviconUrl} |
| 58 | url={tool.url} |
| 59 | className="pointer-events-none size-12 rounded-14" |
| 60 | plateClassName="p-1.5" |
| 61 | /> |
| 62 | <span className="pointer-events-none flex min-w-0 flex-1 flex-col"> |
| 63 | <Typography type={TypographyType.Body} bold truncate> |
| 64 | {tool.title} |
| 65 | </Typography> |
| 66 | <Typography |
| 67 | type={TypographyType.Footnote} |
| 68 | color={TypographyColor.Tertiary} |
| 69 | > |
| 70 | {formattedCount} in stacks |
| 71 | </Typography> |
| 72 | </span> |
| 73 | {onAddToStack && ( |
| 74 | <Tooltip |
| 75 | content={ |
| 76 | isInStack ? 'In your stack' : `Add ${tool.title} to my stack` |
| 77 | } |
| 78 | > |
| 79 | <Button |
| 80 | type="button" |
| 81 | size={ButtonSize.XSmall} |
| 82 | variant={ButtonVariant.Tertiary} |
| 83 | icon={isInStack ? <VIcon aria-hidden /> : <PlusIcon aria-hidden />} |
| 84 | aria-label={ |
| 85 | isInStack |
| 86 | ? `${tool.title} is in your stack` |
| 87 | : `Add ${tool.title} to my stack` |
| 88 | } |
| 89 | aria-disabled={isInStack} |
| 90 | onClick={() => !isInStack && onAddToStack(tool)} |
| 91 | className={classNames( |
| 92 | 'relative shrink-0', |
| 93 | isInStack |
| 94 | ? '!text-brand-default' |
nothing calls this directly
no test coverage detected