Skip to content

Commit d65832e

Browse files
committed
Reduced <Image/> repetition
- Removed repetition of the same Image component for each conditional render for the committee photos. This was done be simply turning the Image into a function called committeeImage(profilePic: string)
1 parent 07a3cca commit d65832e

1 file changed

Lines changed: 16 additions & 44 deletions

File tree

client/src/pages/about.tsx

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ export default function AboutPage() {
6262
</>
6363
);
6464

65+
function committeeImage(profilePic: string) {
66+
return (
67+
<Image
68+
src={profilePic === null ? "/landing_placeholder.png" : profilePic}
69+
alt="/landing_placeholder.png"
70+
width={134}
71+
height={144}
72+
className="h-[9rem] w-[8.4rem]"
73+
/>
74+
);
75+
}
76+
6577
if (isPending) {
6678
for (let i = 0; i < 8; i++) {
6779
if (i < 4) {
@@ -123,30 +135,10 @@ export default function AboutPage() {
123135
>
124136
<div className="relative flex h-56 w-56 items-center justify-center bg-[url('/pixel-art-frame.svg')] bg-contain bg-center bg-no-repeat">
125137
{member.pk === 0 ? (
126-
<Image
127-
src={
128-
member.profile_picture === null
129-
? "/landing_placeholder.png"
130-
: member.profile_picture
131-
}
132-
alt="/landing_placeholder.png"
133-
width={134}
134-
height={144}
135-
className="h-[9rem] w-[8.4rem]"
136-
/>
138+
committeeImage(member.profile_picture)
137139
) : (
138140
<Link href={`/members/${member.pk}`}>
139-
<Image
140-
src={
141-
member.profile_picture === null
142-
? "/landing_placeholder.png"
143-
: member.profile_picture
144-
}
145-
alt="/landing_placeholder.png"
146-
width={134}
147-
height={144}
148-
className="h-[9rem] w-[8.4rem]"
149-
/>
141+
{committeeImage(member.profile_picture)}
150142
</Link>
151143
)}
152144
</div>
@@ -176,30 +168,10 @@ export default function AboutPage() {
176168
>
177169
<div className="relative flex h-56 w-56 items-center justify-center bg-[url('/pixel-art-frame.svg')] bg-contain bg-center bg-no-repeat">
178170
{member.pk === 0 ? (
179-
<Image
180-
src={
181-
member.profile_picture === null
182-
? "/landing_placeholder.png"
183-
: member.profile_picture
184-
}
185-
alt="/landing_placeholder.png"
186-
width={134}
187-
height={144}
188-
className="h-[9rem] w-[8.4rem]"
189-
/>
171+
committeeImage(member.profile_picture)
190172
) : (
191173
<Link href={`/members/${member.pk}`}>
192-
<Image
193-
src={
194-
member.profile_picture === null
195-
? "/landing_placeholder.png"
196-
: member.profile_picture
197-
}
198-
alt="/landing_placeholder.png"
199-
width={134}
200-
height={144}
201-
className="h-[9rem] w-[8.4rem]"
202-
/>
174+
{committeeImage(member.profile_picture)}
203175
</Link>
204176
)}
205177
</div>

0 commit comments

Comments
 (0)