Skip to content

Commit

Permalink
Feat: Add multiple links in Summery xitanggg#124
Browse files Browse the repository at this point in the history
Requirement: Add multiple links (LinkedIn, GitHub) in summary

Support Added:
1. Added Portfolio, LinkedIn and GitHub links in the summary
2. Removed url from `ResumeProfile` type and introduced `portfolioLink, linkedinLink, githubLink` keys.
3. Modified UI in order to reflect links in the Form.
4. Updated logic to redirect if only username is present.
  • Loading branch information
prajwalprogrammer committed Nov 16, 2024
1 parent 4f8255a commit c6eac2e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
35 changes: 25 additions & 10 deletions src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const ResumePDFProfile = ({
themeColor: string;
isPDF: boolean;
}) => {
const { name, email, phone, url, summary, location } = profile;
const iconProps = { email, phone, location, url };
const { name, email, phone, portfolioLink, linkedinLink, githubLink, summary, location } = profile;
const iconProps = { email, phone, location,portfolioLink, linkedinLink, githubLink };

return (
<ResumePDFSection style={{ marginTop: spacing["4"] }}>
Expand All @@ -38,21 +38,28 @@ export const ResumePDFProfile = ({
...styles.flexRowBetween,
flexWrap: "wrap",
marginTop: spacing["0.5"],
justifyContent: "center",
alignContent: "center",
gap:spacing["2.5"],
}}
>
{Object.entries(iconProps).map(([key, value]) => {
if (!value) return null;

let iconType = key as IconType;
if (key === "url") {
if (value.includes("github")) {
iconType = "url_github";
} else if (value.includes("linkedin")) {
switch (key) {
case "portfolioLink":
iconType = "url";
break;
case "linkedinLink":
iconType = "url_linkedin";
}
break;
case "githubLink":
iconType = "url_github";
break;
}

const shouldUseLinkWrapper = ["email", "url", "phone"].includes(key);
const shouldUseLinkWrapper = ["email", "phone", "portfolioLink", "linkedinLink", "githubLink"].includes(key);
const Wrapper = ({ children }: { children: React.ReactNode }) => {
if (!shouldUseLinkWrapper) return <>{children}</>;

Expand All @@ -66,6 +73,14 @@ export const ResumePDFProfile = ({
src = `tel:${value.replace(/[^\d+]/g, "")}`; // Keep only + and digits
break;
}
case "linkedinLink": {
src = value.startsWith("http") ? value : `https://www.linkedin.com/in/${value}`;
break;
}
case "githubLink": {
src = value.startsWith("http") ? value : `https://github.com/${value}`;
break;
}
default: {
src = value.startsWith("http") ? value : `https://${value}`;
}
Expand All @@ -83,8 +98,8 @@ export const ResumePDFProfile = ({
key={key}
style={{
...styles.flexRow,
alignItems: "center",
gap: spacing["1"],
gap: spacing["2"],
flex: "0 1 calc(33.333% - 10px)",
}}
>
<ResumePDFIcon type={iconType} isPDF={isPDF} />
Expand Down
26 changes: 21 additions & 5 deletions src/app/components/ResumeForm/ProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ResumeProfile } from "lib/redux/types";
export const ProfileForm = () => {
const profile = useAppSelector(selectProfile);
const dispatch = useAppDispatch();
const { name, email, phone, url, summary, location } = profile;
const { name, email, phone, summary, location, portfolioLink, linkedinLink, githubLink } = profile;

const handleProfileChange = (field: keyof ResumeProfile, value: string) => {
dispatch(changeProfile({ field, value }));
Expand Down Expand Up @@ -49,11 +49,11 @@ export const ProfileForm = () => {
onChange={handleProfileChange}
/>
<Input
label="Website"
label="Portfolio"
labelClassName="col-span-4"
name="url"
placeholder="linkedin.com/in/khanacademy"
value={url}
name="portfolioLink"
placeholder="khanacademy.com"
value={portfolioLink}
onChange={handleProfileChange}
/>
<Input
Expand All @@ -64,6 +64,22 @@ export const ProfileForm = () => {
value={location}
onChange={handleProfileChange}
/>
<Input
label="LinkedIn Username"
labelClassName="col-span-3"
name="linkedinLink"
placeholder="linkedin.com/in/khanacademy"
value={linkedinLink}
onChange={handleProfileChange}
/>
<Input
label="Github Username"
labelClassName="col-span-3"
name="githubLink"
placeholder="github.com/khanacademy"
value={githubLink}
onChange={handleProfileChange}
/>
</div>
</BaseForm>
);
Expand Down
4 changes: 3 additions & 1 deletion src/app/lib/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ export interface ResumeProfile {
name: string;
email: string;
phone: string;
url: string;
summary: string;
location: string;
portfolioLink: string;
linkedinLink: string;
githubLink: string;
}

export interface ResumeWorkExperience {
Expand Down

0 comments on commit c6eac2e

Please sign in to comment.