Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat: add support for multiple resume layouts with simple and professional templates

Khuram Niaz21ac8b6e7f08
diff --git a/src/components/profile/ResumeContainer.tsx b/src/components/profile/ResumeContainer.tsx
index 97123d7..89f5578 100644
--- a/src/components/profile/ResumeContainer.tsx
+++ b/src/components/profile/ResumeContainer.tsx
@@ -16,8 +16,12 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from "../ui/dropdown-menu";
+import type { ResumeLayout } from "./resume-pdf";
import {
AlertDialog,
AlertDialogAction,
@@ -381,7 +385,7 @@ function ResumeContainer({ resume }: { resume: Resume }) {
router.refresh();
};
- const handleExportPdf = async () => {
+ const handleExportPdf = async (layout: ResumeLayout) => {
const hasName =
resume.ContactInfo?.firstName?.trim() || resume.ContactInfo?.lastName?.trim();
const hasSections = resume.ResumeSections?.some(
@@ -404,7 +408,7 @@ function ResumeContainer({ resume }: { resume: Resume }) {
setIsExporting(true);
try {
const { generateResumePdfBlob } = await import("./resume-pdf");
- const { blob, filename } = await generateResumePdfBlob(resume);
+ const { blob, filename } = await generateResumePdfBlob(resume, layout);
if (!resume.FileId) {
triggerDownload(blob, filename);
@@ -498,14 +502,31 @@ function ResumeContainer({ resume }: { resume: Resume }) {
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
- <DropdownMenuItem
- className="cursor-pointer"
- onClick={handleExportPdf}
- disabled={isExporting}
- >
- <FileDown className="h-4 w-4 mr-2" />
- {isExporting ? "Generating…" : "Export to PDF"}
- </DropdownMenuItem>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger
+ className="cursor-pointer"
+ disabled={isExporting}
+ >
+ <FileDown className="h-4 w-4 mr-2" />
+ {isExporting ? "Generating…" : "Export to PDF"}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => handleExportPdf("simple")}
+ disabled={isExporting}
+ >
+ Simple
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => handleExportPdf("professional")}
+ disabled={isExporting}
+ >
+ Professional
+ </DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
</div>
diff --git a/src/components/profile/resume-pdf/ProfessionalTemplate.tsx b/src/components/profile/resume-pdf/ProfessionalTemplate.tsx
index 86ad5f3..27883d5 100644
--- a/src/components/profile/resume-pdf/ProfessionalTemplate.tsx
+++ b/src/components/profile/resume-pdf/ProfessionalTemplate.tsx
@@ -1,8 +1,8 @@
import React from "react";
import { Document, Page, Text, View } from "@react-pdf/renderer";
import { format } from "date-fns";
-import { Resume, SectionType } from "@/models/profile.model";
-import { styles, SectionHeading } from "./primitives";
+import { Resume, ResumeSection, SectionType } from "@/models/profile.model";
+import { professionalStyles as s } from "./styles/professional.styles";
import { ResumeHtmlNodes } from "./generateResumePdf";
function formatDate(date: Date | undefined | null): string {
@@ -10,6 +10,48 @@ function formatDate(date: Date | undefined | null): string {
return format(new Date(date), "MMM yyyy");
}
+function yearRange(startDate: Date, endDate?: Date | null): string {
+ const start = format(new Date(startDate), "yyyy");
+ const end = endDate ? format(new Date(endDate), "yyyy") : "Present";
+ return `${start} – ${end}`;
+}
+
+function SectionHeading({ title }: { title: string }) {
+ return (
+ <View style={s.sectionHeadingRow}>
+ <Text style={s.sectionHeadingLabel}>{title}</Text>
+ <View style={s.sectionHeadingRule} />
+ </View>
+ );
+}
+
+// Renders sections that use licenseOrCertifications (CERTIFICATION, LICENSE, COURSE, etc.)
+function CertLikeSection({ section }: { section: ResumeSection }) {
+ const entries = section.licenseOrCertifications;
+ if (!entries || entries.length === 0) return null;
+ return (
+ <View>
+ <SectionHeading title={section.sectionTitle} />
+ {entries.map((cert, i) => (
+ <View key={cert.id ?? i} style={{ marginBottom: 6 }} wrap={false}>
+ <Text style={s.entryTitle}>{cert.title}</Text>
+ <Text style={s.entryMeta}>{cert.organization}</Text>
+ {(cert.issueDate || cert.expirationDate) && (
+ <Text style={s.entryMeta}>
+ {cert.issueDate ? `Issued: ${formatDate(cert.issueDate)}` : ""}
+ {cert.issueDate && cert.expirationDate ? " · " : ""}
+ {cert.expirationDate ? `Expires: ${formatDate(cert.expirationDate)}` : ""}
+ </Text>
+ )}
+ {cert.credentialUrl && (
+ <Text style={s.entryMeta}>{cert.credentialUrl}</Text>
+ )}
+ </View>
+ ))}
+ </View>
+ );
+}
+
type Props = {
resume: Resume;
htmlNodes: ResumeHtmlNodes;
@@ -18,21 +60,31 @@ type Props = {
export function ProfessionalResumeDocument({ resume, htmlNodes }: Props) {
const { ContactInfo, ResumeSections } = resume;
+ const summarySection = ResumeSections?.find(
+ (sec) => sec.sectionType === SectionType.SUMMARY,
+ );
const experienceSection = ResumeSections?.find(
- (s) => s.sectionType === SectionType.EXPERIENCE,
+ (sec) => sec.sectionType === SectionType.EXPERIENCE,
);
const educationSection = ResumeSections?.find(
- (s) => s.sectionType === SectionType.EDUCATION,
- );
- const certificationSection = ResumeSections?.find(
- (s) => s.sectionType === SectionType.CERTIFICATION,
+ (sec) => sec.sectionType === SectionType.EDUCATION,
);
+ // All sections that render in the two-column area (right column)
+ const certLikeSections = ResumeSections?.filter((sec) =>
+ [SectionType.CERTIFICATION, SectionType.LICENSE].includes(sec.sectionType),
+ ) ?? [];
+
+ // Sections that don't fit the standard categories — rendered as experience-like blocks
+ const otherSections = ResumeSections?.filter((sec) =>
+ [SectionType.COURSE, SectionType.PROJECT, SectionType.OTHER].includes(sec.sectionType),
+ ) ?? [];
+
const contactParts = [
- ContactInfo?.email,
- ContactInfo?.phone,
ContactInfo?.address,
- ].filter(Boolean);
+ ContactInfo?.phone,
+ ContactInfo?.email,
+ ].filter(Boolean) as string[];
return (
<Document
@@ -41,47 +93,54 @@ export function ProfessionalResumeDocument({ resume, htmlNodes }: Props) {
producer="react-pdf"
title={resume.title}
>
- <Page size="A4" style={styles.page} wrap>
+ <Page size="A4" style={s.page} wrap>
{/* Header */}
{ContactInfo && (
- <View style={{ marginBottom: 12 }}>
- <Text style={styles.heading}>
- {ContactInfo.firstName} {ContactInfo.lastName}
- </Text>
- {ContactInfo.headline ? (
- <Text style={styles.subheading}>{ContactInfo.headline}</Text>
- ) : null}
- {contactParts.length > 0 ? (
- <Text style={styles.contactLine}>{contactParts.join(" · ")}</Text>
- ) : null}
+ <View style={s.headerRow}>
+ <View style={s.headerLeft}>
+ <Text style={s.name}>
+ {ContactInfo.firstName} {ContactInfo.lastName}
+ </Text>
+ {ContactInfo.headline ? (
+ <Text style={s.headline}>{ContactInfo.headline}</Text>
+ ) : null}
+ </View>
+ {contactParts.length > 0 && (
+ <View style={s.headerRight}>
+ {contactParts.map((part, i) => (
+ <Text key={i} style={s.contactLine}>
+ {part}
+ </Text>
+ ))}
+ </View>
+ )}
</View>
)}
- {/* Summary */}
- {htmlNodes.summary.length > 0 && (
- <View>
- <SectionHeading title="Summary" />
- {htmlNodes.summary}
- </View>
+ {/* Thick rule */}
+ <View style={s.thickRule} />
+
+ {/* Summary — no section heading */}
+ {summarySection?.summary?.content && htmlNodes.summary.length > 0 && (
+ <View style={{ marginBottom: 4 }}>{htmlNodes.summary}</View>
)}
{/* Experience */}
{experienceSection?.workExperiences &&
experienceSection.workExperiences.length > 0 && (
<View>
- <SectionHeading title="Experience" />
+ <SectionHeading title={experienceSection.sectionTitle} />
{experienceSection.workExperiences.map((exp, i) => (
- <View
- key={exp.id ?? i}
- style={{ marginBottom: 8 }}
- wrap={false}
- >
- <Text style={styles.entryTitle}>
- {exp.jobTitle.label} — {exp.Company.label}
- </Text>
- <Text style={styles.entryMeta}>
- {formatDate(exp.startDate)} – {formatDate(exp.endDate)} ·{" "}
- {exp.location.label}
+ <View key={exp.id ?? i} style={{ marginBottom: 8 }} wrap={false}>
+ <View style={s.entryHeaderRow}>
+ <Text style={s.entryTitle}>{exp.jobTitle.label}</Text>
+ <Text style={s.entryDate}>
+ {formatDate(exp.startDate)} – {formatDate(exp.endDate)}
+ </Text>
+ </View>
+ <Text style={s.entryMeta}>
+ {exp.Company.label}
+ {exp.location?.label ? ` · ${exp.location.label}` : ""}
</Text>
{htmlNodes.experiences[i]}
</View>
@@ -89,63 +148,66 @@ export function ProfessionalResumeDocument({ resume, htmlNodes }: Props) {
</View>
)}
- {/* Education */}
- {educationSection?.educations &&
- educationSection.educations.length > 0 && (
- <View>
- <SectionHeading title="Education" />
- {educationSection.educations.map((edu, i) => (
- <View
- key={edu.id ?? i}
- style={{ marginBottom: 8 }}
- wrap={false}
- >
- <Text style={styles.entryTitle}>{edu.institution}</Text>
- <Text style={styles.entryMeta}>
- {[edu.degree, edu.fieldOfStudy].filter(Boolean).join(", ")}
- </Text>
- <Text style={styles.entryMeta}>
- {formatDate(edu.startDate)} –{" "}
- {edu.endDate ? formatDate(edu.endDate) : "Present"} ·{" "}
- {edu.location.label}
- </Text>
- {htmlNodes.educations[i]}
+ {/* Other sections with work-experience-like entries (PROJECT, COURSE, OTHER) */}
+ {otherSections.map((sec) => {
+ if (sec.workExperiences && sec.workExperiences.length > 0) {
+ return (
+ <View key={sec.id}>
+ <SectionHeading title={sec.sectionTitle} />
+ {sec.workExperiences.map((exp, i) => (
+ <View key={exp.id ?? i} style={{ marginBottom: 8 }} wrap={false}>
+ <View style={s.entryHeaderRow}>
+ <Text style={s.entryTitle}>{exp.jobTitle.label}</Text>
+ <Text style={s.entryDate}>
+ {formatDate(exp.startDate)} – {formatDate(exp.endDate)}
+ </Text>
+ </View>
+ <Text style={s.entryMeta}>
+ {exp.Company.label}
+ {exp.location?.label ? ` · ${exp.location.label}` : ""}
+ </Text>
+ </View>
+ ))}
+ </View>
+ );
+ }
+ if (sec.licenseOrCertifications && sec.licenseOrCertifications.length > 0) {
+ return <CertLikeSection key={sec.id} section={sec} />;
+ }
+ return null;
+ })}
+
+ {/* Two-column: Education (left) + Cert-like sections (right) */}
+ {(educationSection?.educations?.length || certLikeSections.some((sec) => sec.licenseOrCertifications?.length)) ? (
+ <View style={s.twoColRow} wrap>
+ {/* Left: Education */}
+ <View style={s.twoColLeft}>
+ {educationSection?.educations && educationSection.educations.length > 0 && (
+ <View>
+ <SectionHeading title={educationSection.sectionTitle} />
+ {educationSection.educations.map((edu, i) => (
+ <View key={edu.id ?? i} style={{ marginBottom: 8 }}>
+ <Text style={s.entryTitle}>
+ {[edu.degree, edu.fieldOfStudy].filter(Boolean).join(", ")}
+ </Text>
+ <Text style={s.entryMeta}>{edu.institution}</Text>
+ <Text style={s.entryMeta}>
+ {yearRange(edu.startDate, edu.endDate)}
+ </Text>
+ </View>
+ ))}
</View>
- ))}
+ )}
</View>
- )}
- {/* Certifications */}
- {certificationSection?.licenseOrCertifications &&
- certificationSection.licenseOrCertifications.length > 0 && (
- <View>
- <SectionHeading title="Certifications" />
- {certificationSection.licenseOrCertifications.map((cert, i) => (
- <View
- key={cert.id ?? i}
- style={{ marginBottom: 6 }}
- wrap={false}
- >
- <Text style={styles.entryTitle}>{cert.title}</Text>
- <Text style={styles.entryMeta}>{cert.organization}</Text>
- {(cert.issueDate || cert.expirationDate) && (
- <Text style={styles.entryMeta}>
- {cert.issueDate
- ? `Issued: ${formatDate(cert.issueDate)}`
- : ""}
- {cert.issueDate && cert.expirationDate ? " · " : ""}
- {cert.expirationDate
- ? `Expires: ${formatDate(cert.expirationDate)}`
- : ""}
- </Text>
- )}
- {cert.credentialUrl && (
- <Text style={styles.entryMeta}>{cert.credentialUrl}</Text>
- )}
- </View>
+ {/* Right: Certifications and Licenses */}
+ <View style={s.twoColRight}>
+ {certLikeSections.map((sec) => (
+ <CertLikeSection key={sec.id} section={sec} />
))}
</View>
- )}
+ </View>
+ ) : null}
</Page>
</Document>
);
diff --git a/src/components/profile/resume-pdf/SimpleTemplate.tsx b/src/components/profile/resume-pdf/SimpleTemplate.tsx
new file mode 100644
index 0000000..bc27766
--- /dev/null
+++ b/src/components/profile/resume-pdf/SimpleTemplate.tsx
@@ -0,0 +1,149 @@
+import React from "react";
+import { Document, Page, Text, View } from "@react-pdf/renderer";
+import { format } from "date-fns";
+import { Resume, SectionType } from "@/models/profile.model";
+import { simpleStyles } from "./styles/simple.styles";
+import { ResumeHtmlNodes } from "./generateResumePdf";
+
+function formatDate(date: Date | undefined | null): string {
+ if (!date) return "Present";
+ return format(new Date(date), "MMM yyyy");
+}
+
+function SectionHeading({ title }: { title: string }) {
+ return (
+ <View>
+ <Text style={simpleStyles.sectionTitle}>{title}</Text>
+ <View style={simpleStyles.divider} />
+ </View>
+ );
+}
+
+type Props = {
+ resume: Resume;
+ htmlNodes: ResumeHtmlNodes;
+};
+
+export function SimpleResumeDocument({ resume, htmlNodes }: Props) {
+ const { ContactInfo, ResumeSections } = resume;
+
+ const experienceSection = ResumeSections?.find(
+ (s) => s.sectionType === SectionType.EXPERIENCE,
+ );
+ const educationSection = ResumeSections?.find(
+ (s) => s.sectionType === SectionType.EDUCATION,
+ );
+ const certificationSection = ResumeSections?.find(
+ (s) => s.sectionType === SectionType.CERTIFICATION,
+ );
+
+ const contactParts = [
+ ContactInfo?.email,
+ ContactInfo?.phone,
+ ContactInfo?.address,
+ ].filter(Boolean);
+
+ return (
+ <Document
+ author={`${ContactInfo?.firstName ?? ""} ${ContactInfo?.lastName ?? ""}`.trim()}
+ creator="jobsync.ca"
+ producer="react-pdf"
+ title={resume.title}
+ >
+ <Page size="A4" style={simpleStyles.page} wrap>
+ {/* Header */}
+ {ContactInfo && (
+ <View style={{ marginBottom: 12 }}>
+ <Text style={simpleStyles.heading}>
+ {ContactInfo.firstName} {ContactInfo.lastName}
+ </Text>
+ {ContactInfo.headline ? (
+ <Text style={simpleStyles.subheading}>{ContactInfo.headline}</Text>
+ ) : null}
+ {contactParts.length > 0 ? (
+ <Text style={simpleStyles.contactLine}>{contactParts.join(" · ")}</Text>
+ ) : null}
+ </View>
+ )}
+
+ {/* Summary */}
+ {htmlNodes.summary.length > 0 && (
+ <View>
+ <SectionHeading title="Summary" />
+ {htmlNodes.summary}
+ </View>
+ )}
+
+ {/* Experience */}
+ {experienceSection?.workExperiences &&
+ experienceSection.workExperiences.length > 0 && (
+ <View>
+ <SectionHeading title={experienceSection.sectionTitle} />
+ {experienceSection.workExperiences.map((exp, i) => (
+ <View key={exp.id ?? i} style={{ marginBottom: 8 }} wrap={false}>
+ <Text style={simpleStyles.entryTitle}>
+ {exp.jobTitle.label} — {exp.Company.label}
+ </Text>
+ <Text style={simpleStyles.entryMeta}>
+ {formatDate(exp.startDate)} – {formatDate(exp.endDate)} ·{" "}
+ {exp.location.label}
+ </Text>
+ {htmlNodes.experiences[i]}
+ </View>
+ ))}
+ </View>
+ )}
+
+ {/* Education */}
+ {educationSection?.educations &&
+ educationSection.educations.length > 0 && (
+ <View>
+ <SectionHeading title={educationSection.sectionTitle} />
+ {educationSection.educations.map((edu, i) => (
+ <View key={edu.id ?? i} style={{ marginBottom: 8 }} wrap={false}>
+ <Text style={simpleStyles.entryTitle}>{edu.institution}</Text>
+ <Text style={simpleStyles.entryMeta}>
+ {[edu.degree, edu.fieldOfStudy].filter(Boolean).join(", ")}
+ </Text>
+ <Text style={simpleStyles.entryMeta}>
+ {formatDate(edu.startDate)} –{" "}
+ {edu.endDate ? formatDate(edu.endDate) : "Present"} ·{" "}
+ {edu.location.label}
+ </Text>
+ {htmlNodes.educations[i]}
+ </View>
+ ))}
+ </View>
+ )}
+
+ {/* Certifications */}
+ {certificationSection?.licenseOrCertifications &&
+ certificationSection.licenseOrCertifications.length > 0 && (
+ <View>
+ <SectionHeading title={certificationSection.sectionTitle} />
+ {certificationSection.licenseOrCertifications.map((cert, i) => (
+ <View key={cert.id ?? i} style={{ marginBottom: 6 }} wrap={false}>
+ <Text style={simpleStyles.entryTitle}>{cert.title}</Text>
+ <Text style={simpleStyles.entryMeta}>{cert.organization}</Text>
+ {(cert.issueDate || cert.expirationDate) && (
+ <Text style={simpleStyles.entryMeta}>
+ {cert.issueDate
+ ? `Issued: ${formatDate(cert.issueDate)}`
+ : ""}
+ {cert.issueDate && cert.expirationDate ? " · " : ""}
+ {cert.expirationDate
+ ? `Expires: ${formatDate(cert.expirationDate)}`
+ : ""}
+ </Text>
+ )}
+ {cert.credentialUrl && (
+ <Text style={simpleStyles.entryMeta}>{cert.credentialUrl}</Text>
+ )}
+ </View>
+ ))}
+ </View>
+ )}
+ </Page>
+ </Document>
+ );
+}
diff --git a/src/components/profile/resume-pdf/generateResumePdf.tsx b/src/components/profile/resume-pdf/generateResumePdf.tsx
index 3b06095..d5bc9a3 100644
--- a/src/components/profile/resume-pdf/generateResumePdf.tsx
+++ b/src/components/profile/resume-pdf/generateResumePdf.tsx
@@ -1,7 +1,9 @@
import React from "react";
import { Resume, SectionType } from "@/models/profile.model";
import { htmlToPdfNodes } from "./html-to-pdf";
-import { ProfessionalResumeDocument } from "./ProfessionalTemplate";
+import { ResumeLayout, RESUME_LAYOUT_LABELS } from "./types";
+import { simpleHtmlStyles } from "./styles/simple.styles";
+import { professionalHtmlStyles } from "./styles/professional.styles";
export type ResumeHtmlNodes = {
summary: React.ReactElement[];
@@ -21,7 +23,10 @@ export function sanitizeFilename(name: string): string {
export async function generateResumePdfBlob(
resume: Resume,
+ layout: ResumeLayout = "simple",
): Promise<{ blob: Blob; filename: string }> {
+ const htmlStyles = layout === "professional" ? professionalHtmlStyles : simpleHtmlStyles;
+
// Parse HTML in the browser main thread before entering react-pdf's rendering context
const summarySection = resume.ResumeSections?.find(
(s) => s.sectionType === SectionType.SUMMARY,
@@ -35,23 +40,31 @@ export async function generateResumePdfBlob(
const htmlNodes: ResumeHtmlNodes = {
summary: summarySection?.summary?.content
- ? htmlToPdfNodes(summarySection.summary.content)
+ ? htmlToPdfNodes(summarySection.summary.content, htmlStyles)
: [],
experiences:
experienceSection?.workExperiences?.map((exp) =>
- exp.description ? htmlToPdfNodes(exp.description) : [],
+ exp.description ? htmlToPdfNodes(exp.description, htmlStyles) : [],
) ?? [],
educations:
educationSection?.educations?.map((edu) =>
- edu.description ? htmlToPdfNodes(edu.description) : [],
+ edu.description ? htmlToPdfNodes(edu.description, htmlStyles) : [],
) ?? [],
};
const { pdf } = await import("@react-pdf/renderer");
- const blob = await pdf(
- <ProfessionalResumeDocument resume={resume} htmlNodes={htmlNodes} />,
- ).toBlob();
- const filename = `${sanitizeFilename(resume.title)}.pdf`;
+
+ let document: React.ReactElement;
+ if (layout === "professional") {
+ const { ProfessionalResumeDocument } = await import("./ProfessionalTemplate");
+ document = <ProfessionalResumeDocument resume={resume} htmlNodes={htmlNodes} />;
+ } else {
+ const { SimpleResumeDocument } = await import("./SimpleTemplate");
+ document = <SimpleResumeDocument resume={resume} htmlNodes={htmlNodes} />;
+ }
+
+ const blob = await pdf(document).toBlob();
+ const filename = `${sanitizeFilename(resume.title)} - ${RESUME_LAYOUT_LABELS[layout]}.pdf`;
return { blob, filename };
}
diff --git a/src/components/profile/resume-pdf/html-to-pdf.tsx b/src/components/profile/resume-pdf/html-to-pdf.tsx
index e68cb8e..51855e3 100644
--- a/src/components/profile/resume-pdf/html-to-pdf.tsx
+++ b/src/components/profile/resume-pdf/html-to-pdf.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Text, View } from "@react-pdf/renderer";
-import { styles } from "./primitives";
+import { HtmlStyleSet } from "./types";
// Use numeric constants — the `Node` global is not available in all rendering contexts
const TEXT_NODE = 3;
@@ -11,10 +11,10 @@ type InheritedStyle = {
italic?: boolean;
};
-function inlineStyle(inherited: InheritedStyle) {
- if (inherited.bold && inherited.italic) return styles.boldItalic;
- if (inherited.bold) return styles.bold;
- if (inherited.italic) return styles.italic;
+function inlineStyle(inherited: InheritedStyle, s: HtmlStyleSet) {
+ if (inherited.bold && inherited.italic) return s.boldItalic;
+ if (inherited.bold) return s.bold;
+ if (inherited.italic) return s.italic;
return undefined;
}
@@ -22,13 +22,14 @@ function walkNode(
node: ChildNode,
inherited: InheritedStyle,
key: string,
+ s: HtmlStyleSet,
): React.ReactElement | string | null {
if (node.nodeType === TEXT_NODE) {
const text = node.textContent ?? "";
if (!text) return null;
- const s = inlineStyle(inherited);
- return s ? (
- <Text key={key} style={s}>
+ const style = inlineStyle(inherited, s);
+ return style ? (
+ <Text key={key} style={style}>
{text}
</Text>
) : (
@@ -41,20 +42,20 @@ function walkNode(
const tag = el.tagName.toLowerCase();
const children = Array.from(el.childNodes)
- .map((child, i) => walkNode(child, inherited, `${key}-${i}`))
+ .map((child, i) => walkNode(child, inherited, `${key}-${i}`, s))
.filter(Boolean);
switch (tag) {
case "p": {
return (
- <Text key={key} style={styles.bodyText}>
+ <Text key={key} style={s.bodyText}>
{children}
</Text>
);
}
case "h2": {
return (
- <Text key={key} style={styles.h2text}>
+ <Text key={key} style={s.h2text}>
{children}
</Text>
);
@@ -63,11 +64,10 @@ function walkNode(
case "b": {
const next = { ...inherited, bold: true };
const inner = Array.from(el.childNodes)
- .map((child, i) => walkNode(child, next, `${key}-${i}`))
+ .map((child, i) => walkNode(child, next, `${key}-${i}`, s))
.filter(Boolean);
- const s = inlineStyle(next);
return (
- <Text key={key} style={s}>
+ <Text key={key} style={inlineStyle(next, s)}>
{inner}
</Text>
);
@@ -76,11 +76,10 @@ function walkNode(
case "i": {
const next = { ...inherited, italic: true };
const inner = Array.from(el.childNodes)
- .map((child, i) => walkNode(child, next, `${key}-${i}`))
+ .map((child, i) => walkNode(child, next, `${key}-${i}`, s))
.filter(Boolean);
- const s = inlineStyle(next);
return (
- <Text key={key} style={s}>
+ <Text key={key} style={inlineStyle(next, s)}>
{inner}
</Text>
);
@@ -90,16 +89,14 @@ function walkNode(
const items = Array.from(el.children)
.filter((c) => c.tagName.toLowerCase() === "li")
.map((li, i) => {
- const marker = tag === "ol" ? `${i + 1}.` : "•";
+ const marker = tag === "ol" ? `${i + 1}.` : s.bulletChar;
const liChildren = Array.from(li.childNodes)
- .map((child, j) =>
- walkNode(child, inherited, `${key}-li${i}-${j}`),
- )
+ .map((child, j) => walkNode(child, inherited, `${key}-li${i}-${j}`, s))
.filter(Boolean);
return (
- <View key={`${key}-li${i}`} style={styles.listRow}>
- <Text style={styles.bullet}>{marker}</Text>
- <Text style={styles.listText}>{liChildren}</Text>
+ <View key={`${key}-li${i}`} style={s.listRow}>
+ <Text style={s.bullet}>{marker}</Text>
+ <Text style={s.listText}>{liChildren}</Text>
</View>
);
});
@@ -115,27 +112,26 @@ function walkNode(
default:
if (children.length === 0) return null;
return (
- <Text key={key} style={inlineStyle(inherited)}>
+ <Text key={key} style={inlineStyle(inherited, s)}>
{children}
</Text>
);
}
}
-export function htmlToPdfNodes(html: string): React.ReactElement[] {
+export function htmlToPdfNodes(html: string, s: HtmlStyleSet): React.ReactElement[] {
if (!html || !html.trim()) return [];
try {
const doc = new DOMParser().parseFromString(html, "text/html");
const nodes: React.ReactElement[] = [];
Array.from(doc.body.childNodes).forEach((node, i) => {
- const result = walkNode(node, {}, `node-${i}`);
+ const result = walkNode(node, {}, `node-${i}`, s);
if (!result) return;
if (typeof result === "string") {
- // Wrap top-level bare text (plain-text content with no block wrapper)
- // so it is not silently dropped from the PDF.
+ // Wrap top-level bare text so it is not silently dropped from the PDF.
if (!result.trim()) return;
nodes.push(
- <Text key={`node-${i}`} style={styles.bodyText}>
+ <Text key={`node-${i}`} style={s.bodyText}>
{result}
</Text>,
);
diff --git a/src/components/profile/resume-pdf/index.ts b/src/components/profile/resume-pdf/index.ts
index 38b2529..84ec05e 100644
--- a/src/components/profile/resume-pdf/index.ts
+++ b/src/components/profile/resume-pdf/index.ts
@@ -1,2 +1,4 @@
export { downloadResumePdf, generateResumePdfBlob, sanitizeFilename } from "./generateResumePdf";
export { htmlToPdfNodes } from "./html-to-pdf";
+export type { ResumeLayout } from "./types";
+export { RESUME_LAYOUT_LABELS } from "./types";
diff --git a/src/components/profile/resume-pdf/styles/professional.styles.ts b/src/components/profile/resume-pdf/styles/professional.styles.ts
new file mode 100644
index 0000000..01a72ff
--- /dev/null
+++ b/src/components/profile/resume-pdf/styles/professional.styles.ts
@@ -0,0 +1,149 @@
+import { StyleSheet } from "@react-pdf/renderer";
+import { HtmlStyleSet } from "../types";
+
+const ACCENT = "#34506e";
+const NEAR_BLACK = "#1a1a1a";
+const GRAY = "#555555";
+
+export const professionalStyles = StyleSheet.create({
+ page: {
+ fontFamily: "Helvetica",
+ fontSize: 10,
+ paddingTop: 36,
+ paddingBottom: 40,
+ paddingHorizontal: 44,
+ color: NEAR_BLACK,
+ lineHeight: 1.45,
+ },
+ // Header
+ headerRow: {
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "flex-start",
+ marginBottom: 8,
+ },
+ headerLeft: {
+ flex: 1,
+ },
+ headerRight: {
+ alignItems: "flex-end",
+ },
+ name: {
+ fontFamily: "Times-Bold",
+ fontSize: 24,
+ color: NEAR_BLACK,
+ marginBottom: 16,
+ },
+ headline: {
+ fontFamily: "Helvetica",
+ fontSize: 10,
+ color: ACCENT,
+ textTransform: "uppercase",
+ letterSpacing: 1.2,
+ },
+ contactLine: {
+ fontFamily: "Courier",
+ fontSize: 9,
+ color: GRAY,
+ marginBottom: 1,
+ },
+ thickRule: {
+ borderBottomWidth: 2,
+ borderBottomColor: "#000000",
+ marginBottom: 10,
+ },
+ // Section heading
+ sectionHeadingRow: {
+ flexDirection: "row",
+ alignItems: "center",
+ marginBottom: 6,
+ marginTop: 12,
+ },
+ sectionHeadingLabel: {
+ fontFamily: "Helvetica-Bold",
+ fontSize: 9,
+ color: ACCENT,
+ textTransform: "uppercase",
+ letterSpacing: 1.4,
+ marginRight: 6,
+ },
+ sectionHeadingRule: {
+ flex: 1,
+ borderBottomWidth: 0.75,
+ borderBottomColor: ACCENT,
+ },
+ // Body
+ bodyText: {
+ fontSize: 10,
+ marginBottom: 2,
+ },
+ bold: { fontFamily: "Helvetica-Bold" },
+ italic: { fontFamily: "Helvetica-Oblique" },
+ boldItalic: { fontFamily: "Helvetica-BoldOblique" },
+ h2text: {
+ fontFamily: "Helvetica-Bold",
+ fontSize: 12,
+ marginBottom: 3,
+ marginTop: 4,
+ },
+ // Entry rows
+ entryHeaderRow: {
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "flex-start",
+ },
+ entryTitle: {
+ fontFamily: "Helvetica-Bold",
+ fontSize: 10,
+ color: NEAR_BLACK,
+ flex: 1,
+ },
+ entryDate: {
+ fontFamily: "Helvetica",
+ fontSize: 9,
+ color: GRAY,
+ marginLeft: 8,
+ },
+ entryMeta: {
+ fontSize: 9,
+ color: GRAY,
+ marginBottom: 3,
+ },
+ // List
+ listRow: {
+ flexDirection: "row",
+ marginBottom: 1,
+ },
+ bullet: {
+ width: 12,
+ fontSize: 10,
+ color: ACCENT,
+ },
+ listText: {
+ flex: 1,
+ fontSize: 10,
+ },
+ // Two-column section
+ twoColRow: {
+ flexDirection: "row",
+ gap: 20,
+ },
+ twoColLeft: {
+ flex: 1,
+ },
+ twoColRight: {
+ flex: 1,
+ },
+});
+
+export const professionalHtmlStyles: HtmlStyleSet = {
+ bodyText: professionalStyles.bodyText,
+ bold: professionalStyles.bold,
+ italic: professionalStyles.italic,
+ boldItalic: professionalStyles.boldItalic,
+ h2text: professionalStyles.h2text,
+ listRow: professionalStyles.listRow,
+ bullet: professionalStyles.bullet,
+ listText: professionalStyles.listText,
+ bulletChar: "▪",
+};
diff --git a/src/components/profile/resume-pdf/primitives.tsx b/src/components/profile/resume-pdf/styles/simple.styles.ts
similarity index 73%
rename from src/components/profile/resume-pdf/primitives.tsx
rename to src/components/profile/resume-pdf/styles/simple.styles.ts
index 6f73728..8e78980 100644
--- a/src/components/profile/resume-pdf/primitives.tsx
+++ b/src/components/profile/resume-pdf/styles/simple.styles.ts
@@ -1,6 +1,7 @@
-import { StyleSheet, Text, View } from "@react-pdf/renderer";
+import { StyleSheet } from "@react-pdf/renderer";
+import { HtmlStyleSet } from "../types";
-export const styles = StyleSheet.create({
+export const simpleStyles = StyleSheet.create({
page: {
fontFamily: "Helvetica",
fontSize: 11,
@@ -65,11 +66,14 @@ export const styles = StyleSheet.create({
},
});
-export function SectionHeading({ title }: { title: string }) {
- return (
- <View>
- <Text style={styles.sectionTitle}>{title}</Text>
- <View style={styles.divider} />
- </View>
- );
-}
+export const simpleHtmlStyles: HtmlStyleSet = {
+ bodyText: simpleStyles.bodyText,
+ bold: simpleStyles.bold,
+ italic: simpleStyles.italic,
+ boldItalic: simpleStyles.boldItalic,
+ h2text: simpleStyles.h2text,
+ listRow: simpleStyles.listRow,
+ bullet: simpleStyles.bullet,
+ listText: simpleStyles.listText,
+ bulletChar: "•",
+};
diff --git a/src/components/profile/resume-pdf/types.ts b/src/components/profile/resume-pdf/types.ts
new file mode 100644
index 0000000..221e078
--- /dev/null
+++ b/src/components/profile/resume-pdf/types.ts
@@ -0,0 +1,18 @@
+export type ResumeLayout = "simple" | "professional";
+
+export const RESUME_LAYOUT_LABELS: Record<ResumeLayout, string> = {
+ simple: "Simple",
+ professional: "Professional",
+};
+
+export type HtmlStyleSet = {
+ bodyText: object;
+ bold: object;
+ italic: object;
+ boldItalic: object;
+ h2text: object;
+ listRow: object;
+ bullet: object;
+ listText: object;
+ bulletChar: string;
+};