Files
supabase/apps/studio/components/ui/ActionCard.tsx
Joshen Lim 6d08d66b7d Add eslint rule for google translate dynamic spans + address all issues (#52949)
## Context

We've been seeing many `NotFoundError: Failed to execute 'removeChild'
on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on
'Node'` events on Sentry which are historically known to be caused by
Google Translate in the browser.

There's technically no _right way_ to address this unfortunately, but
one of the solutions which should address most of these issues is to
wrap any dynamic text within a span - we've considered that quite a
while back tbh but never took the time to do this until today with the
help of Claude. Although just a heads up that it might not necessarily
completely eradicate those issues.

Also added an eslint rule which should prevent future occurences of this
<img width="1264" height="192" alt="image"
src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29"
/>
2026-11-05 23:28:46 +08:00

42 lines
1.2 KiB
TypeScript

import type { ReactNode } from 'react'
import { Card, cn } from 'ui'
export const ActionCard = (card: {
icon: ReactNode
title: string
bgColor?: string
description?: ReactNode
className?: string
onClick?: () => void
}) => {
return (
<Card
className={cn(
'grow bg-surface-100 p-3 transition-colors hover:bg-surface-200 border hover:border-default cursor-pointer',
card.className
)}
onClick={card.onClick}
>
<div className="relative flex items-start gap-3">
<div
className={`rounded-full ${card.bgColor} w-8 h-8 flex items-center justify-center shrink-0`}
>
{card.icon}
</div>
<div className="grow flex flex-col gap-0 min-w-0">
<div className="flex items-center gap-x-2">
<h3 title={card.title} className="text-sm text-foreground mb-0 truncate max-w-full">
{card.title}
</h3>
</div>
{typeof card.description === 'string' ? (
<pre className="text-xs text-foreground-light font-sans">{card.description}</pre>
) : (
<span>{card.description}</span>
)}
</div>
</div>
</Card>
)
}