Skip to content

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!

fix: complete letter preview fallbacks and label fitting (RX-208)

Amruth Pillai3c1626cebf1b
diff --git a/apps/mobile/src/features/applications-board/insights-screen.tsx b/apps/mobile/src/features/applications-board/insights-screen.tsx
index 23894180e..b08508ab0 100644
--- a/apps/mobile/src/features/applications-board/insights-screen.tsx
+++ b/apps/mobile/src/features/applications-board/insights-screen.tsx
@@ -9,6 +9,7 @@ import * as Sharing from "expo-sharing";
import { useRef, useState } from "react";
import { RefreshControl, I18nManager, ScrollView, View } from "react-native";
import Svg, { Circle, Defs, G, LinearGradient, Path, Rect, Stop, Text as SvgText } from "react-native-svg";
+import { fitLabel } from "@reactive-resume/utils/string";
import { weekStartsOn } from "./calendar";
import { computeOutcomes, computePipeline, computeTimeline, countSources } from "./insights";
import { useApplicationSearch } from "./search";
@@ -344,7 +345,7 @@ type PipelineFlowProps = {
};
// The flow chart's drawing units (web PipelineFlow): bars on a mid line, bands joining them.
-const FLOW = { width: 800, height: 340, padX: 40, midY: 190, maxBar: 150, bar: 34 } as const;
+const FLOW = { width: 800, height: 340, padX: 40, midY: 190, maxBar: 150, bar: 34, labelMax: 18 } as const;
/**
* Where active applications went, as a shareable picture (web "Pipeline flow"), with the stage totals as text for
@@ -475,7 +476,7 @@ function PipelineFlow({ active, closed, steps, labelOf }: PipelineFlowProps) {
fontFamily={fonts.ui[500]}
fill={colors.ink2}
>
- {labelOf(bar.status)}
+ {fitLabel(labelOf(bar.status), FLOW.labelMax)}
</SvgText>
{i > 0 && bar.conversion !== null ? (
<SvgText
diff --git a/apps/mobile/src/features/documents/thumbnail.tsx b/apps/mobile/src/features/documents/thumbnail.tsx
index 3d2322e29..34e43a15d 100644
--- a/apps/mobile/src/features/documents/thumbnail.tsx
+++ b/apps/mobile/src/features/documents/thumbnail.tsx
@@ -25,7 +25,10 @@ export function Thumbnail({ document, visible, compact = false }: ThumbnailProps
const [width, setWidth] = useState(0);
const signedIn = visible && session.status === "signed-in";
const { server } = session;
- const draftText = useLetterStore((state) => (state.document?.id === document.id ? state.data?.content : undefined));
+ const draft = useLetterStore((state) => (state.document?.id === document.id ? state.data : undefined));
+ const draftPreview = draft
+ ? [draft.greeting?.trim(), letterText(draft.content)].filter(Boolean).join("\n\n")
+ : undefined;
const letter = useQuery({
queryKey: ["letter-thumbnail", server, document.id, document.updatedAt.getTime()],
queryFn: ({ signal }) => orpc.coverLetters.getById.call({ id: document.id }, { signal }),
@@ -71,7 +74,7 @@ export function Thumbnail({ document, visible, compact = false }: ThumbnailProps
{document.type === "letter" ? (
// A miniature of the page: it scales with the card, not with the text-size setting (tokens.md `pageThumb`).
<Text variant="callout" color="paperInk" numberOfLines={compact ? 2 : 12} maxFontSizeMultiplier={1}>
- {(draftText === undefined ? (letter.data ?? "") : letterText(draftText)) ||
+ {(draftPreview === undefined ? (letter.data ?? "") : draftPreview) ||
(letter.isError ? t`Couldn't load letter` : letter.isPending ? t`Loading letter…` : t`Empty letter`)}
</Text>
) : firstPage ? (
diff --git a/apps/web/locales/af-ZA.po b/apps/web/locales/af-ZA.po
index 5cb1e8a17..2e0f3bae6 100644
--- a/apps/web/locales/af-ZA.po
+++ b/apps/web/locales/af-ZA.po
@@ -11946,6 +11946,10 @@ msgstr "Voorbeskou {name} voorbeeld PDF"
msgid "Preview size"
msgstr "Voorskougrootte"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/am-ET.po b/apps/web/locales/am-ET.po
index dee0acf12..6e94fa5b4 100644
--- a/apps/web/locales/am-ET.po
+++ b/apps/web/locales/am-ET.po
@@ -11946,6 +11946,10 @@ msgstr "ቅድመ ዕይታ {name} ናሙና PDF"
msgid "Preview size"
msgstr "የቅድመ እይታ መጠን"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ar-SA.po b/apps/web/locales/ar-SA.po
index edd87bbd5..095f31ca3 100644
--- a/apps/web/locales/ar-SA.po
+++ b/apps/web/locales/ar-SA.po
@@ -11946,6 +11946,10 @@ msgstr "معاينة {name} نموذج PDF"
msgid "Preview size"
msgstr "حجم المعاينة"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/az-AZ.po b/apps/web/locales/az-AZ.po
index 954811767..786d4d3e5 100644
--- a/apps/web/locales/az-AZ.po
+++ b/apps/web/locales/az-AZ.po
@@ -11946,6 +11946,10 @@ msgstr "{name} PDF nümunəsinə önizləmə"
msgid "Preview size"
msgstr "Önizləmə ölçüsü"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/bg-BG.po b/apps/web/locales/bg-BG.po
index 4f330e620..30bcbf49a 100644
--- a/apps/web/locales/bg-BG.po
+++ b/apps/web/locales/bg-BG.po
@@ -11946,6 +11946,10 @@ msgstr "Визуализирайте {name} примерен PDF"
msgid "Preview size"
msgstr "Размер на прегледа"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/bn-BD.po b/apps/web/locales/bn-BD.po
index 3ac27f301..63d016d52 100644
--- a/apps/web/locales/bn-BD.po
+++ b/apps/web/locales/bn-BD.po
@@ -11946,6 +11946,10 @@ msgstr "প্রিভিউ {name} নমুনা PDF"
msgid "Preview size"
msgstr "প্রিভিউয়ের আকার"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ca-ES.po b/apps/web/locales/ca-ES.po
index 3d2d0da59..5fcbba47c 100644
--- a/apps/web/locales/ca-ES.po
+++ b/apps/web/locales/ca-ES.po
@@ -11946,6 +11946,10 @@ msgstr "Previsualitza el PDF de mostra de {name}"
msgid "Preview size"
msgstr "Mida de la previsualització"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/cs-CZ.po b/apps/web/locales/cs-CZ.po
index 6c2519e7d..c0e93fe07 100644
--- a/apps/web/locales/cs-CZ.po
+++ b/apps/web/locales/cs-CZ.po
@@ -11946,6 +11946,10 @@ msgstr "Náhled ukázky {name} PDF"
msgid "Preview size"
msgstr "Velikost náhledu"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/da-DK.po b/apps/web/locales/da-DK.po
index 72824ed29..fe18dfd6e 100644
--- a/apps/web/locales/da-DK.po
+++ b/apps/web/locales/da-DK.po
@@ -11946,6 +11946,10 @@ msgstr "Se eksempel på {name}-eksempel-PDF"
msgid "Preview size"
msgstr "Størrelse på forhåndsvisning"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/de-DE.po b/apps/web/locales/de-DE.po
index 28c7fae14..51d657a91 100644
--- a/apps/web/locales/de-DE.po
+++ b/apps/web/locales/de-DE.po
@@ -11946,6 +11946,10 @@ msgstr "Vorschau der Beispiel-PDF für {name}"
msgid "Preview size"
msgstr "Vorschaugröße"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/el-GR.po b/apps/web/locales/el-GR.po
index 15e74b5ea..90b469395 100644
--- a/apps/web/locales/el-GR.po
+++ b/apps/web/locales/el-GR.po
@@ -11946,6 +11946,10 @@ msgstr "Προεπισκόπηση {name} δείγματος PDF"
msgid "Preview size"
msgstr "Μέγεθος προεπισκόπησης"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/en-GB.po b/apps/web/locales/en-GB.po
index 4f68c8239..e153f2bbd 100644
--- a/apps/web/locales/en-GB.po
+++ b/apps/web/locales/en-GB.po
@@ -11946,6 +11946,10 @@ msgstr "Preview {name} sample PDF"
msgid "Preview size"
msgstr "Preview size"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/en-US.po b/apps/web/locales/en-US.po
index d7357f820..bcf73ed2a 100644
--- a/apps/web/locales/en-US.po
+++ b/apps/web/locales/en-US.po
@@ -11943,6 +11943,10 @@ msgstr "Preview {name} sample PDF"
msgid "Preview size"
msgstr "Preview size"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr "Preview unavailable"
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/es-ES.po b/apps/web/locales/es-ES.po
index dfde484de..410082b7d 100644
--- a/apps/web/locales/es-ES.po
+++ b/apps/web/locales/es-ES.po
@@ -11946,6 +11946,10 @@ msgstr "Vista previa del PDF de muestra de {name}"
msgid "Preview size"
msgstr "Tamaño de la vista previa"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/fa-IR.po b/apps/web/locales/fa-IR.po
index 93b0cc1a6..e7d8622ea 100644
--- a/apps/web/locales/fa-IR.po
+++ b/apps/web/locales/fa-IR.po
@@ -11946,6 +11946,10 @@ msgstr "پیش نمایش {name} نمونه PDF"
msgid "Preview size"
msgstr "اندازه پیش‌نمایش"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/fi-FI.po b/apps/web/locales/fi-FI.po
index 1cf902c5d..719d64e7d 100644
--- a/apps/web/locales/fi-FI.po
+++ b/apps/web/locales/fi-FI.po
@@ -11946,6 +11946,10 @@ msgstr "Esikatsele {name} PDF-esimerkki"
msgid "Preview size"
msgstr "Esikatselun koko"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/fr-FR.po b/apps/web/locales/fr-FR.po
index 1619f48a8..53b6573ea 100644
--- a/apps/web/locales/fr-FR.po
+++ b/apps/web/locales/fr-FR.po
@@ -11946,6 +11946,10 @@ msgstr "Aperçu d'un exemple de PDF de {name}"
msgid "Preview size"
msgstr "Taille de l’aperçu"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/he-IL.po b/apps/web/locales/he-IL.po
index 05aeff15b..b2f35ca45 100644
--- a/apps/web/locales/he-IL.po
+++ b/apps/web/locales/he-IL.po
@@ -11946,6 +11946,10 @@ msgstr "תצוגה מקדימה של PDF לדוגמה של {name}"
msgid "Preview size"
msgstr "גודל התצוגה המקדימה"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/hi-IN.po b/apps/web/locales/hi-IN.po
index e545576c6..23dbc1668 100644
--- a/apps/web/locales/hi-IN.po
+++ b/apps/web/locales/hi-IN.po
@@ -11946,6 +11946,10 @@ msgstr "पूर्वावलोकन {name} नमूना PDF"
msgid "Preview size"
msgstr "पूर्वावलोकन आकार"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/hu-HU.po b/apps/web/locales/hu-HU.po
index 89c1ba384..20eb2848c 100644
--- a/apps/web/locales/hu-HU.po
+++ b/apps/web/locales/hu-HU.po
@@ -11946,6 +11946,10 @@ msgstr "Tekintse meg a(z) {name} PDF-minta előnézetét"
msgid "Preview size"
msgstr "Előnézet mérete"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/id-ID.po b/apps/web/locales/id-ID.po
index 657a8a0bb..b4e55a45c 100644
--- a/apps/web/locales/id-ID.po
+++ b/apps/web/locales/id-ID.po
@@ -11946,6 +11946,10 @@ msgstr "Pratinjau contoh PDF {name}"
msgid "Preview size"
msgstr "Ukuran pratinjau"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/it-IT.po b/apps/web/locales/it-IT.po
index 60cd5175f..de79ba794 100644
--- a/apps/web/locales/it-IT.po
+++ b/apps/web/locales/it-IT.po
@@ -11946,6 +11946,10 @@ msgstr "Anteprima del PDF di esempio di {name}"
msgid "Preview size"
msgstr "Dimensione anteprima"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ja-JP.po b/apps/web/locales/ja-JP.po
index 1fc5f9ad7..6483e604f 100644
--- a/apps/web/locales/ja-JP.po
+++ b/apps/web/locales/ja-JP.po
@@ -11946,6 +11946,10 @@ msgstr "{name} のサンプル PDF をプレビューする"
msgid "Preview size"
msgstr "プレビューサイズ"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/km-KH.po b/apps/web/locales/km-KH.po
index 6cba8f043..9ab12e3c2 100644
--- a/apps/web/locales/km-KH.po
+++ b/apps/web/locales/km-KH.po
@@ -11946,6 +11946,10 @@ msgstr "មើលគំរូ {name} ជា PDF"
msgid "Preview size"
msgstr "ទំហំមើលជាមុន"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/kn-IN.po b/apps/web/locales/kn-IN.po
index f680e2eea..a5d5619a2 100644
--- a/apps/web/locales/kn-IN.po
+++ b/apps/web/locales/kn-IN.po
@@ -11946,6 +11946,10 @@ msgstr "ಪೂರ್ವವೀಕ್ಷಣೆ {name} ಮಾದರಿ PDF"
msgid "Preview size"
msgstr "ಪೂರ್ವವೀಕ್ಷಣೆ ಗಾತ್ರ"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ko-KR.po b/apps/web/locales/ko-KR.po
index f176eb812..55f40a077 100644
--- a/apps/web/locales/ko-KR.po
+++ b/apps/web/locales/ko-KR.po
@@ -11946,6 +11946,10 @@ msgstr "{name} 샘플 PDF 미리보기"
msgid "Preview size"
msgstr "미리보기 크기"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/lt-LT.po b/apps/web/locales/lt-LT.po
index 814795d33..eee2e07b3 100644
--- a/apps/web/locales/lt-LT.po
+++ b/apps/web/locales/lt-LT.po
@@ -11946,6 +11946,10 @@ msgstr "Peržiūrėkite {name} PDF pavyzdį"
msgid "Preview size"
msgstr "Peržiūros dydis"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/lv-LV.po b/apps/web/locales/lv-LV.po
index ee1e84ad7..2f9552f2d 100644
--- a/apps/web/locales/lv-LV.po
+++ b/apps/web/locales/lv-LV.po
@@ -11946,6 +11946,10 @@ msgstr "Priekšskatiet {name} PDF paraugu"
msgid "Preview size"
msgstr "Priekšskatījuma izmērs"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ml-IN.po b/apps/web/locales/ml-IN.po
index 426e440a8..5058ff379 100644
--- a/apps/web/locales/ml-IN.po
+++ b/apps/web/locales/ml-IN.po
@@ -11946,6 +11946,10 @@ msgstr "{name} സാമ്പിൾ PDF പ്രിവ്യൂ ചെയ്
msgid "Preview size"
msgstr "പ്രിവ്യൂ വലുപ്പം"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/mr-IN.po b/apps/web/locales/mr-IN.po
index e9684ba7a..2d22b80c5 100644
--- a/apps/web/locales/mr-IN.po
+++ b/apps/web/locales/mr-IN.po
@@ -11946,6 +11946,10 @@ msgstr "{name} नमुना PDF चे पूर्वावलोकन क
msgid "Preview size"
msgstr "पूर्वावलोकन आकार"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ms-MY.po b/apps/web/locales/ms-MY.po
index b63690097..cdf3f554e 100644
--- a/apps/web/locales/ms-MY.po
+++ b/apps/web/locales/ms-MY.po
@@ -11946,6 +11946,10 @@ msgstr "Pratonton {name} sampel PDF"
msgid "Preview size"
msgstr "Saiz pratonton"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ne-NP.po b/apps/web/locales/ne-NP.po
index 75094e57d..503c474a8 100644
--- a/apps/web/locales/ne-NP.po
+++ b/apps/web/locales/ne-NP.po
@@ -11946,6 +11946,10 @@ msgstr "पूर्वावलोकन {name} नमूना PDF"
msgid "Preview size"
msgstr "पूर्वावलोकन आकार"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/nl-NL.po b/apps/web/locales/nl-NL.po
index da5237790..84e85af72 100644
--- a/apps/web/locales/nl-NL.po
+++ b/apps/web/locales/nl-NL.po
@@ -11946,6 +11946,10 @@ msgstr "Bekijk een voorbeeld-PDF van {name}"
msgid "Preview size"
msgstr "Voorbeeldgrootte"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/no-NO.po b/apps/web/locales/no-NO.po
index 658870d9f..e726586c3 100644
--- a/apps/web/locales/no-NO.po
+++ b/apps/web/locales/no-NO.po
@@ -11946,6 +11946,10 @@ msgstr "Forhåndsvis {name} eksempel-PDF"
msgid "Preview size"
msgstr "Forhåndsvisningsstørrelse"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/or-IN.po b/apps/web/locales/or-IN.po
index 300b4ed29..7f464ee9b 100644
--- a/apps/web/locales/or-IN.po
+++ b/apps/web/locales/or-IN.po
@@ -11948,6 +11948,10 @@ msgstr "ପୂର୍ବାବଲୋକନ {name} ନମୁନା PDF |"
msgid "Preview size"
msgstr "ପ୍ରିଭ୍ୟୁ ଆକାର"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/pl-PL.po b/apps/web/locales/pl-PL.po
index cedae20ea..d02deaf65 100644
--- a/apps/web/locales/pl-PL.po
+++ b/apps/web/locales/pl-PL.po
@@ -11946,6 +11946,10 @@ msgstr "Wyświetl podgląd przykładowego pliku PDF {name}"
msgid "Preview size"
msgstr "Rozmiar podglądu"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/pt-BR.po b/apps/web/locales/pt-BR.po
index bab847b7a..dc8f1ad49 100644
--- a/apps/web/locales/pt-BR.po
+++ b/apps/web/locales/pt-BR.po
@@ -11946,6 +11946,10 @@ msgstr "Visualizar exemplo de PDF de {name}"
msgid "Preview size"
msgstr "Tamanho da prévia"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/pt-PT.po b/apps/web/locales/pt-PT.po
index e0e0e2761..fd366a419 100644
--- a/apps/web/locales/pt-PT.po
+++ b/apps/web/locales/pt-PT.po
@@ -11946,6 +11946,10 @@ msgstr "Visualizar exemplo PDF de {name}"
msgid "Preview size"
msgstr "Tamanho da pré-visualização"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ro-RO.po b/apps/web/locales/ro-RO.po
index 778d6e14a..d9b807e09 100644
--- a/apps/web/locales/ro-RO.po
+++ b/apps/web/locales/ro-RO.po
@@ -11946,6 +11946,10 @@ msgstr "Previzualizează {name} exemplu PDF"
msgid "Preview size"
msgstr "Dimensiune previzualizare"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ru-RU.po b/apps/web/locales/ru-RU.po
index 85acfe35a..de66a8886 100644
--- a/apps/web/locales/ru-RU.po
+++ b/apps/web/locales/ru-RU.po
@@ -11946,6 +11946,10 @@ msgstr "Предварительный просмотр примера PDF-фа
msgid "Preview size"
msgstr "Размер предпросмотра"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/sk-SK.po b/apps/web/locales/sk-SK.po
index 06bd0a7e7..7b33350cb 100644
--- a/apps/web/locales/sk-SK.po
+++ b/apps/web/locales/sk-SK.po
@@ -11946,6 +11946,10 @@ msgstr "Ukážka {name} ukážkového PDF"
msgid "Preview size"
msgstr "Veľkosť náhľadu"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/sl-SI.po b/apps/web/locales/sl-SI.po
index e0094fb9d..055871dd8 100644
--- a/apps/web/locales/sl-SI.po
+++ b/apps/web/locales/sl-SI.po
@@ -11946,6 +11946,10 @@ msgstr "Predogled {name} vzorca PDF"
msgid "Preview size"
msgstr "Velikost predogleda"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/sq-AL.po b/apps/web/locales/sq-AL.po
index 641890ff8..ba77737b0 100644
--- a/apps/web/locales/sq-AL.po
+++ b/apps/web/locales/sq-AL.po
@@ -11946,6 +11946,10 @@ msgstr "Shikoni paraprakisht {name} mostër PDF"
msgid "Preview size"
msgstr "Madhësia e pamjes paraprake"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/sr-SP.po b/apps/web/locales/sr-SP.po
index 9c2f6bbeb..187ea0336 100644
--- a/apps/web/locales/sr-SP.po
+++ b/apps/web/locales/sr-SP.po
@@ -11946,6 +11946,10 @@ msgstr "Прегледајте {name} пример PDF-а"
msgid "Preview size"
msgstr "Величина прегледа"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/sv-SE.po b/apps/web/locales/sv-SE.po
index 2563e74b4..780d11db5 100644
--- a/apps/web/locales/sv-SE.po
+++ b/apps/web/locales/sv-SE.po
@@ -11946,6 +11946,10 @@ msgstr "Förhandsgranska {name} exempel-PDF"
msgid "Preview size"
msgstr "Förhandsvisningsstorlek"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/ta-IN.po b/apps/web/locales/ta-IN.po
index 21e8a71b6..5fedd158d 100644
--- a/apps/web/locales/ta-IN.po
+++ b/apps/web/locales/ta-IN.po
@@ -11946,6 +11946,10 @@ msgstr "{name} மாதிரி PDF மாதிரிக்காட்சி
msgid "Preview size"
msgstr "முன்னோட்ட அளவு"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/te-IN.po b/apps/web/locales/te-IN.po
index c71ccc103..e58f7d68e 100644
--- a/apps/web/locales/te-IN.po
+++ b/apps/web/locales/te-IN.po
@@ -11946,6 +11946,10 @@ msgstr "ప్రివ్యూ {name} నమూనా PDF"
msgid "Preview size"
msgstr "ప్రివ్యూ పరిమాణం"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/th-TH.po b/apps/web/locales/th-TH.po
index 686cf7073..ec3037fbe 100644
--- a/apps/web/locales/th-TH.po
+++ b/apps/web/locales/th-TH.po
@@ -11946,6 +11946,10 @@ msgstr "ดูตัวอย่าง {name} PDF"
msgid "Preview size"
msgstr "ขนาดตัวอย่าง"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/tr-TR.po b/apps/web/locales/tr-TR.po
index ffed0bb90..53162fc9f 100644
--- a/apps/web/locales/tr-TR.po
+++ b/apps/web/locales/tr-TR.po
@@ -11946,6 +11946,10 @@ msgstr "{name} örnek PDF'sini önizleyin"
msgid "Preview size"
msgstr "Önizleme boyutu"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/uk-UA.po b/apps/web/locales/uk-UA.po
index edbc4f257..09322afff 100644
--- a/apps/web/locales/uk-UA.po
+++ b/apps/web/locales/uk-UA.po
@@ -11946,6 +11946,10 @@ msgstr "Попередній перегляд зразка PDF {name}"
msgid "Preview size"
msgstr "Розмір попереднього перегляду"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/uz-UZ.po b/apps/web/locales/uz-UZ.po
index 31468db0b..ca1f528c0 100644
--- a/apps/web/locales/uz-UZ.po
+++ b/apps/web/locales/uz-UZ.po
@@ -11946,6 +11946,10 @@ msgstr "{name} PDF namunasini oldindan koʻrish"
msgid "Preview size"
msgstr "Oldindan ko'rish o'lchami"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/vi-VN.po b/apps/web/locales/vi-VN.po
index c16e933e8..322915f3a 100644
--- a/apps/web/locales/vi-VN.po
+++ b/apps/web/locales/vi-VN.po
@@ -11946,6 +11946,10 @@ msgstr "Xem trước bản PDF mẫu của {name}"
msgid "Preview size"
msgstr "Kích thước xem trước"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/zh-CN.po b/apps/web/locales/zh-CN.po
index d696c4e50..b0343070a 100644
--- a/apps/web/locales/zh-CN.po
+++ b/apps/web/locales/zh-CN.po
@@ -11946,6 +11946,10 @@ msgstr "预览 {name} 示例 PDF"
msgid "Preview size"
msgstr "预览尺寸"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/zh-TW.po b/apps/web/locales/zh-TW.po
index 1030d559b..b0b76674c 100644
--- a/apps/web/locales/zh-TW.po
+++ b/apps/web/locales/zh-TW.po
@@ -11946,6 +11946,10 @@ msgstr "預覽 {name} 範例 PDF"
msgid "Preview size"
msgstr "預覽大小"
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/locales/zu-ZA.po b/apps/web/locales/zu-ZA.po
index 6e15af209..f6214138d 100644
--- a/apps/web/locales/zu-ZA.po
+++ b/apps/web/locales/zu-ZA.po
@@ -11941,6 +11941,10 @@ msgstr ""
msgid "Preview size"
msgstr ""
+#: src/features/documents/document-card.tsx
+msgid "Preview unavailable"
+msgstr ""
+
#. placeholder {0}: templates[previewTemplate].name
#: src/routes/builder/$resumeId/-components/page-canvas.tsx
#: src/routes/builder/letter/-components/letter-page.tsx
diff --git a/apps/web/src/features/applications/components/insights-view.tsx b/apps/web/src/features/applications/components/insights-view.tsx
index f43890539..c38a32c51 100644
--- a/apps/web/src/features/applications/components/insights-view.tsx
+++ b/apps/web/src/features/applications/components/insights-view.tsx
@@ -10,6 +10,7 @@ import { EmptyState } from "@reactive-resume/ui/components/empty-state";
import { Icon } from "@reactive-resume/ui/components/icon";
import { Skeleton } from "@reactive-resume/ui/components/skeleton";
import { toast } from "@reactive-resume/ui/components/toast";
+import { fitLabel } from "@reactive-resume/utils/string";
import { resolveExportTokens } from "../flow-tokens";
import { computeInsights, computeOutcomes, computeTimeline, countSources } from "../insights";
import { getCategoryDisplay } from "../lanes";
@@ -240,8 +241,7 @@ export function ApplicationInsights({ applications, onSaveJob, onClearFilters }:
const FLOW_FONT = "var(--font-ui)";
// RxR mark ~18px wide in the 256-unit icon viewBox (the mark's glyphs span y ≈ 36–220).
const ICON_SCALE = 18 / 256;
-// A label wider than this runs into the next stage; keep the owner's name, with an ellipsis when it is very long.
-const fitFlowLabel = (label: string) => (label.length > 18 ? `${label.slice(0, 17)}…` : label);
+const FLOW_LABEL_MAX = 18;
function toBase64(buffer: ArrayBuffer): string {
const bytes = new Uint8Array(buffer);
@@ -434,7 +434,7 @@ function PipelineFlow({
{bar.reached}
</text>
<text x={bar.cx} y={H - 42} textAnchor="middle" fontSize={12} fontWeight={500} fill="var(--ink-2)">
- {fitFlowLabel(bar.label)}
+ {fitLabel(bar.label, FLOW_LABEL_MAX)}
</text>
{i > 0 && (
<text x={bar.cx} y={H - 26} textAnchor="middle" fontSize={11} fill={bar.color}>
diff --git a/apps/web/src/features/documents/document-card.test.tsx b/apps/web/src/features/documents/document-card.test.tsx
index d3a7ba1a4..f114e74e6 100644
--- a/apps/web/src/features/documents/document-card.test.tsx
+++ b/apps/web/src/features/documents/document-card.test.tsx
@@ -14,7 +14,11 @@ vi.mock("motion/react", async (importOriginal) => ({
useInView: () => true,
}));
vi.mock("@tanstack/react-router", () => ({
- Link: ({ children }: { children: React.ReactNode }) => <a href="/documents">{children}</a>,
+ Link: ({ children, ...props }: React.ComponentProps<"a">) => (
+ <a href="/documents" {...props}>
+ {children}
+ </a>
+ ),
useNavigate: () => vi.fn(),
}));
vi.mock("@/libs/orpc/client", () => ({
@@ -78,6 +82,34 @@ it("previews a letter's recipient, greeting and opening lines", async () => {
expect(screen.getByText("Northwind Labs")).toBeTruthy();
});
+it("describes the letter's opening words for screen readers without changing the link's name", async () => {
+ letters.load.mockResolvedValue({ greeting: "Dear Dana,", content: "<p>I am writing about the role.</p>" });
+ renderCard(letter(new Date("2026-10-19T00:00:00.000Z")));
+ await screen.findByText("I am writing about the role.");
+
+ const link = screen.getByRole("link", { name: "Untitled letter" });
+ const id = link.getAttribute("aria-describedby");
+ expect(id).toBeTruthy();
+ expect(document.getElementById(id ?? "")?.textContent).toContain("Dear Dana,");
+ expect(document.getElementById(id ?? "")?.textContent).toContain("I am writing about the role.");
+});
+
+it("does not draw loading bars over a loaded greeting-only letter", async () => {
+ letters.load.mockResolvedValue({ greeting: "Dear Dana,", content: "" });
+ const { container } = renderCard(letter(new Date("2026-10-19T00:00:00.000Z")));
+ await screen.findByText("Dear Dana,");
+
+ expect(container.querySelectorAll("span.h-1")).toHaveLength(0);
+ expect(screen.queryByText("Empty letter")).toBeNull();
+});
+
+it("shows a failed preview instead of an endless loading placeholder", async () => {
+ letters.load.mockRejectedValue(new Error("preview failed"));
+ renderCard(letter(new Date("2026-10-19T00:00:00.000Z")));
+
+ expect(await screen.findByText("Preview unavailable")).toBeTruthy();
+});
+
it("fetches a new preview after the letter's content edit", async () => {
letters.load.mockResolvedValue({ greeting: null, content: "<p>First version.</p>" });
const view = renderCard(letter(new Date("2026-10-19T00:00:00.000Z")));
diff --git a/apps/web/src/features/documents/document-card.tsx b/apps/web/src/features/documents/document-card.tsx
index cea6c1097..ad43b282b 100644
--- a/apps/web/src/features/documents/document-card.tsx
+++ b/apps/web/src/features/documents/document-card.tsx
@@ -5,7 +5,7 @@ import { Plural, Trans } from "@lingui/react/macro";
import { useQuery } from "@tanstack/react-query";
import { Link, useNavigate } from "@tanstack/react-router";
import { useInView } from "motion/react";
-import { useRef, useState } from "react";
+import { useId, useRef, useState } from "react";
import { Checkbox } from "@reactive-resume/ui/components/checkbox";
import { ContextMenu, ContextMenuTrigger } from "@reactive-resume/ui/components/context-menu";
import { DropdownMenu, DropdownMenuTrigger } from "@reactive-resume/ui/components/dropdown-menu";
@@ -52,11 +52,14 @@ function OpenLink({
className,
children,
label,
+ describedBy,
onSelect,
disabled,
dir,
}: Pick<DocumentItemProps, "document" | "disabled"> & {
className?: string;
+ /** The id of an extra description, such as a letter's opening lines, so equal names stay distinguishable. */
+ describedBy?: string | undefined;
/** "auto" when the link's text is the document's name, so the name keeps its own direction. */
dir?: "auto";
children: React.ReactNode;
@@ -76,7 +79,7 @@ function OpenLink({
event.preventDefault();
onSelect();
};
- const common = { "aria-label": label, className, onClick, dir };
+ const common = { "aria-label": label, "aria-describedby": describedBy, className, onClick, dir };
return document.type === "resume" ? (
<Link to="/builder/$resumeId" params={{ resumeId: document.id }} {...common}>
@@ -99,7 +102,7 @@ function RenameInput({ document, onDone }: { document: DocumentSummary; onDone:
* A letter's page: its recipient and opening lines, so several letters can be told apart. The text is the owner's own
* letter, read only once the card nears the viewport and cached until the letter's content changes (`editedAt`).
*/
-function LetterThumbnail({ document }: { document: DocumentSummary }) {
+function LetterThumbnail({ document, descriptionId }: { document: DocumentSummary; descriptionId: string }) {
const containerRef = useRef<HTMLDivElement>(null);
const isInView = useInView(containerRef, { amount: 0.1, margin: "240px" });
const options = orpc.coverLetters.getById.queryOptions({ input: { id: document.id } });
@@ -114,32 +117,45 @@ function LetterThumbnail({ document }: { document: DocumentSummary }) {
const greeting = letter.data ? letterGreeting(letter.data.greeting) : null;
const lines = letter.data ? letterBodyLines(letter.data.content) : [];
const empty = letter.isSuccess && !greeting && lines.length === 0;
+ const description =
+ [recipient, greeting, lines[0]].filter(Boolean).join(". ") ||
+ (letter.isError ? t`Preview unavailable` : empty ? t`Empty letter` : "");
return (
- <div ref={containerRef} aria-hidden="true" className="flex size-full flex-col gap-1 bg-white p-[14%] text-[0]">
- <span className="h-1.5 w-2/5 rounded-sm bg-[#c9c9c9]" />
- {recipient ? (
- <span className="truncate text-[10px] leading-4 font-semibold text-[#3a3a3a]">{recipient}</span>
- ) : null}
- {greeting ? <span className="truncate text-[9px] leading-3 text-[#3a3a3a]">{greeting}</span> : null}
- {lines.length > 0 ? (
- lines.map((line, index) => (
- <span key={`${index}-${line}`} className="line-clamp-2 text-[9px] leading-3 text-[#6d6d6d]">
- {line}
+ <>
+ <div ref={containerRef} aria-hidden="true" className="flex size-full flex-col gap-1 bg-white p-[14%] text-[0]">
+ <span className="h-1.5 w-2/5 rounded-sm bg-[#c9c9c9]" />
+ {recipient ? (
+ <span className="truncate text-[10px] leading-4 font-semibold text-[#3a3a3a]">{recipient}</span>
+ ) : null}
+ {greeting ? <span className="truncate text-[9px] leading-3 text-[#3a3a3a]">{greeting}</span> : null}
+ {lines.length > 0 ? (
+ lines.map((line, index) => (
+ <span key={`${index}-${line}`} className="line-clamp-2 text-[9px] leading-3 text-[#6d6d6d]">
+ {line}
+ </span>
+ ))
+ ) : letter.isError ? (
+ <span className="truncate text-[9px] leading-3 text-[#9a9a9a]">
+ <Trans>Preview unavailable</Trans>
+ </span>
+ ) : empty ? (
+ <span className="truncate text-[9px] leading-3 text-[#9a9a9a]">
+ <Trans>Empty letter</Trans>
</span>
- ))
- ) : empty ? (
- <span className="truncate text-[9px] leading-3 text-[#9a9a9a]">
- <Trans>Empty letter</Trans>
- </span>
- ) : (
- // Loading, or content that couldn't be read: keep the page's shape rather than an empty frame.
- Array.from({ length: 7 }, (_, index) => (
- <span key={index} className={cn("h-1 rounded-sm bg-[#e6e6e6]", index % 3 === 2 ? "w-4/5" : "w-full")} />
- ))
- )}
- <span className="sr-only">{document.name}</span>
- </div>
+ ) : letter.isSuccess ? null : (
+ // Loading: keep the page's shape rather than an empty frame.
+ Array.from({ length: 7 }, (_, index) => (
+ <span key={index} className={cn("h-1 rounded-sm bg-[#e6e6e6]", index % 3 === 2 ? "w-4/5" : "w-full")} />
+ ))
+ )}
+ </div>
+ {/* Outside the aria-hidden page: the link's accessible name stays the document name, and this reads the
+ letter's own opening words so two equally named letters remain distinguishable. */}
+ <span id={descriptionId} className="sr-only">
+ {description}
+ </span>
+ </>
);
}
@@ -167,6 +183,7 @@ export function DocumentCard({
disabled = false,
}: DocumentItemProps) {
const openDocument = useOpenDocument();
+ const descriptionId = useId();
const requestedRename = useNewDocumentsStore((state) => state.renameId === document.id);
const [localRenaming, setLocalRenaming] = useState(false);
const renaming = localRenaming || requestedRename;
@@ -208,6 +225,7 @@ export function DocumentCard({
document={document}
disabled={disabled}
label={document.name}
+ describedBy={document.type === "letter" ? descriptionId : undefined}
onSelect={selecting && onSelectedChange ? () => onSelectedChange(!selected) : undefined}
className={cn(
"relative block aspect-page overflow-hidden rounded-md shadow-[0_0_0_1px_var(--line),var(--shadow-1)] transition-[translate,scale,box-shadow] duration-quick ease-enter hover:-translate-y-0.5 hover:shadow-[0_0_0_1px_var(--line),var(--shadow-2)] active:scale-[0.98]",
@@ -220,7 +238,7 @@ export function DocumentCard({
{document.type === "resume" ? (
<ResumeThumbnail resume={document} />
) : (
- <LetterThumbnail document={document} />
+ <LetterThumbnail document={document} descriptionId={descriptionId} />
)}
{/* Bottom of the paper: its top is where every template prints the person's name. */}
<span className="absolute start-2 bottom-2 flex gap-1">
diff --git a/apps/web/src/features/documents/letter-preview.test.ts b/apps/web/src/features/documents/letter-preview.test.ts
index bf4e9a12e..1be2b3fb1 100644
--- a/apps/web/src/features/documents/letter-preview.test.ts
+++ b/apps/web/src/features/documents/letter-preview.test.ts
@@ -22,6 +22,11 @@ describe("letterBodyLines", () => {
]);
});
+ it("decodes entities the stored letter HTML carries", () => {
+ expect(letterBodyLines("<p>R&amp;D &amp; design&nbsp;team</p>")).toEqual(["R&D & design team"]);
+ expect(letterBodyLines("<p>&lt;hello&gt; &#39;world&#39;</p>")).toEqual(["<hello> 'world'"]);
+ });
+
it("returns nothing for a letter with no body", () => {
expect(letterBodyLines("")).toEqual([]);
expect(letterBodyLines(null)).toEqual([]);
diff --git a/apps/web/src/features/documents/letter-preview.ts b/apps/web/src/features/documents/letter-preview.ts
index 8e9c6a93e..8bac991b5 100644
--- a/apps/web/src/features/documents/letter-preview.ts
+++ b/apps/web/src/features/documents/letter-preview.ts
@@ -3,13 +3,62 @@ import { stripHtml } from "@reactive-resume/utils/string";
/** How many opening lines a thumbnail shows; enough to tell letters apart, few enough to stay a page miniature. */
const LETTER_PREVIEW_LINES = 3;
+/**
+ * Stored letter HTML can carry entities (`R&amp;D`, `&nbsp;`). `stripHtml` removes tags but leaves them, so decode the
+ * text the reader would see. Covers the named and numeric entities the sanitized rich-text surface emits; anything
+ * unknown stays as written rather than becoming a replacement character.
+ */
+const NAMED_ENTITIES: Record<string, string> = {
+ amp: "&",
+ lt: "<",
+ gt: ">",
+ quot: '"',
+ apos: "'",
+ nbsp: "\u00a0",
+ copy: "©",
+ reg: "®",
+ trade: "™",
+ hellip: "…",
+ mdash: "—",
+ ndash: "–",
+ lsquo: "‘",
+ rsquo: "’",
+ ldquo: "“",
+ rdquo: "”",
+ bull: "•",
+ middot: "·",
+ deg: "°",
+ plusmn: "±",
+ times: "×",
+ divide: "÷",
+ frac12: "½",
+};
+
+function decodeEntities(text: string): string {
+ if (!text.includes("&")) return text;
+ return text.replace(/&(#x[\da-f]+|#\d+|[a-z]+);/gi, (entity, code: string) => {
+ if (code.startsWith("#")) {
+ const point =
+ code[1]?.toLowerCase() === "x" ? Number.parseInt(code.slice(2), 16) : Number.parseInt(code.slice(1), 10);
+ try {
+ return String.fromCodePoint(point);
+ } catch {
+ return entity;
+ }
+ }
+ return NAMED_ENTITIES[code.toLowerCase()] ?? entity;
+ });
+}
+
/**
* The opening lines of a letter's body as the page reads them: paragraph and line breaks become lines, markup is
- * stripped, blank lines dropped. Bounded, since a thumbnail only needs the start of the letter.
+ * stripped, entities decoded, blank lines dropped. Bounded, since a thumbnail only needs the start of the letter.
*/
export function letterBodyLines(content: string | null | undefined, max = LETTER_PREVIEW_LINES): string[] {
if (!content) return [];
- const text = stripHtml(content.replace(/<\/(?:p|div|li|h[1-6])>|<br\s*\/?>/gi, "\n").replace(/\r/g, ""));
+ const text = decodeEntities(
+ stripHtml(content.replace(/<\/(?:p|div|li|h[1-6])>|<br\s*\/?>/gi, "\n").replace(/\r/g, "")),
+ ).replace(/\u00a0/g, " ");
return text
.split("\n")
.map((line) => line.trim())
diff --git a/packages/utils/src/string.test.ts b/packages/utils/src/string.test.ts
index 3bfaf699c..132b924ea 100644
--- a/packages/utils/src/string.test.ts
+++ b/packages/utils/src/string.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from "vite-plus/test";
import { slugify } from "./slug";
-import { filterOptions, getInitials, isolate, rewriteSummary, toUsername } from "./string";
+import { filterOptions, fitLabel, getInitials, isolate, rewriteSummary, toUsername } from "./string";
describe("slugify", () => {
it("falls back to a non-empty slug for CJK input", () => {
@@ -20,6 +20,24 @@ describe("toUsername", () => {
});
});
+describe("fitLabel", () => {
+ it("leaves a short label alone", () => {
+ expect(fitLabel("Recruiter call", 18)).toBe("Recruiter call");
+ expect(fitLabel("Recruiter call", 14)).toBe("Recruiter call");
+ });
+
+ it("ends a long label with an ellipsis within the limit", () => {
+ expect(fitLabel("a".repeat(20), 18)).toBe(`${"a".repeat(17)}…`);
+ });
+
+ it("counts code points so an emoji is never cut in half", () => {
+ const label = "😀".repeat(20);
+ const fitted = fitLabel(label, 18);
+ expect(fitted).toBe(`${"😀".repeat(17)}…`);
+ expect([...fitted]).toHaveLength(18);
+ });
+});
+
describe("filterOptions", () => {
const options = [
{ value: "AT", label: "Österreich" },
diff --git a/packages/utils/src/string.ts b/packages/utils/src/string.ts
index 1266fc939..a6da0981f 100644
--- a/packages/utils/src/string.ts
+++ b/packages/utils/src/string.ts
@@ -92,6 +92,16 @@ export function stripHtml(html: string | undefined): string {
return html.replace(/<[^<>]*>/g, "").trim();
}
+/**
+ * Shortens a label to at most `max` code points, ending with an ellipsis when it was longer. Code points (not UTF-16
+ * units) keep astral characters such as emoji whole, so a chart label never ends on half a surrogate pair.
+ */
+export function fitLabel(text: string, max: number): string {
+ if (max <= 0) return "";
+ const characters = Array.from(text);
+ return characters.length > max ? `${characters.slice(0, max - 1).join("")}…` : text;
+}
+
/** FNV-1a over the text: a short, stable fingerprint. Not for security. */
export function fnv1a(text: string): number {
let hash = 0x811c9dc5;