feat(flextable): reusable Civilytics flextable branding helpers #16

Merged
jared merged 1 commits from feat/flextable-branding into master 2026-07-09 16:18:44 -04:00
Owner

Adds reusable Civilytics flextable branding helpers.

This is the one commit (4f51a49) on feat/flextable-branding that never reached master: PR #10 merged this branch into feat/stamp-logo-png, but the commit wasn't carried along when feat/stamp-logo-png merged to master (PR #9). The branch is now exactly one commit ahead of master and not behind, so it merges cleanly.

What it adds

  • style_flextable_civilytics() — applies only the Civilytics visual brand to an already-structured flextable (header fill/color, body font/size, zebra striping guarded for < 2 rows, borders, footer). Every value is an overridable parameter; table structure (labels, widths, alignment) stays with the caller.
  • save_branded_flextable_png() — exports a styled flextable to PNG via ragg::agg_png() sized to the table plus extra_height, then optionally stamps the logo via stamp_logo_png().
  • flextable, officer, ragg added to Suggests (not Imports) to keep the base install light; both functions reference them fully qualified and guard with requireNamespace() + an install hint.
  • roxygen man pages + tests/testthat/test_flextable.R (styling, 1-row idempotence, PNG export, extra_height).

Verification

  • Full suite: 208 PASS / 0 FAIL (warnings are pre-existing testthat-2e deprecations).
  • flextable tests: 13 PASS / 0 FAIL.

Note

No version bump in this PR, to avoid a DESCRIPTION conflict with the other open PR (#15, which bumps to 0.3.0). Please reconcile the version when merging both.

Adds reusable Civilytics **flextable** branding helpers. This is the one commit (`4f51a49`) on `feat/flextable-branding` that never reached `master`: PR #10 merged this branch into `feat/stamp-logo-png`, but the commit wasn't carried along when `feat/stamp-logo-png` merged to master (PR #9). The branch is now **exactly one commit ahead of master and not behind**, so it merges cleanly. ## What it adds - **`style_flextable_civilytics()`** — applies only the Civilytics visual brand to an already-structured flextable (header fill/color, body font/size, zebra striping guarded for < 2 rows, borders, footer). Every value is an overridable parameter; table structure (labels, widths, alignment) stays with the caller. - **`save_branded_flextable_png()`** — exports a styled flextable to PNG via `ragg::agg_png()` sized to the table plus `extra_height`, then optionally stamps the logo via `stamp_logo_png()`. - `flextable`, `officer`, `ragg` added to **Suggests** (not Imports) to keep the base install light; both functions reference them fully qualified and guard with `requireNamespace()` + an install hint. - roxygen man pages + `tests/testthat/test_flextable.R` (styling, 1-row idempotence, PNG export, `extra_height`). ## Verification - Full suite: **208 PASS / 0 FAIL** (warnings are pre-existing testthat-2e deprecations). - flextable tests: **13 PASS / 0 FAIL**. ## Note No version bump in this PR, to avoid a `DESCRIPTION` conflict with the other open PR (#15, which bumps to 0.3.0). Please reconcile the version when merging both.
jared added 1 commit 2026-07-09 16:15:25 -04:00
feat(flextable): add reusable Civilytics flextable branding helpers
R-CMD-check / R CMD check (pull_request) Successful in 4m20s
4f51a49903
Generalize the flextable brand styling and "export to PNG + stamp logo"
pattern repeated across Civilytics projects into two small functions:

- style_flextable_civilytics(): applies only the visual brand (header
  fill/color, body font/size, zebra striping guarded for <2 rows,
  borders, footer styling, fixed layout) to an already-structured
  flextable. Every value is an overridable parameter; zebra toggles
  striping. Structure (labels, headers, widths, alignment, footer text)
  stays with the caller.
- save_branded_flextable_png(): exports a styled flextable to PNG via
  ragg::agg_png() sized to the table plus extra_height headroom, then
  optionally stamps the logo via stamp_logo_png() (... forwarded).

flextable, officer, and ragg are added to Suggests (not Imports) to keep
the base install light; both functions reference them fully qualified and
guard with requireNamespace() + an install hint. Real round-trip tests
cover styling, 1-row idempotence, PNG export, and extra_height.
jared merged commit 96dc1c4c6b into master 2026-07-09 16:18:44 -04:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Civilytics/civilyticsR#16