Skip to content

Commit 1e950c8

Browse files
committed
fix: cleanup comments, implement ellipsis suggestions.
1 parent 2eb5d21 commit 1e950c8

File tree

7 files changed

+46
-20
lines changed

7 files changed

+46
-20
lines changed

src/components/MuiLink.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@ describe("MuiLink", () => {
2020
expect(linkElement).toBeInTheDocument();
2121
expect(linkElement).toHaveAttribute("target", "_self");
2222
});
23+
24+
it("renders with aria-label attribute", () => {
25+
const { getByRole } = render(
26+
<MuiLink href="https://example.com" aria-label="Accessible link description">
27+
Example
28+
</MuiLink>,
29+
);
30+
const linkElement = getByRole("link", { name: "Accessible link description" });
31+
expect(linkElement).toBeInTheDocument();
32+
expect(linkElement).toHaveAttribute("aria-label", "Accessible link description");
33+
});
2334
});

src/components/MuiLink.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import NextLink from "next/link";
22
import { SxProps, Theme } from "@mui/material";
33
import Link from "@mui/material/Link";
4+
import { ComponentPropsWithoutRef } from "react";
45

56
export const MuiLink = ({
67
children,
78
href,
89
target = "_self",
910
sx,
11+
"aria-label": ariaLabel,
12+
...props
1013
}: {
1114
children: React.ReactNode;
1215
href: string;
1316
target?: "_self" | "_blank";
1417
sx?: SxProps<Theme>;
15-
}) => (
16-
<Link href={href} component={NextLink} target={target} sx={sx}>
18+
"aria-label"?: string;
19+
} & Omit<ComponentPropsWithoutRef<"a">, "href" | "target" | "children">) => (
20+
<Link href={href} component={NextLink} target={target} sx={sx} aria-label={ariaLabel} {...props}>
1721
{children}
1822
</Link>
1923
);

src/theme/components/Skills/SkillsExperience.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ export const SkillsExperience = ({ skills }: { skills: SkillForUser[] }) => {
3737
*
3838
*/
3939
skills.forEach((skill) => {
40-
// If yearStart isn't defined, use "0" as the object key to indicate
41-
// that there's no year. We can filter on this value later to conditionally
42-
// display a label.
4340
const year = skill?.yearStarted;
4441

4542
// The totalYears field allows users to override the value of how many years'

src/theme/default/components/ResumeHeading.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "@testing-library/jest-dom";
22
import { usePathname } from "next/navigation";
33
import { render, screen } from "@testing-library/react";
44
import { themeDefaultSampleData } from "@/theme/sampleData";
5-
import { generateSocialUrl } from "@/util/social";
5+
import { generateSocialUrl, getSocialMediaPlatformByPlatformName } from "@/util/social";
66
import { ResumeHeading } from "./ResumeHeading";
77

88
// Mock the usePathname hook
@@ -42,10 +42,14 @@ describe("ResumeHeading", () => {
4242
// Check if all social links are rendered
4343
sampleSocials.forEach((social) => {
4444
const expectedUrl = generateSocialUrl(social);
45-
const links = screen.getAllByRole("link", { name: "" });
46-
const link = links.find((link) => link.getAttribute("href") === expectedUrl);
45+
const platformName = getSocialMediaPlatformByPlatformName(social.platform).name;
46+
const expectedAriaLabel = `${platformName} profile for ${sampleUser.name}`;
47+
48+
const link = screen.getByRole("link", { name: expectedAriaLabel });
4749
expect(link).toBeInTheDocument();
50+
expect(link).toHaveAttribute("href", expectedUrl);
4851
expect(link).toHaveAttribute("target", "_blank");
52+
expect(link).toHaveAttribute("aria-label", expectedAriaLabel);
4953
});
5054
});
5155

src/theme/default/components/ResumeHeading.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { Box, Typography } from "@mui/material";
55
import { Icon } from "@iconify/react";
66
import { MuiLink } from "@/components/MuiLink";
77
import { Social, User } from "@/types";
8-
import { generateSocialUrl, getSocialIcon } from "@/util/social";
8+
import {
9+
generateSocialUrl,
10+
getSocialIcon,
11+
getSocialMediaPlatformByPlatformName,
12+
} from "@/util/social";
913

1014
export const ResumeHeading = ({ user, socials }: { user: User; socials: Social[] }) => {
1115
const pathname = usePathname();
@@ -75,11 +79,20 @@ export const ResumeHeading = ({ user, socials }: { user: User; socials: Social[]
7579
>
7680
<Box sx={{ display: "flex", gap: 2 }}>
7781
{socials
78-
? socials.map((social) => (
79-
<MuiLink href={generateSocialUrl(social)} key={social.id} target="_blank">
80-
<Icon icon={getSocialIcon(social)} width="30" height="30" />
81-
</MuiLink>
82-
))
82+
? socials.map((social) => {
83+
const platformName = getSocialMediaPlatformByPlatformName(social.platform).name;
84+
const ariaLabel = `${platformName} profile for ${user?.name || "user"}`;
85+
return (
86+
<MuiLink
87+
href={generateSocialUrl(social)}
88+
key={social.id}
89+
target="_blank"
90+
aria-label={ariaLabel}
91+
>
92+
<Icon icon={getSocialIcon(social)} width="30" height="30" />
93+
</MuiLink>
94+
);
95+
})
8396
: null}
8497
</Box>
8598
<Typography component="div" sx={{ display: "flex", gap: 2, alignItems: "center" }}>

src/theme/default/components/pdf/Skills.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ describe("Skills", () => {
2525
if (!cssSkill) throw new Error("CSS skill not found in sample data");
2626
const cssYears = currentYear - (cssSkill.yearStarted as number);
2727

28-
// Check for React's experience
28+
// Check for React Redux experience
2929
expect(screen.getByText(`${reactReduxYears} years:`)).toBeInTheDocument();
3030
expect(screen.getByText(/React Redux/)).toBeInTheDocument();
3131

32-
// Check for TypeScript's experience
32+
// Check for CSS experience
3333
expect(screen.getByText(`${cssYears} years:`)).toBeInTheDocument();
3434
expect(screen.getByText(/CSS/)).toBeInTheDocument();
3535
});

src/util/structure.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ export const groupSkillsForUserByYearExperience = (skills: SkillForUser[]) => {
3232
*
3333
*/
3434
skills.forEach((skill) => {
35-
// If yearStart isn't defined, use "0" as the object key to indicate
36-
// that there's no year. We can filter on this value later to conditionally
37-
// display a label.
3835
const year = skill?.yearStarted;
3936

4037
// The totalYears field allows users to override the value of how many years'
@@ -59,7 +56,7 @@ export const groupSkillsForUserByYearExperience = (skills: SkillForUser[]) => {
5956
// the order of the render.
6057
const skillsExperienceList: [string, SkillForUser[]][] = [];
6158

62-
Object.keys(skillsByYear).map((totalYears) => {
59+
Object.keys(skillsByYear).forEach((totalYears) => {
6360
skillsExperienceList.push([totalYears, skillsByYear[totalYears]]);
6461
});
6562

0 commit comments

Comments
 (0)