chore(workspace): move the app to apps/app under a pnpm workspace (step 2)
144 files moved with git mv (pure renames). Root package.json delegates dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager, root devDependency, engine-strict). Dockerfile builds @faunosteo/app on node:24-alpine and copies apps/app/dist; nginx and runtime config unchanged. CI workflow for Gitea Actions. packages/ reserved (README only). Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan. 271/271 tests, typecheck, lint, build green from the root.
This commit is contained in:
1 parent
c8d48ab4cc
commit
8673475293
164 files changed
+348
-128
No files matched your search
@@ -0,0 +1,100 @@
|
||||
import type { PDFPage, PDFImage } from 'pdf-lib'
|
||||
import type { EmbeddedFonts } from '@/pdf/fonts'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
import { getDict } from '@/i18n'
|
||||
import { formatDate } from '@/lib/dates'
|
||||
import { addLinkAnnotation } from './linkAnnotation'
|
||||
import { MARGIN_X, COLOR_INK, COLOR_MUTED } from './constants'
|
||||
|
||||
const TOP_Y = 800
|
||||
const LOGO_WIDTH = 100
|
||||
const LOGO_HEIGHT = 38
|
||||
|
||||
export interface HeaderAssets {
|
||||
logoPng: PDFImage | null
|
||||
}
|
||||
|
||||
export function drawHeader(
|
||||
page: PDFPage,
|
||||
report: Report,
|
||||
fonts: EmbeddedFonts,
|
||||
locale: Locale,
|
||||
assets: HeaderAssets,
|
||||
): void {
|
||||
const dict = getDict(locale)
|
||||
const { width } = page.getSize()
|
||||
|
||||
const y = TOP_Y
|
||||
|
||||
const left = [
|
||||
report.practitioner.name,
|
||||
report.practitioner.cabinet,
|
||||
report.practitioner.contact,
|
||||
report.practitioner.siret
|
||||
? `${dict['pdf.siret_prefix']}${report.practitioner.siret}`
|
||||
: undefined,
|
||||
].filter(Boolean) as string[]
|
||||
|
||||
left.forEach((line, i) => {
|
||||
page.drawText(line, {
|
||||
x: MARGIN_X,
|
||||
y: y - i * 12,
|
||||
size: i === 0 ? 11 : 9,
|
||||
font: i === 0 ? fonts.bodyBold : fonts.bodyRegular,
|
||||
color: i === 0 ? COLOR_INK : COLOR_MUTED,
|
||||
})
|
||||
})
|
||||
|
||||
if (assets.logoPng) {
|
||||
const logoX = (width - LOGO_WIDTH) / 2
|
||||
const logoY = y - LOGO_HEIGHT + 10
|
||||
page.drawImage(assets.logoPng, {
|
||||
x: logoX,
|
||||
y: logoY,
|
||||
width: LOGO_WIDTH,
|
||||
height: LOGO_HEIGHT,
|
||||
})
|
||||
addLinkAnnotation(page, {
|
||||
x: logoX,
|
||||
y: logoY,
|
||||
width: LOGO_WIDTH,
|
||||
height: LOGO_HEIGHT,
|
||||
url: 'https://faunosteo.com',
|
||||
})
|
||||
}
|
||||
|
||||
const animalLine = [
|
||||
report.animal.name,
|
||||
report.animal.breed ? `(${report.animal.breed})` : '',
|
||||
report.animal.age ? `· ${report.animal.age}` : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
|
||||
const right = [
|
||||
animalLine,
|
||||
`${dict['pdf.owner_prefix']}${report.owner.name}`,
|
||||
formatDate(report.date, locale),
|
||||
]
|
||||
right.forEach((line, i) => {
|
||||
const size = i === 0 ? 11 : 9
|
||||
const font = i === 0 ? fonts.bodyBold : fonts.bodyRegular
|
||||
const w = font.widthOfTextAtSize(line, size)
|
||||
page.drawText(line, {
|
||||
x: width - MARGIN_X - w,
|
||||
y: y - i * 12,
|
||||
size,
|
||||
font,
|
||||
color: i === 0 ? COLOR_INK : COLOR_MUTED,
|
||||
})
|
||||
})
|
||||
|
||||
const separatorY = y - Math.max(left.length * 12, LOGO_HEIGHT) - 8
|
||||
page.drawLine({
|
||||
start: { x: MARGIN_X, y: separatorY },
|
||||
end: { x: width - MARGIN_X, y: separatorY },
|
||||
thickness: 0.5,
|
||||
color: COLOR_MUTED,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user