Skip to content

feat(cv-v2): migrate Monogram Sidebar preset + multi-rect pageBackgrounds engine API#65

Merged
DemchaAV merged 1 commit into
developfrom
feature/cv-v2-monogram-sidebar-preset
May 27, 2026
Merged

feat(cv-v2): migrate Monogram Sidebar preset + multi-rect pageBackgrounds engine API#65
DemchaAV merged 1 commit into
developfrom
feature/cv-v2-monogram-sidebar-preset

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Summary

  • Preset: v2 port of the legacy Monogram Sidebar CV — pale teal full-bleed sidebar with a Crimson Text monogram badge, centered icon contact stack, education + expertise modules; right column carries the spaced-caps name + professional summary, experience, projects, and additional info.
  • Engine: new additive pageBackgrounds(List<PageBackgroundFill>) API for multi-rect page chrome — both columns repeat automatically on every page without preset-side filler logic.
  • Theme: CvPalette gains a 5th mainFill field with a 4-arg legacy constructor that preserves all 12 existing palette factories.

Engine extension (additive, backward-compatible)

New public record com.demcha.compose.document.api.PageBackgroundFill with factory helpers (fullPage, leftColumn, rightColumn, column) defined as ratios of the canvas, so a single API scales across page formats.

document.pageBackgrounds(List.of(
    PageBackgroundFill.leftColumn(0.33, sidebarColor),
    PageBackgroundFill.rightColumn(0.67, mainColor)));

The legacy pageBackground(color) keeps working unchanged — internally it delegates to a one-fill list. All 18 legacy callers (PageBackgroundTest, InvoiceTemplateV2Test, ProposalTemplateV2Test, PdfBackendExtensibilityTest, BusinessTheme, GraphCompose.DocumentBuilder) pass without modification.

Preset highlights

  • Two-column page chrome painted via the new engine API → on page 2+ the layout structure inherits automatically.
  • Options.sidebarFillColor + Options.mainFillColor for runtime colour overrides without forking the theme.
  • Reuses shared ProjectRenderer, LabelValueRenderer, SectionLookup, MarkdownInline, TextOrnaments.spacedUpper — no preset-local helpers that duplicate existing components.

Architecture

  • PublicApiNoEngineLeakTest — green (FQN-only usage of engine internals).
  • ShapeContainerInvariantsTest — green.
  • New PageBackgroundFill is a public-API-package record; its validation and factory helpers are unit-tested directly.

Test plan

  • PageBackgroundTest — 10 tests (5 legacy + 5 new direct multi-rect API tests, including validation + factory helpers + empty-list clear semantics).
  • MonogramSidebarSmokeTest — 4 tests including a new assertion that the two-column page chrome is emitted on every rendered page.
  • CvV2VisualParityTest — 14 presets including new monogram_sidebar baseline.
  • Full canonical suite: 958/958 passing.
  • Visual parity gate — pixel-diff under budget against the committed baseline.

Limitations / follow-ups (not in scope for this PR)

  • The row inside the preset is PaginationPolicy.ATOMIC, so the preset itself can't yet span multiple pages. The new engine API is multi-page-aware (its primary motivation) and will start scaling correctly the moment row-pagination contracts land. That work is a separate engine task.
  • MonogramSidebar's addSidebarHeader / addNameBlock / addContactBlock stay preset-local because no existing SectionHeader / Headline / ContactLine widget variant matches their exact visual (centered + multi-line + stacked-icon shapes). Extracting these as new widget variants is a future refactor opportunity once a second preset wants them.

…kgrounds engine API

New v2 preset port of the legacy MonogramSidebarCvTemplateComposer: pale
teal sidebar with a Crimson Text monogram badge, centered icon contact
stack, education + expertise modules; right column carries the spaced-caps
name, professional summary, experience, projects, and additional info.

Engine — new multi-rect page-background API (additive, backward-compat):
 - PageBackgroundFill record with factory helpers (fullPage, leftColumn,
   rightColumn, column) defined as ratios of the canvas page size so the
   same fill scales across page formats.
 - DocumentSession.pageBackgrounds(List<PageBackgroundFill>) + parallel
   GraphCompose.DocumentBuilder.pageBackgrounds(List) builder method.
 - DocumentPageBackgrounds.apply now emits one fragment per fill per
   page, painted at z=0 in list order. The legacy single-color
   pageBackground(color) keeps working unchanged via delegation to a
   one-fill list.

Theme — additive CvPalette extension:
 - New 5th field mainFill (defaults to WHITE) carrying the right-column
   background. 4-arg legacy constructor preserved so all 12 existing
   palette factories compile and behave identically.

Preset highlights:
 - Two-column chrome painted via pageBackgrounds, so overflow content on
   page 2+ inherits the same visual structure with no preset-side filler
   logic.
 - Options exposes sidebarFillColor + mainFillColor for runtime overrides
   without forking the theme.
 - Reuses shared ProjectRenderer, LabelValueRenderer, SectionLookup,
   MarkdownInline, TextOrnaments.spacedUpper — no preset-local helpers
   that duplicate existing components.

Tests:
 - 5 new direct tests for the multi-rect API (PageBackgroundTest):
   multi-fill emission, fullPage parity, empty-list clear, ratio
   validation, factory helpers.
 - New MonogramSidebarSmokeTest assertion verifying the two-column page
   chrome is emitted on every rendered page.
 - Visual parity baseline at
   src/test/resources/visual-baselines/cv-v2-layered/monogram_sidebar-page-0.png.
 - Full canonical suite: 958/958 passing.

Refs: ADR-aligned (additive engine extension via new public record
PageBackgroundFill; no engine internals leak to the public API).
// -- Main column ---------------------------------------------------

private void addMain(SectionBuilder section, CvIdentity identity,
List<CvSection> sections, double anchorWidth) {
@DemchaAV DemchaAV merged commit 7c33538 into develop May 27, 2026
9 checks passed
@DemchaAV DemchaAV deleted the feature/cv-v2-monogram-sidebar-preset branch May 27, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants