7 changed files with 77 additions and 39 deletions
@ -1,36 +1,37 @@ |
|||||||
import { getCanonicalPaytoType, getPaytoEditorTypeLabel } from '@/lib/payto' |
import { getCanonicalPaytoType, getPaytoEditorTypeLabel, paytoTypeHasDisplayIcon } from '@/lib/payto' |
||||||
import PaytoTypeIcon from '@/components/PaytoTypeIcon' |
import PaytoTypeIcon from '@/components/PaytoTypeIcon' |
||||||
import { cn } from '@/lib/utils' |
import { cn } from '@/lib/utils' |
||||||
|
|
||||||
export default function SuperchatPaymentMethodLabel({ |
export default function SuperchatPaymentMethodLabel({ |
||||||
paytoType, |
paytoType, |
||||||
className, |
className, |
||||||
imgClassName, |
imgClassName |
||||||
iconOnly = false |
|
||||||
}: { |
}: { |
||||||
/** Canonical or alias payto type (`lightning`, `monero`, `geyser`, …). */ |
/** Canonical or alias payto type (`lightning`, `monero`, `geyser`, …). */ |
||||||
paytoType: string |
paytoType: string |
||||||
className?: string |
className?: string |
||||||
imgClassName?: string |
imgClassName?: string |
||||||
/** Profile wall: icon only (label in `title` for hover). */ |
/** @deprecated Icon-only when a logo/lightning/symbol exists; text label only as fallback. */ |
||||||
iconOnly?: boolean |
iconOnly?: boolean |
||||||
}) { |
}) { |
||||||
const canonical = getCanonicalPaytoType(paytoType) |
const canonical = getCanonicalPaytoType(paytoType) |
||||||
const label = getPaytoEditorTypeLabel(canonical) |
const label = getPaytoEditorTypeLabel(canonical) |
||||||
|
const showIconOnly = paytoTypeHasDisplayIcon(canonical) |
||||||
|
|
||||||
return ( |
return ( |
||||||
<span |
<span |
||||||
title={iconOnly ? label : undefined} |
title={showIconOnly ? label : undefined} |
||||||
|
aria-label={showIconOnly ? label : undefined} |
||||||
className={cn( |
className={cn( |
||||||
'inline-flex shrink-0 items-center rounded-md border border-border/60 bg-muted/40', |
'inline-flex shrink-0 items-center rounded-md border border-border/60 bg-muted/40', |
||||||
iconOnly |
showIconOnly |
||||||
? 'p-1.5 leading-none text-muted-foreground' |
? 'p-1.5 leading-none text-muted-foreground' |
||||||
: 'gap-1.5 px-2 py-1 text-sm font-semibold leading-none text-muted-foreground', |
: 'gap-1.5 px-2 py-1 text-sm font-semibold leading-none text-muted-foreground', |
||||||
className |
className |
||||||
)} |
)} |
||||||
> |
> |
||||||
<PaytoTypeIcon type={paytoType} imgClassName={imgClassName} /> |
<PaytoTypeIcon type={paytoType} imgClassName={imgClassName} /> |
||||||
{iconOnly ? null : <span className="truncate">{label}</span>} |
{showIconOnly ? null : <span className="truncate">{label}</span>} |
||||||
</span> |
</span> |
||||||
) |
) |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue