From cf4185d8901457a23c8970beb078a5e3639f4566 Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:50 +0530 Subject: [PATCH] feat: add client logo component --- app/components/ui/client-logo.tsx | 82 +++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 app/components/ui/client-logo.tsx diff --git a/app/components/ui/client-logo.tsx b/app/components/ui/client-logo.tsx new file mode 100644 index 0000000..1a0bcaa --- /dev/null +++ b/app/components/ui/client-logo.tsx @@ -0,0 +1,82 @@ +import { cva } from 'class-variance-authority'; +import { cn } from '~/lib/utils'; +import type { BrandIdentity } from '~/types/project'; + +const frame = cva('inline-flex shrink-0 items-center justify-center overflow-hidden leading-none', { + variants: { + variant: { + // Rounded backing chip: AR page, asset header + chip: 'ring-1 ring-inset', + // The logo on its own at chip size: AR page with the backing turned off + bare: '', + // Bare logo: admin tiles that already have a coloured background + plain: '', + // Square tile with the logo (or first letter): sidebar, QR centre, project chips + mark: 'ring-1 ring-inset', + }, + size: { xs: '', sm: '', md: '', lg: '', fill: '' }, + background: { light: '', dark: '' }, + }, + compoundVariants: [ + // Fills the box it is placed in (admin logo tiles) + { variant: 'plain', size: 'fill', className: 'h-full w-full' }, + { variant: ['chip', 'mark'], background: 'light', className: 'bg-logo-chip-light ring-shadow/[0.07] shadow-xs' }, + { variant: ['chip', 'mark'], background: 'dark', className: 'bg-logo-chip-dark ring-text-primary/[0.08]' }, + { variant: 'chip', size: ['xs', 'sm'], className: 'gap-1.5 rounded-option px-2 py-1.5' }, + { variant: 'chip', size: ['md', 'lg'], className: 'gap-2 rounded-item px-2.5 py-[7px]' }, + { variant: 'mark', size: 'xs', className: 'h-[17px] w-[17px] rounded-[4px] p-0.5' }, + { variant: 'mark', size: 'sm', className: 'h-5 w-5 rounded-[5px] p-0.5' }, + { variant: 'mark', size: 'md', className: 'h-[30px] w-[30px] rounded-option p-1' }, + { variant: 'mark', size: 'lg', className: 'h-12 w-12 rounded-card-sm p-1.5' }, + ], +}); + +const image = cva('object-contain', { + variants: { + variant: { chip: 'w-auto max-w-[140px]', bare: 'w-auto max-w-[160px]', plain: 'w-auto max-w-[70%]', mark: 'h-full w-full' }, + size: { xs: '', sm: '', md: '', lg: '', fill: '' }, + }, + compoundVariants: [ + { variant: 'plain', size: 'fill', className: 'h-full w-full max-w-none' }, + { variant: 'chip', size: ['xs', 'sm'], className: 'h-3.5' }, + { variant: 'chip', size: ['md', 'lg'], className: 'h-[18px]' }, + // No chip padding, so the logo itself can be larger + { variant: 'bare', size: ['xs', 'sm'], className: 'h-5' }, + { variant: 'bare', size: ['md', 'lg'], className: 'h-7' }, + { variant: 'plain', size: 'sm', className: 'max-h-7' }, + { variant: 'plain', size: 'md', className: 'max-h-9' }, + { variant: 'plain', size: 'lg', className: 'max-h-12' }, + ], +}); + +const fallback = cva('whitespace-nowrap font-semibold tracking-[-0.01em]', { + variants: { + size: { xs: 'text-3xs', sm: 'text-2xs', md: 'text-sm', lg: 'text-xl', fill: 'text-xl' }, + background: { light: 'text-ink', dark: 'text-text-primary' }, + }, +}); + +interface ClientLogoProps { + brand: BrandIdentity; + variant?: 'chip' | 'bare' | 'plain' | 'mark'; + size?: 'xs' | 'sm' | 'md' | 'lg' | 'fill'; + className?: string; +} + +// A client's uploaded logo, or their company name when no logo has been added +export function ClientLogo({ brand, variant = 'chip', size = 'md', className }: ClientLogoProps) { + const background = brand.logoBg; + const text = variant === 'mark' ? brand.name.trim().charAt(0).toUpperCase() || '?' : brand.name; + return ( + + {brand.logoUrl ? ( + {brand.name} + ) : ( + {text} + )} + + ); +}