All files / components/common ProviderLogo.tsx

80% Statements 4/5
60% Branches 3/5
100% Functions 1/1
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                      3x           88x   88x 88x                                                                  
import React from 'react';
import { Settings } from 'lucide-react';
import { cn } from '@/lib/utils';
 
interface ProviderLogoProps {
    logoUrl?: string | null;
    providerName: string;
    className?: string;
    size?: number | string;
}
 
export const ProviderLogo: React.FC<ProviderLogoProps> = ({
    logoUrl,
    providerName,
    className,
    size = 24,
}) => {
    const pixelSize = typeof size === 'number' ? `${size}px` : size;
 
    Eif (!logoUrl) {
        return (
            <div
                className={cn(
                    "bg-secondary rounded-full flex items-center justify-center shrink-0",
                    className
                )}
                style={{ width: pixelSize, height: pixelSize }}
            >
                <Settings style={{ width: `calc(${pixelSize} * 0.6)`, height: `calc(${pixelSize} * 0.6)` }} />
            </div>
        );
    }
 
    return (
        <div
            className={cn("shrink-0 bg-current", className)}
            style={{
                width: pixelSize,
                height: pixelSize,
                maskImage: `url(${logoUrl})`,
                maskRepeat: 'no-repeat',
                maskPosition: 'center',
                maskSize: 'contain',
                WebkitMaskImage: `url(${logoUrl})`,
                WebkitMaskRepeat: 'no-repeat',
                WebkitMaskPosition: 'center',
                WebkitMaskSize: 'contain',
            }}
            aria-label={`${providerName} logo`}
            role="img"
        />
    );
};