Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Simplify/cleanup officer data approach #37

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions src/app/about/officer-card.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
import Image from "next/image";
import { OfficerData, SocialSite } from "./officer-data";
import styles from "./OfficerCard.module.css";

export type SocialLink = {
name: string;
url: string;
icon: string;
const socialIcons: Record<SocialSite, string> = {
GitHub: "/github_logo.svg",
LinkedIn: "/linkedin_logo.png",
Website: "/web_logo.svg",
};

export type OfficerCardProps = {
position: string;
image: string;
name: string;
socialLinksData: SocialLink[];
officer: OfficerData;
};

export default function OfficerCard({
position,
image,
name,
socialLinksData,
}: OfficerCardProps) {
const socialLinks = socialLinksData.map((link) => (
<a
href={link.url}
key={link.name}
target="_blank"
rel="noopener noreferrer"
>
export default function OfficerCard({ position, officer }: OfficerCardProps) {
const socialLinks = Object.entries(officer.socials).map(([site, url]) => (
<a key={site} href={url} target="_blank" rel="noopener noreferrer">
<Image
src={link.icon}
alt={link.name}
src={socialIcons[site as SocialSite]} // cast key from Object.entries
alt={site}
height={30}
width={30}
data-name={link.name}
data-name={site}
/>
</a>
));
Expand All @@ -42,12 +31,12 @@ export default function OfficerCard({
<h3>{position}</h3>
<Image
className={styles.portrait}
src={image}
alt={`Profile picture of ${name}`}
src={officer.image}
alt={`Profile picture of ${officer.name}`}
height={180}
width={180}
/>
<h4>{name}</h4>
<h4>{officer.name}</h4>
<div className={styles.socialLinks}>{socialLinks}</div>
</div>
);
Expand Down
Loading
Loading