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: match public message pages to display preferences
Amruth Pillai2e34de35d7f0
diff --git a/docs/guides/sharing-your-resume-publicly.mdx b/docs/guides/sharing-your-resume-publicly.mdxindex bcb5aff88..0deabef86 100644--- a/docs/guides/sharing-your-resume-publicly.mdx+++ b/docs/guides/sharing-your-resume-publicly.mdx@@ -49,6 +49,15 @@ The **Share** mode publishes your resume as a web page that anyone you send the- **With a password**, visitors first see **This resume is password-protected**, enter the password you shared and select **Unlock**. The page stays unlocked for about 10 minutes.- **When the page isn't published**, or the resume is in Trash, visitors see **This resume isn't shared right now.** with a link to Reactive Resume's home. The page gives nothing away about you.+The space around your resume, the password screen and the unavailable-page screen follow the visitor's light or dark display preference. The resume itself keeps your chosen design on white paper.++<Frame caption="The password screen follows a visitor's dark display preference. This phone capture uses a fictional resume on a local test installation.">+ <img+ src="/images/guides/sharing-your-resume-publicly/password-dark.png"+ alt="Dark password screen with a readable password field, an incorrect-password message and a keyboard-focused Unlock button"+ />+</Frame>+When someone pastes your link into LinkedIn, Slack or a chat, the preview shows your name, headline and photo in your resume's colors.Visitors never see your private notes, or any section or entry you've hidden. A small Reactive Resume mark sits under the page; you can turn it off under **Web page**.diff --git a/docs/images/guides/sharing-your-resume-publicly/password-dark.png b/docs/images/guides/sharing-your-resume-publicly/password-dark.pngnew file mode 100644index 000000000..59d07a7e3Binary files /dev/null and b/docs/images/guides/sharing-your-resume-publicly/password-dark.png differdiff --git a/packages/pdf/src/html/document.ts b/packages/pdf/src/html/document.tsindex 46b964825..b48126deb 100644--- a/packages/pdf/src/html/document.ts+++ b/packages/pdf/src/html/document.ts@@ -74,19 +74,29 @@ body{margin:0;background:#f8f7f3;color:#111;font-family:system-ui,-apple-system,`;const MESSAGE_CSS = `-body{margin:0;min-height:100vh;display:grid;place-items:center;background:#f8f7f3;color:#111;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;padding:24px;box-sizing:border-box}+body{margin:0;min-height:100vh;display:grid;place-items:center;background:#f8f7f3;color:#111;color-scheme:light;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;padding:24px;box-sizing:border-box}main{max-width:380px;text-align:center;display:grid;gap:12px}h1{font-size:24px;line-height:1.25;margin:0;font-weight:600}p{margin:0;color:#4b4b52;font-size:15px;line-height:1.5}form{display:grid;gap:12px;margin-top:12px;text-align:start}label{font-size:14px;font-weight:500}-input{font:inherit;height:44px;padding:0 12px;border:1px solid #c9c9d0;border-radius:4px;background:#fff}+input{font:inherit;height:44px;padding:0 12px;border:1px solid #8c887f;border-radius:4px;background:#fff;color:inherit}input:focus{outline:2px solid #337344;outline-offset:1px}button{font:inherit;font-weight:600;height:44px;border:0;border-radius:4px;background:#337344;color:#f7fef8;cursor:pointer}+button:focus-visible{outline:2px solid #337344;outline-offset:3px}.error{color:#b42318;font-size:14px}.home{display:inline-flex;align-items:center;justify-self:center;gap:8px;min-height:44px;margin-top:12px;padding:0 12px;border-radius:4px;color:#111;font-size:15px;font-weight:500;text-decoration:underline;text-underline-offset:3px}.home svg{width:20px;height:20px}.home:focus-visible{outline:2px solid #337344;outline-offset:2px}+@media (prefers-color-scheme:dark){+body{background:#100f0c;color:#e8e5dd;color-scheme:dark}+p{color:#b5b1a7}+input{background:#1d1c17;border-color:#807b6e}+input:focus,button:focus-visible,.home:focus-visible{outline-color:#82b787}+button{background:#82b787;color:#10170f}+.error{color:#ff9c91}+.home{color:inherit}+}`;/**diff --git a/tests/e2e/specs/public-message-pages.spec.ts b/tests/e2e/specs/public-message-pages.spec.tsnew file mode 100644index 000000000..fb3710272--- /dev/null+++ b/tests/e2e/specs/public-message-pages.spec.ts@@ -0,0 +1,111 @@+import type { Locator } from "@playwright/test";+import { expect, test } from "../fixtures/test";++async function appearance(locator: Locator) {+ return locator.evaluate((element) => {+ const style = getComputedStyle(element);+ let background = element;+ while (getComputedStyle(background).backgroundColor === "rgba(0, 0, 0, 0)" && background.parentElement)+ background = background.parentElement;+ const luminance = (color: string) => {+ const channels = (color.match(/[\d.]+/g) ?? []).slice(0, 3).map((part) => {+ const value = Number(part) / 255;+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;+ });+ return (channels[0] ?? 0) * 0.2126 + (channels[1] ?? 0) * 0.7152 + (channels[2] ?? 0) * 0.0722;+ };+ const base = luminance(getComputedStyle(background).backgroundColor);+ const contrast = (color: string, backdrop = base) => {+ const foreground = luminance(color);+ return (Math.max(backdrop, foreground) + 0.05) / (Math.min(backdrop, foreground) + 0.05);+ };+ return {+ background: style.backgroundColor,+ text: contrast(style.color),+ border: contrast(style.borderColor),+ focus: contrast(style.outlineColor, luminance(getComputedStyle(document.body).backgroundColor)),+ radius: style.borderRadius,+ };+ });+}++for (const width of [1440, 390])+ for (const theme of ["light", "dark"] as const)+ test(`public password and unavailable pages stay readable at ${width}px in ${theme}`, async ({+ browser,+ authPage: owner,+ account,+ }, info) => {+ await owner.setViewportSize({ width, height: 900 });+ await owner.emulateMedia({ colorScheme: theme });+ const created = await owner.request.post("/api/openapi/resumes", {+ data: { name: "PRIVATE fictional message fixture", tags: [], withSampleData: true },+ });+ await expect(created).toBeOK();+ const id = (await created.json()) as string;+ const api = `/api/openapi/resumes/${id}`;+ await expect(await owner.request.put(api, { data: { slug: "fictional-message-page", isPublic: true } })).toBeOK();+ await expect(+ await owner.request.put(`${api}/password`, { data: { password: "fictional-message-password" } }),+ ).toBeOK();+ const origin = process.env.APP_URL ?? "http://localhost:3000";+ const url = `${origin}/${account.username}/fictional-message-page`;+ const visitor = await browser.newPage({ viewport: { width, height: 900 }, colorScheme: theme });+ const desk = theme === "dark" ? "rgb(16, 15, 12)" : "rgb(248, 247, 243)";+ try {+ expect((await visitor.goto(url))?.status()).toBe(401);+ await expect(visitor.locator("body")).toHaveCSS("background-color", desk);+ const password = visitor.getByLabel("Password", { exact: true });+ await expect(password).toBeFocused();+ expect((await appearance(visitor.locator("h1"))).text).toBeGreaterThanOrEqual(4.5);+ expect((await appearance(visitor.locator("main > p"))).text).toBeGreaterThanOrEqual(4.5);+ const input = await appearance(password);+ expect(input.border).toBeGreaterThanOrEqual(3);+ expect(input.focus).toBeGreaterThanOrEqual(3);+ expect(input.radius).toBe("4px");+ const unlock = visitor.getByRole("button", { name: "Unlock", exact: true });+ expect((await appearance(unlock)).text).toBeGreaterThanOrEqual(4.5);+ await password.fill("fictional-wrong-password");+ await unlock.click();+ await expect(visitor.locator("#error")).toBeVisible();+ await expect(password).toHaveAttribute("aria-invalid", "true");+ await expect(password).toHaveAttribute("aria-describedby", "error");+ expect((await appearance(visitor.locator("#error"))).text).toBeGreaterThanOrEqual(4.5);+ await password.focus();+ await visitor.keyboard.press("Tab");+ await expect(unlock).toBeFocused();+ expect((await appearance(unlock)).focus).toBeGreaterThanOrEqual(3);+ await visitor.screenshot({ path: info.outputPath("password-error.png") });+ await password.fill("fictional-message-password");+ await unlock.click();+ await expect(visitor.getByRole("link", { name: "Download PDF", exact: true })).toBeVisible();+ await expect(visitor.locator("body")).toHaveCSS("background-color", desk);+ await expect(visitor.locator(".rr-page").first()).toHaveCSS("background-color", "rgb(255, 255, 255)");+ await expect(await owner.request.put(api, { data: { isPublic: false } })).toBeOK();+ expect((await visitor.reload())?.status()).toBe(404);+ await expect(visitor.locator("body")).toHaveCSS("background-color", desk);+ const home = visitor.getByRole("link", { name: "Go to Reactive Resume", exact: true });+ await expect(home).toHaveAttribute("href", `${origin}/`);+ await home.focus();+ expect((await appearance(home)).focus).toBeGreaterThanOrEqual(3);+ expect((await appearance(home)).text).toBeGreaterThanOrEqual(4.5);+ const unavailable = await visitor.locator("main").innerText();+ expect(unavailable).not.toContain("PRIVATE fictional message fixture");+ expect(unavailable).not.toContain(account.username);+ await visitor.screenshot({ path: info.outputPath("unavailable.png") });+ expect((await visitor.goto(`${url}-unknown`))?.status()).toBe(404);+ expect(await visitor.locator("main").innerText()).toBe(unavailable);+ expect((await owner.goto(url))?.status()).toBe(404);+ await expect(owner.locator("body")).toHaveCSS("background-color", desk);+ await owner.getByRole("link", { name: "Open Share", exact: true }).click();+ await expect(owner).toHaveURL(new RegExp(`/builder/${id}\\?mode=share$`));+ await expect(owner.getByRole("switch", { name: "Require a password", exact: true })).toBeChecked();+ expect(await visitor.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width);+ await info.attach("message-page-style", {+ body: JSON.stringify({ width, theme, desk, input }),+ contentType: "application/json",+ });+ } finally {+ await visitor.close();+ }+ });diff --git a/tests/e2e/specs/public-sharing.spec.ts b/tests/e2e/specs/public-sharing.spec.tsindex ec0af4450..bdcaff21b 100644--- a/tests/e2e/specs/public-sharing.spec.ts+++ b/tests/e2e/specs/public-sharing.spec.ts@@ -146,7 +146,7 @@ test("counts a visitor's PDF download without counting the preview", async ({ brtest("publishing the first resume enables a working short link", async ({ browser, authPage: page }, testInfo) => {await createSampleResumeFromDashboard(page, testInfo);await openSidebarSection(page, "Sharing");- const addresses = page.getByRole("region", { name: "Short link and domain" });+ const addresses = page.getByRole("region", { name: /^Short link(?: and domain)?$/ });const copy = addresses.getByRole("button", { name: "Copy", exact: true });await expect(copy).toBeDisabled();await page.getByRole("button", { name: "Publish", exact: true }).click();@@ -181,9 +181,9 @@ test("a non-primary resume can copy the short link another published primary serawait page.goto(`/builder/${secondId}`);await openSidebarSection(page, "Sharing");- const addresses = page.getByRole("region", { name: "Short link and domain" });+ const addresses = page.getByRole("region", { name: /^Short link(?: and domain)?$/ });await expect(addresses.getByRole("button", { name: "Copy", exact: true })).toBeEnabled();- await expect(addresses).toContainText(`open “${primaryName}”`);+ await expect(addresses).toContainText(new RegExp(`opens? “${RegExp.escape(primaryName)}”`));});test("a failed primary lookup stops Copy for a cached primary that is no longer published", async ({@@ -208,10 +208,10 @@ test("a failed primary lookup stops Copy for a cached primary that is no longerconst secondId = (await created.json()) as string;await page.goto(`/builder/${secondId}`);await openSidebarSection(page, "Sharing");- const addresses = page.getByRole("region", { name: "Short link and domain" });+ const addresses = page.getByRole("region", { name: /^Short link(?: and domain)?$/ });const copy = addresses.getByRole("button", { name: "Copy", exact: true });await expect(copy).toBeEnabled();- await expect(addresses).toContainText(`open “${primaryName}”`);+ await expect(addresses).toContainText(new RegExp(`opens? “${RegExp.escape(primaryName)}”`));// The primary is unpublished outside this page. The cached row still says it is public until the list is read again.expect((await page.request.put(`/api/openapi/resumes/${primaryId}`, { data: { isPublic: false } })).ok()).toBe(true);@@ -262,7 +262,7 @@ test("a primary in Trash keeps the short link closed until Primary is switched oconst secondId = (await created.json()) as string;await page.goto(`/builder/${secondId}`);await openSidebarSection(page, "Sharing");- const addresses = page.getByRole("region", { name: "Short link and domain" });+ const addresses = page.getByRole("region", { name: /^Short link(?: and domain)?$/ });const copy = addresses.getByRole("button", { name: "Copy", exact: true });await expect(copy).toBeEnabled();@@ -273,7 +273,7 @@ test("a primary in Trash keeps the short link closed until Primary is switched oawait page.reload();await openSidebarSection(page, "Sharing");- await expect(addresses).toContainText("Publish this resume to open it at your short link and custom domain.");+ await expect(addresses).toContainText(/Publish this resume to open it at your short link(?: and custom domain)?\./);await expect(addresses).toContainText("If another resume holds Primary, turn it on for this one instead.");await expect(copy).toBeDisabled();expect((await page.request.get(`/${account.username}`)).status()).toBe(404);