feat(C163): colunas mais largas no acervo de falas

This commit is contained in:
Francisco Solla 2026-09-15 09:05:14 -03:00
parent 05d4ac42d5
commit 5b801c4b52
4 changed files with 17 additions and 8 deletions

View file

@ -0,0 +1 @@
**C163 — largura das colunas no acervo de falas (2026-09-15):** a tabela "Acervo de falas" ganhou larguras explícitas por coluna (Data 8% · Fase 11% · O que é 37% · Menção ao município 32% · Link 12%) porque o sumário oficial e o trecho de menção são descrições elaboradas; o renderer passou a aceitar `width` por coluna e usa `table-layout: fixed` com `overflow-wrap` quando definido (a URL do Diário quebra dentro da célula). Unit 3117/3117 e `tsc` verdes; PDF de Itamaraju regerado.

View file

@ -802,11 +802,11 @@ const buildSpeechesSection = ({ snapshot }) => {
kind: 'table',
title: 'Acervo de falas',
columns: [
{ key: 'date', label: 'Data' },
{ key: 'phase', label: 'Fase' },
{ key: 'description', label: 'O que é' },
{ key: 'mention', label: `Menção a ${cityLabel}` },
{ key: 'link', label: 'Link' },
{ key: 'date', label: 'Data', width: 8 },
{ key: 'phase', label: 'Fase', width: 11 },
{ key: 'description', label: 'O que é', width: 37 },
{ key: 'mention', label: `Menção a ${cityLabel}`, width: 32 },
{ key: 'link', label: 'Link', width: 12 },
],
rows: speeches.rows.map((row) => ({
date: formatDateBr(row.speechAt),

View file

@ -127,6 +127,8 @@ const PRINT_CSS = `
.pair .panel li, .bullets li { margin-bottom: .8mm; }
.pair-note { color: #92400e; font-size: 7.6pt; margin: 1.2mm 0 0; }
table { width: 100%; border-collapse: collapse; font-size: 8pt; }
table.table-fixed { table-layout: fixed; }
table.table-fixed td, table.table-fixed th { overflow-wrap: anywhere; }
caption { caption-side: top; text-align: left; font-weight: 600; font-size: 8.6pt; padding-bottom: 1.2mm; color: #18181b; }
th { text-align: left; background: #f4f4f5; border-bottom: .8px solid #d4d4d8; padding: 1.4mm 1.4mm; font-size: 7pt; text-transform: uppercase; letter-spacing: .03em; color: #52525b; }
td { border-bottom: .6px solid #e4e4e7; padding: 1.4mm 1.4mm; vertical-align: top; }
@ -217,8 +219,12 @@ const renderPair = (block) => {
}
const renderTable = (block) => {
const fixed = block.columns.some((column) => column.width)
const head = block.columns
.map((column) => `<th${column.numeric ? ' class="num"' : ''}>${htmlEscape(column.label)}</th>`)
.map(
(column) =>
`<th${column.numeric ? ' class="num"' : ''}${column.width ? ` style="width:${column.width}%"` : ''}>${htmlEscape(column.label)}</th>`,
)
.join('')
const rows = block.rows
.map(
@ -231,7 +237,7 @@ const renderTable = (block) => {
.join('')}</tr>`,
)
.join('')
return `<table><caption>${htmlEscape(block.title)}</caption><thead><tr>${head}</tr></thead><tbody>${rows}</tbody></table>${
return `<table${fixed ? ' class="table-fixed"' : ''}><caption>${htmlEscape(block.title)}</caption><thead><tr>${head}</tr></thead><tbody>${rows}</tbody></table>${
block.note ? `<p class="table-note">${htmlEscape(block.note)}</p>` : ''
}`
}

View file

@ -306,7 +306,7 @@ type ReportBlock = {
title?: string
items?: ReportItem[]
rows?: ReportRow[]
columns?: Array<{ key: string; label: string }>
columns?: Array<{ key: string; label: string; width?: number }>
cells?: Array<{ title: string; blocks: ReportBlock[] }>
body?: string[]
sources?: Array<{ kind: string; url?: string | null }>
@ -389,6 +389,8 @@ describe('buildCityReport', () => {
`Menção a ${snapshot.municipality.name}`,
'Link',
])
expect(falas.columns!.find((column) => column.key === 'description')!.width).toBe(37)
expect(falas.columns!.find((column) => column.key === 'mention')!.width).toBe(32)
expect(rows[0].description).toBe('Resumo da fala')
expect(rows[0].mention).toContain('cita Feira de Santana')
expect(rows[1].description).toBe('Saúde indígena na Bahia')