A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix: omit Pikachu contact divider from empty headers
Amruth Pillai6d15fc86358e
diff --git a/docs/guides/choosing-a-template.mdx b/docs/guides/choosing-a-template.mdxindex 0d7f9b981..ea60c22af 100644--- a/docs/guides/choosing-a-template.mdx+++ b/docs/guides/choosing-a-template.mdx@@ -16,6 +16,15 @@ The public gallery keeps **Sign in** and **Build your resume** in the header, inA template decides the layout of your resume: where the header sits, whether there is a sidebar, and how headings and entries look. You can switch templates at any time. Your content, fonts and colors stay the same.+Glalie, Leafish and Pikachu leave out their contact box, band or divider when no contact details print. Your name and headline stay.++<Frame caption="Pikachu without contact details">+ <img+ src="/images/guides/choosing-a-template/empty-pikachu-header.webp"+ alt="Fictional Jordan Rivera name in Pikachu’s colored header, without a divider or empty contact row"+ />+</Frame>+## Open the template gallery<Steps>diff --git a/docs/images/guides/choosing-a-template/empty-pikachu-header.webp b/docs/images/guides/choosing-a-template/empty-pikachu-header.webpnew file mode 100644index 000000000..bc2721deeBinary files /dev/null and b/docs/images/guides/choosing-a-template/empty-pikachu-header.webp differdiff --git a/packages/pdf/src/templates/pikachu/PikachuPage.tsx b/packages/pdf/src/templates/pikachu/PikachuPage.tsxindex 686f16fe7..8708d401e 100644--- a/packages/pdf/src/templates/pikachu/PikachuPage.tsx+++ b/packages/pdf/src/templates/pikachu/PikachuPage.tsx@@ -128,17 +128,24 @@ export const PikachuPage = ({ page, pageSize, pageMinHeightStyle, showHeader, paconst Header = ({ styles, colors }: PikachuHeaderProps) => {const { basics } = useRender();+ const hasContacts = hasContactDetails(basics);return (<SemanticHeaderView style={styles.header}>- <SemanticTemplatePartView partKeys={["header-divider"]} style={styles.headerDivider}>+ <SemanticTemplatePartView+ partKeys={["header-divider"]}+ style={composeStyles(+ styles.headerDivider,+ hasContacts ? undefined : { borderBottomWidth: 0, paddingBottom: 0 },+ )}+ ><View style={styles.headerIdentity}><Heading style={styles.headerName}>{basics.name}</Heading><Text style={styles.headerText}>{basics.headline}</Text></View></SemanticTemplatePartView>- {hasContactDetails(basics) && (+ {hasContacts && (<SemanticContactListView style={styles.contactList}><EmailContactItememail={basics.email}diff --git a/packages/pdf/src/templates/pikachu/contact-divider.test.tsx b/packages/pdf/src/templates/pikachu/contact-divider.test.tsxnew file mode 100644index 000000000..ec21dc7b5--- /dev/null+++ b/packages/pdf/src/templates/pikachu/contact-divider.test.tsx@@ -0,0 +1,42 @@+import { expect, it } from "vite-plus/test";+import { getDocument, OPS } from "pdfjs-dist/legacy/build/pdf.mjs";+import { act, createElement } from "react";+import { defaultResumeData } from "@reactive-resume/schema/resume/default";+import { ResumeDocument } from "../../document";+import { renderToBuffer } from "../../forme/testing";++async function header(email: string) {+ const data = structuredClone(defaultResumeData);+ data.basics.name = "Fictional header";+ data.basics.email = email;+ data.metadata.page.hideIcons = true;+ data.metadata.page.hideLinkUnderline = true;+ data.metadata.typography.body.fontFamily = "Helvetica";+ data.metadata.typography.heading.fontFamily = "Helvetica";+ const element = createElement(ResumeDocument, { data, template: "pikachu" }) as unknown as Parameters<+ typeof renderToBuffer+ >[0];+ let bytes: Uint8Array = new Uint8Array();+ await act(async () => {+ bytes = new Uint8Array(await renderToBuffer(element));+ });+ const task = getDocument({ data: bytes, useSystemFonts: true });+ try {+ const document = await task.promise;+ const page = await document.getPage(1);+ const operators = await page.getOperatorList();+ const text = (await page.getTextContent()).items.flatMap((item) => ("str" in item ? [item.str] : [])).join(" ");+ return { paths: operators.fnArray.filter((operation) => operation === OPS.constructPath).length, text };+ } finally {+ await task.destroy();+ }+}++it("paints a contact divider only when contact details print", async () => {+ const empty = await header("");+ const contact = await header("[email protected]");+ expect(empty.text).toContain("Fictional header");+ expect(empty.text).not.toContain("[email protected]");+ expect(contact.text).toContain("[email protected]");+ expect(contact.paths).toBeGreaterThan(empty.paths);+});diff --git a/tests/e2e/specs/empty-template-header.spec.ts b/tests/e2e/specs/empty-template-header.spec.tsnew file mode 100644index 000000000..628bb9f45--- /dev/null+++ b/tests/e2e/specs/empty-template-header.spec.ts@@ -0,0 +1,63 @@+import type { Page } from "@playwright/test";+import { expect, test } from "../fixtures/test";++async function borderedHeaderNodes(page: Page) {+ return page.locator("[data-region=header]").evaluate(+ (header) =>+ [header, ...header.querySelectorAll("*")].filter((node) => {+ const style = getComputedStyle(node);+ return [style.borderTopWidth, style.borderBottomWidth, style.borderLeftWidth, style.borderRightWidth].some(+ (width) => Number.parseFloat(width) > 0,+ );+ }).length,+ );+}++test("empty contact details omit header decoration without removing the identity", async ({+ authPage: page,+ account,+}, info) => {+ const created = await page.request.post("/api/openapi/resumes", {+ data: { name: "Fictional empty header", tags: [] },+ });+ await expect(created).toBeOK();+ const id = await created.json();+ await expect(+ await page.request.patch(`/api/openapi/resumes/${id}`, {+ data: {+ operations: [+ { op: "replace", path: "/basics/name", value: "Jordan Rivera" },+ ...["email", "phone", "location"].map((key) => ({ op: "replace", path: "/basics/" + key, value: "" })),+ { op: "replace", path: "/basics/website", value: { url: "", label: "" } },+ { op: "replace", path: "/basics/customFields", value: [] },+ ],+ },+ }),+ ).toBeOK();+ await expect(await page.request.put(`/api/openapi/resumes/${id}`, { data: { isPublic: true } })).toBeOK();+ const response = await page.request.get(`/api/openapi/resumes/${id}`);+ await expect(response).toBeOK();+ const { slug } = await response.json();+ for (const template of ["glalie", "leafish", "pikachu"]) {+ await expect(+ await page.request.patch(`/api/openapi/resumes/${id}`, {+ data: { operations: [{ op: "replace", path: "/metadata/template", value: template }] },+ }),+ ).toBeOK();+ await page.goto(`/${account.username}/${slug}`);+ const header = page.locator("[data-region=header]");+ await expect(header).toContainText("Jordan Rivera");+ expect(await borderedHeaderNodes(page)).toBe(0);+ await expect(header.locator("a")).toHaveCount(0);+ if (template === "pikachu")+ await header.screenshot({ path: info.outputPath("empty-pikachu-header.png"), animations: "disabled" });+ }+ await expect(+ await page.request.patch(`/api/openapi/resumes/${id}`, {+ data: { operations: [{ op: "replace", path: "/basics/email", value: "[email protected]" }] },+ }),+ ).toBeOK();+ await page.reload();+ await expect(page.getByRole("link", { name: "[email protected]", exact: true })).toBeVisible();+ expect(await borderedHeaderNodes(page)).toBe(1);+});