diff --git a/src/components/labeled-input.tsx b/src/components/labeled-input.tsx index 7a416d4..250dd5f 100644 --- a/src/components/labeled-input.tsx +++ b/src/components/labeled-input.tsx @@ -15,7 +15,7 @@ export default function LabeledInput({ name?: string; }) { return ( -
+
{ + colorType: ColorType; + logoType: LogoType; + theme: Theme; + alt?: string; +} + +const LOGO_BASE_PATH = '/assets/logo/'; +const IMAGE_EXTENSION = 'svg'; + +export default function Logo({ + colorType, + logoType, + theme, + alt, + className = '', + width, + height, + onError, + ...imageProps +}: LogoProps) { + if (!colorType || !logoType || !theme) { + const errorMessage = + 'Logo: colorType, logoType, and theme props are required.'; + console.error(errorMessage); + return ( +
+ Error: Missing required logo props. Check console. +
+ ); + } + + if (width === undefined || height === undefined) { + console.warn( + `Logo: 'width' and 'height' props are required by next/image for ${logoType} logo. Path: ${LOGO_BASE_PATH}logo_${colorType}_${logoType}_${theme}.${IMAGE_EXTENSION}`, + ); + } + + const colorTypeInFilename = colorType === 'monochrome' ? 'mono' : colorType; + const filename = `logo_${colorTypeInFilename}_${logoType}_${theme}.${IMAGE_EXTENSION}`; + const logoUrl = `${LOGO_BASE_PATH}${filename}`; + const defaultAltText = `Logo: ${colorType} ${logoType} ${theme}`; + + const handleImageError: ImageProps['onError'] = (e) => { + console.error(`Error loading logo via next/image: ${logoUrl}`, e); + if (onError) { + onError(e); + } + }; + + return ( + {alt + ); +}