Skip to content

Commit 7ebad67

Browse files
authored
Merge pull request #1734 from nishtha-agarwal-211/fix/careers-testimonial-avatar
fix(layout): resolve algorithmic testimonial avatars on careers page
2 parents 196f137 + 9182dcf commit 7ebad67

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

src/pages/careers/index.tsx

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,54 @@ const testimonials = [
172172
role: "Senior Frontend Developer",
173173
content:
174174
"recode hive has given me the opportunity to work on cutting-edge projects while maintaining an amazing work-life balance. The team is incredibly supportive and collaborative.",
175-
avatar: "/img/testimonial-sarah.jpg",
175+
avatar: "/icons/vivien.png",
176176
},
177177
{
178178
name: "Marcus Johnson",
179179
role: "DevOps Engineer",
180180
content:
181181
"I love the remote-first culture here. The flexibility to work from anywhere has allowed me to travel while building my career. The learning opportunities are endless.",
182-
avatar: "/img/testimonial-marcus.jpg",
182+
avatar: "/icons/daniel.png",
183183
},
184184
{
185185
name: "Priya Patel",
186186
role: "Product Manager",
187187
content:
188188
"The growth mindset at recode hive is real. I've been able to take on new challenges and expand my skill set with full support from leadership.",
189-
avatar: "/img/testimonial-priya.jpg",
189+
avatar: "/icons/ethan.png",
190190
},
191191
];
192192

193+
function TestimonialAvatar({ avatar, name }: { avatar?: string; name: string }) {
194+
const [hasError, setHasError] = useState(false);
195+
196+
useEffect(() => {
197+
setHasError(false);
198+
}, [avatar]);
199+
200+
const showFallback = !avatar || hasError;
201+
202+
return (
203+
<div
204+
className="mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-gradient-to-br from-blue-400 to-purple-500 shadow-inner overflow-hidden relative"
205+
{...(showFallback ? { "aria-label": `Avatar for ${name}`, role: "img" } : {})}
206+
>
207+
{!showFallback ? (
208+
<img
209+
src={avatar}
210+
alt={name}
211+
loading="lazy"
212+
decoding="async"
213+
className="h-full w-full object-cover rounded-full"
214+
onError={() => setHasError(true)}
215+
/>
216+
) : (
217+
<User className="h-10 w-10 text-white" aria-hidden="true" />
218+
)}
219+
</div>
220+
);
221+
}
222+
193223
function CareersContent() {
194224
const { colorMode, isDark, mounted } = useSafeColorMode();
195225
const [activeTestimonial, setActiveTestimonial] = useState(0);
@@ -593,9 +623,10 @@ function CareersContent() {
593623
variants={fadeIn}
594624
>
595625
<div className="testimonial-content relative z-10 text-center">
596-
<div className="mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-gradient-to-br from-blue-400 to-purple-500 shadow-inner">
597-
<User className="h-10 w-10 text-white" />
598-
</div>
626+
<TestimonialAvatar
627+
avatar={testimonials[activeTestimonial].avatar}
628+
name={testimonials[activeTestimonial].name}
629+
/>
599630
<blockquote className="mb-6 text-lg italic md:text-xl">
600631
"{testimonials[activeTestimonial].content}"
601632
</blockquote>
@@ -639,9 +670,10 @@ function CareersContent() {
639670
) : (
640671
<div className="testimonial-carousel testimonial-carousel--light rounded-xl p-8 shadow-lg">
641672
<div className="testimonial-content relative z-10 text-center">
642-
<div className="mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-gradient-to-br from-blue-400 to-purple-500 shadow-inner">
643-
<User className="h-10 w-10 text-white" />
644-
</div>
673+
<TestimonialAvatar
674+
avatar={testimonials[activeTestimonial].avatar}
675+
name={testimonials[activeTestimonial].name}
676+
/>
645677
<blockquote className="mb-6 text-lg italic md:text-xl">
646678
"{testimonials[activeTestimonial].content}"
647679
</blockquote>

0 commit comments

Comments
 (0)