GEN-2: surface Farbschlag images (FarbschlagImage component) in breeding results, animal detail, form picker
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
gerbil-manager-web/src/components/FarbschlagImage.tsx
Normal file
25
gerbil-manager-web/src/components/FarbschlagImage.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { farbschlagImageUrl, findVariety } from '../genetics'
|
||||
import './FarbschlagImage.css'
|
||||
|
||||
export interface FarbschlagImageProps {
|
||||
/** Variety name; may include " Schecke"/" Rex" modifiers (stripped for lookup). */
|
||||
name: string
|
||||
size?: number
|
||||
}
|
||||
|
||||
/** Thumbnail for a Farbschlag, or null if the variety has no catalog image. */
|
||||
export default function FarbschlagImage({ name, size = 40 }: FarbschlagImageProps) {
|
||||
const baseName = name.replace(/\s+(Schecke|Rex)\b/g, '').trim()
|
||||
const url = farbschlagImageUrl(findVariety(baseName)?.image ?? findVariety(name)?.image)
|
||||
if (!url) return null
|
||||
return (
|
||||
<img
|
||||
className="farbschlag-thumb"
|
||||
src={url}
|
||||
alt={name}
|
||||
width={size}
|
||||
height={size}
|
||||
loading="lazy"
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user