Skip to content

Commit 945f4ca

Browse files
authored
Merge pull request #17 from oslabs-beta/customhook
Fixed 404 Image Error on website
2 parents 7dccae9 + da13fcd commit 945f4ca

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

www/src/pages/components/TeamSection.tsx

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Image from 'next/image'
2+
import { useState } from 'react';
23

34
const people: string[][] = [
45
["Alex Gomez", "alexgomez9"],
@@ -76,7 +77,7 @@ function replace(e: React.SyntheticEvent<HTMLImageElement>): void{
7677
e.currentTarget.onerror = null;
7778
e.currentTarget.src = "/profileFallback.png"
7879
}
79-
80+
8081
export default function People(): JSX.Element {
8182
return (
8283
<div className="bg-white">
@@ -85,31 +86,49 @@ function replace(e: React.SyntheticEvent<HTMLImageElement>): void{
8586
<div className="space-y-5 sm:mx-auto sm:max-w-xl sm:space-y-4 lg:max-w-5xl">
8687
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl">Our Contributors</h2>
8788
<p className="text-xl text-gray-500">
88-
{/* Risus velit condimentum vitae tincidunt tincidunt. Mauris ridiculus fusce amet urna nunc. Ut nisl ornare
89-
diam in. */}
89+
All of the people who make Reactime awesome!
9090
</p>
9191
</div>
9292
<ul
9393
role="list"
9494
className="mx-auto grid grid-cols-2 gap-x-8 gap-y-8 sm:grid-cols-4 md:gap-x-6 lg:max-w-5xl lg:gap-x-8 lg:gap-y-12 xl:grid-cols-8"
9595
>
96-
{people.map((person) => person && (
97-
<li key={person[1]} >
98-
<div className="space-y-4">
99-
<img className="mx-auto h-20 w-20 rounded-full lg:h-24 lg:w-24" src={`https://github.com/${person[1]}.png`} onError={(e) => replace(e)} />
100-
<div className="space-y-2">
101-
<div className="text-xs font-medium lg:text-sm">
102-
<h3>{person[0]}</h3>
103-
<a href={`https://github.com/${person[1]}`} className="text-rose-500">{person[1]}</a>
104-
</div>
105-
</div>
106-
</div>
107-
</li>
108-
))}
96+
<>
97+
{people.map((person)=>(
98+
<Profile key={person[1]} profile={person[1]} name={person[0]}/>
99+
))}
100+
</>
109101
</ul>
110102
</div>
111103
</div>
112104
</div>
113105
)
114106
}
115-
107+
type profileType = {
108+
profile: string | undefined,
109+
name: string | undefined,
110+
}
111+
function Profile({profile, name}: profileType) {
112+
const [imageError, setImageError] = useState(false);
113+
return (
114+
<div className="space-y-4">
115+
<Image
116+
width={100}
117+
height={100}
118+
src={imageError ? "/profileFallback.png" : 'https://github.com/' + profile + '.png'}
119+
className="mx-auto h-20 w-20 rounded-full lg:h-24 lg:w-24"
120+
onError={(e) => setImageError(true)}
121+
alt="missing-profile-image"
122+
/>
123+
<div className="space-y-2">
124+
<div className="text-xs font-medium lg:text-sm">
125+
<h3>{name}</h3>
126+
<a target="_blank" href={`https://github.com/${profile}`} className="text-rose-500">{profile}</a>
127+
</div>
128+
</div>
129+
</div>
130+
)
131+
}
132+
133+
134+

0 commit comments

Comments
 (0)