fix(pdf): stack eyebrow + title without overlap, color-code severity pill

Eyebrow OBSERVATION / SYNTHÈSE now baseline-anchored at y=height-95;
title baseline at y=height-122. 27pt separation between baselines so
the Times-22 ascender no longer reaches into the eyebrow line.

Severity next to the observation number is rendered as a filled pill
with white uppercase label. Background color encodes severity at a
glance:
- légère  → sage green
- modérée → amber
- sévère  → red

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude committed 2026-05-19 06:14:14 +02:00
1 parent ee5b7f0277
commit d7ea99e040
2 files changed
+39 -11

No files matched your search

+4 -2
View File
@@ -5,7 +5,8 @@ import { drawHeader } from './header'
import { formatDateFr } from '@/lib/dates'
const MARGIN_X = 36
const TITLE_Y_OFFSET = 115
const EYEBROW_Y_OFFSET = 95
const TITLE_Y_OFFSET = 122
const TITLE_RULE_OFFSET = 12
const TITLE_RULE_WIDTH = 48
const SECTION_TOP_GAP = 28
@@ -45,10 +46,11 @@ export async function addConclusionPage(
drawHeader(page, report, fonts)
const eyebrowY = height - EYEBROW_Y_OFFSET
const titleY = height - TITLE_Y_OFFSET
page.drawText('SYNTHÈSE', {
x: MARGIN_X,
y: titleY + 14,
y: eyebrowY,
size: 9,
font: fonts.bodyBold,
color: COLOR_ACCENT,
+35 -9
View File
@@ -9,7 +9,8 @@ import { parseSvgBones } from '@/anatomy/svgConvention'
import { getSpecies } from '@/domain/species/registry'
const MARGIN_X = 36
const TITLE_Y_OFFSET = 115
const EYEBROW_Y_OFFSET = 95
const TITLE_Y_OFFSET = 122
const TITLE_RULE_OFFSET = 12
const TITLE_RULE_WIDTH = 48
const IMAGE_TOP_GAP = 32
@@ -23,6 +24,13 @@ const SECTION_BLOCK_GAP = 10
const COLOR_INK = rgb(0.12, 0.11, 0.09)
const COLOR_MUTED = rgb(0.42, 0.39, 0.35)
const COLOR_ACCENT = rgb(0.72, 0.35, 0.25)
const COLOR_WHITE = rgb(1, 1, 1)
const SEVERITY_BG: Record<string, ReturnType<typeof rgb>> = {
'légère': rgb(0.55, 0.65, 0.45),
'modérée': rgb(0.85, 0.55, 0.18),
'sévère': rgb(0.78, 0.20, 0.20),
}
function wrapLines(text: string, font: PDFFont, size: number, max: number): string[] {
const words = text.split(/\s+/)
@@ -87,11 +95,12 @@ export async function addObservationPage(
const { width, height } = page.getSize()
drawHeader(page, report, fonts)
const eyebrowY = height - EYEBROW_Y_OFFSET
const titleY = height - TITLE_Y_OFFSET
const obsLabel = String(obsIndex + 1).padStart(2, '0')
page.drawText('OBSERVATION', {
x: MARGIN_X,
y: titleY + 14,
y: eyebrowY,
size: 9,
font: fonts.bodyBold,
color: COLOR_ACCENT,
@@ -103,14 +112,31 @@ export async function addObservationPage(
font: fonts.headingRegular,
color: COLOR_INK,
})
const numW = fonts.headingRegular.widthOfTextAtSize(obsLabel, 22)
if (observation.severity) {
page.drawText(`Sévérité — ${observation.severity}`, {
x: MARGIN_X + numW + 16,
y: titleY + 5,
size: 10,
font: fonts.bodyRegular,
color: COLOR_MUTED,
const numW = fonts.headingRegular.widthOfTextAtSize(obsLabel, 22)
const sev = observation.severity
const sevText = sev.toUpperCase()
const sevSize = 9
const sevTextW = fonts.bodyBold.widthOfTextAtSize(sevText, sevSize)
const padX = 8
const padY = 4
const pillW = sevTextW + padX * 2
const pillH = sevSize + padY * 2
const pillX = MARGIN_X + numW + 14
const pillY = titleY + 4
page.drawRectangle({
x: pillX,
y: pillY,
width: pillW,
height: pillH,
color: SEVERITY_BG[sev] ?? COLOR_MUTED,
})
page.drawText(sevText, {
x: pillX + padX,
y: pillY + padY,
size: sevSize,
font: fonts.bodyBold,
color: COLOR_WHITE,
})
}
page.drawLine({