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: mirror right-to-left public resume layouts (#3798)
Amruth Pillaie450059f44d0
diff --git a/docs/guides/sharing-your-resume-publicly.mdx b/docs/guides/sharing-your-resume-publicly.mdxindex 286afc45d..cbc3f05eb 100644--- a/docs/guides/sharing-your-resume-publicly.mdx+++ b/docs/guides/sharing-your-resume-publicly.mdx@@ -50,6 +50,10 @@ To change the page's template, colours or typography, use **Design**; the web pa**Web page**, **Show “Made with Reactive Resume”** controls only the footer credit. Preview links let you review anunpublished page for 15 minutes; keep them private, since anyone with that preview link can open it while it's valid.+The **Language** under **Design** → **Page** also sets the web page's reading direction. Arabic and Hebrew mirror the template's+layout, with bullet markers beside their text. If you choose a **Sidebar side**, the web page keeps that choice;+on a phone, the sidebar still follows the main content.+## Change the addressThe last part of the address is yours to choose. For a new resume with an automatically generated address, it follows thediff --git a/packages/pdf/src/html/to-html.ts b/packages/pdf/src/html/to-html.tsindex 6b56b6adf..2137603af 100644--- a/packages/pdf/src/html/to-html.ts+++ b/packages/pdf/src/html/to-html.ts@@ -134,6 +134,11 @@ function toCssDeclarations(input: Style, context: Context) {LENGTH_KEYS.has(key) && key.endsWith("Radius") && typeof raw === "string" && PERCENT.test(raw.trim());const css = percentCorner ? raw.trim() : cssValue(key, converted[key], fontSize);if (css === undefined) continue;+ // Templates already mirror geometry; direction must reach text without flipping browser flex axes again.+ if (key === "direction") {+ declarations.push(["--rr-text-direction", css]);+ continue;+ }for (const target of EXPANDED[key] ?? [key]) declarations.push([kebab(target), css]);}return { declarations, fontSize, hidden };@@ -393,8 +398,9 @@ function bandColor(page: HostElement): string | undefined {*/const BASE_CSS = `.rr,.rr *{box-sizing:border-box;margin:0;padding:0;border:0 solid}-.rr .v{display:flex;flex-direction:column;position:relative;min-width:0;align-content:flex-start}+.rr .v{display:flex;flex-direction:column;direction:ltr;position:relative;min-width:0;align-content:flex-start}.rr .t{display:block;min-width:0;overflow-wrap:break-word}+.rr .t,.rr .t span,.rr .t a{direction:var(--rr-text-direction,ltr)}.rr a{color:inherit;text-decoration:none}.rr h1,.rr h2{font:inherit}.rr .s,.rr .i{flex-shrink:0;display:block}@@ -410,6 +416,7 @@ const BASE_CSS = `.rr [data-part=header-sidebar]>[data-region=header]{order:0}.rr [data-region=sidebar]{background-color:var(--rr-band,transparent)}.rr [data-fold]{flex-direction:column!important;align-items:flex-start!important;row-gap:8px}+.rr:dir(rtl) [data-fold]{align-items:flex-end!important}.rr [data-fold]>*{width:auto!important;max-width:100%!important;flex:none!important}.rr [data-fixed]{display:none!important}}diff --git a/tests/e2e/specs/public-sharing.spec.ts b/tests/e2e/specs/public-sharing.spec.tsindex a05e900c8..ec0af4450 100644--- a/tests/e2e/specs/public-sharing.spec.ts+++ b/tests/e2e/specs/public-sharing.spec.ts@@ -3,6 +3,109 @@ import { createSampleResumeFromDashboard, makeResumePublic, openSidebarSection }import { failRpcProcedure } from "../fixtures/rpc-failure";import { expect, test } from "../fixtures/test";+for (const { locale, name, rtl } of [+ { locale: "en-US", name: "Jane Doe", rtl: false },+ { locale: "ar-SA", name: "مريم أحمد", rtl: true },+ { locale: "he-IL", name: "נועה כהן", rtl: true },+]) {+ test(`keeps the ${locale} public page's picture, name and bullets on their reading side`, async ({+ browser,+ authPage: page,+ }, testInfo) => {+ await createSampleResumeFromDashboard(page, testInfo);+ const resumeId = new URL(page.url()).pathname.split("/")[2];+ await expect(+ await page.request.patch(`/api/openapi/resumes/${resumeId}`, {+ data: {+ operations: [+ { op: "replace", path: "/metadata/template", value: "onyx" },+ { op: "replace", path: "/metadata/page/locale", value: locale },+ { op: "replace", path: "/basics/name", value: name },+ ],+ },+ }),+ ).toBeOK();+ await page.reload();+ const publicUrl = await makeResumePublic(page);+ const visitor = await browser.newPage();+ try {+ await visitor.goto(publicUrl);+ await expect(visitor.locator("html")).toHaveAttribute("dir", rtl ? "rtl" : "ltr");+ for (const width of [1280, 390]) {+ await visitor.setViewportSize({ width, height: 900 });+ const heading = visitor.getByRole("heading", { level: 1, name });+ await expect(heading).toBeVisible();+ const picture = visitor.locator("[data-region=header] img");+ await expect(picture).toBeVisible();+ const [photo, header] = await Promise.all([+ picture.boundingBox(),+ visitor.locator("[data-region=header]").boundingBox(),+ ]);+ if (!photo || !header) throw new Error("The public header is missing.");+ const photoInset = rtl ? header.x + header.width - photo.x - photo.width : photo.x - header.x;+ expect(photoInset).toBeLessThan(2);+ await expect(heading).toHaveCSS("direction", rtl ? "rtl" : "ltr");+ await expect(heading).toHaveCSS("text-align", rtl ? "right" : "left");++ const bullet = visitor.getByText("•", { exact: true }).first();+ const geometry = await bullet.evaluate((marker) => {+ const row = marker.parentElement;+ if (!row) throw new Error("The bullet has no row.");+ const content = [...row.children].find((child) => child !== marker);+ if (!content) throw new Error("The bullet has no content.");+ const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT);+ const text = walker.nextNode();+ if (!text) throw new Error("The bullet content has no text.");+ const range = document.createRange();+ range.selectNodeContents(text);+ const firstLine = range.getClientRects()[0];+ if (!firstLine) throw new Error("The bullet text has no line.");+ return {+ marker: marker.getBoundingClientRect().toJSON(),+ row: row.getBoundingClientRect().toJSON(),+ text: firstLine.toJSON(),+ };+ });+ const markerInset = rtl ? geometry.row.right - geometry.marker.right : geometry.marker.left - geometry.row.left;+ const textGap = rtl ? geometry.marker.left - geometry.text.right : geometry.text.left - geometry.marker.right;+ expect(markerInset).toBeLessThan(2);+ expect(textGap).toBeGreaterThanOrEqual(-1);+ expect(textGap).toBeLessThan(24);+ expect(await visitor.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width);+ }++ // Column placement is independent of text direction, including an explicit choice in Design.+ for (const side of [null, "left", "right"]) {+ await expect(+ await page.request.patch(`/api/openapi/resumes/${resumeId}`, {+ data: {+ operations: [+ { op: "replace", path: "/metadata/template", value: "gengar" },+ ...(side ? [{ op: "add", path: "/metadata/layout/sidebarSide", value: side }] : []),+ ],+ },+ }),+ ).toBeOK();+ await visitor.setViewportSize({ width: 1280, height: 900 });+ await visitor.reload();+ const sidebar = visitor.locator("[data-region=sidebar]");+ const main = visitor.locator("[data-region=main]");+ await expect(sidebar).toBeVisible();+ const [sidebarBox, mainBox] = await Promise.all([sidebar.boundingBox(), main.boundingBox()]);+ if (!sidebarBox || !mainBox) throw new Error("The public columns are missing.");+ expect(sidebarBox.x < mainBox.x).toBe((side ?? (rtl ? "right" : "left")) === "left");+ await visitor.setViewportSize({ width: 390, height: 900 });+ const [foldedSidebar, foldedMain] = await Promise.all([sidebar.boundingBox(), main.boundingBox()]);+ if (!foldedSidebar || !foldedMain) throw new Error("The folded public columns are missing.");+ expect(foldedSidebar.y).toBeGreaterThanOrEqual(foldedMain.y + foldedMain.height);+ expect(await visitor.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390);+ }+ } finally {+ await visitor.close();+ }+ });+}+test("counts a visitor's PDF download without counting the preview", async ({ browser, authPage: page }, testInfo) => {test.setTimeout(60_000);await createSampleResumeFromDashboard(page, testInfo);