11"use client" ;
22
3+ import React , { useState } from "react" ;
34import Image from "next/image" ;
45import { colors } from "@/config/colors" ;
56
@@ -10,38 +11,40 @@ export function SponsorCard({
1011 sponsor : any ;
1112 tier : string ;
1213} ) {
14+ const [ imgError , setImgError ] = useState ( false ) ;
15+
16+ const hasLogo = ! ! sponsor ?. logo ;
17+
1318 return (
1419 < div className = "p-6 rounded-lg shadow-lg flex flex-col items-center text-center transition-transform duration-200 hover:scale-105 bg-transparent" >
1520 < div className = "flex flex-col items-center w-full" >
1621 < div className = "flex items-center justify-center w-full h-32 mb-4" >
17- < Image
18- src = { `/sponsors/${ sponsor . logo } ` }
19- alt = { `${ sponsor . name } logo` }
20- width = { sponsor . logo === "BaskinEngineeringLogo.png" ? 240 : 180 }
21- height = { sponsor . logo === "BaskinEngineeringLogo.png" ? 160 : 120 }
22- className = "object-contain max-w-full max-h-full"
23- style = { { display : "block" } }
24- onError = { ( e ) => {
25- console . warn ( 'Image load failed:' , sponsor . logo ) ;
26- const img = e . currentTarget ;
27- img . style . display = "none" ;
28- const fallback =
29- img . parentElement ?. querySelector ( ".fallback-text" ) ;
30- if ( fallback ) {
31- ( fallback as HTMLElement ) . style . display = "flex" ;
32- }
33- } }
34- />
35- < div
36- className = "fallback-text w-full h-full items-center justify-center text-4xl font-bold hidden"
37- style = { { color : colors . primary , display : "none" } }
38- >
39- { sponsor . name . charAt ( 0 ) }
40- </ div >
22+ { hasLogo && ! imgError ? (
23+ < Image
24+ src = { `/sponsors/${ sponsor . logo } ` }
25+ alt = { `${ sponsor . name ?? "Sponsor" } logo` }
26+ width = { sponsor . logo === "BaskinEngineeringLogo.png" ? 240 : 180 }
27+ height = { sponsor . logo === "BaskinEngineeringLogo.png" ? 160 : 120 }
28+ className = "object-contain max-w-full max-h-full"
29+ onError = { ( ) => {
30+ console . warn ( "Image load failed:" , sponsor . logo ) ;
31+ setImgError ( true ) ;
32+ } }
33+ />
34+ ) : (
35+ < div className = "w-full h-full flex items-center justify-center px-2" >
36+ < span
37+ className = "text-base sm:text-lg md:text-xl lg:text-2xl font-semibold"
38+ style = { { color : '#ffffff' , fontFamily : "'Scandia Bold Italic', sans-serif" } }
39+ >
40+ { sponsor ?. name ?? "Sponsor" }
41+ </ span >
42+ </ div >
43+ ) }
4144 </ div >
4245 </ div >
4346 < div className = "mt-2" >
44- { sponsor . website !== "#" && (
47+ { sponsor ?. website && sponsor . website !== "#" && (
4548 < a
4649 href = { sponsor . website }
4750 target = "_blank"
0 commit comments