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.
civilytics_logo()/make_logo_grob() brand ggplot/grobs, but flextables and
other outputs are rendered to PNG first and can't use them. stamp_logo_png()
is the raster analogue: it resolves the SAME brand asset that make_logo_grob()
uses (via the type/variant switch) and composites it into a corner of an
existing PNG in place, so file-based tables stay visually consistent with
logo-branded plots.
Dependency-free by design — uses only png + grid + grDevices (all already
imported), no magick. Configurable type/variant/position/width/margin;
preserves the image's pixel dimensions. Adds tests (21 assertions).
- Add test verifying .send_webhook() and .send_desktop_notify() use
system2() (not system()) to prevent command injection. This test
reads the function body and asserts system2 is present and
system("...") is absent, so the vulnerability cannot be
reintroduced by accident.
- Add test for beep(type='all') exercising both beep and notify paths.
Use system2() with separate args instead of shell-interpolated system()
calls in .send_desktop_notify() and .send_webhook(). This eliminates
command injection risk when msg, status, url, or payload contain shell
metacharacters.
- #5: Unwrap _brand.yml for Quarto 1.9+ compatibility (remove top-level
brand: wrapper so meta/logo/color/typography are at the top level)
- #1: Add quiet parameter to na_sum() to suppress warnings in loops/pipelines
- #3: Add beep() function for CLI beep, desktop notifications, and webhook
alerts (supports type=beep|notify|webhook|all)
Integrate Civilytics Reveal.js slide extension, HTML/PDF/Typst document
themes, and _brand.yml into the package under inst/quarto/. Three new
helper functions (use_civilytics_revealjs, use_civilytics_theme,
use_civilytics_brand) copy assets into a user's Quarto project. Logos
are stored once in inst/img/ and distributed at install time.
The previous fix applied the plot's background to the logo grob
directly, which made it opaque and covered caption/axis text that
overlaps into the logo area via negative margins.
Instead, wrap the entire arrangeGrob composition in a grobTree with
a background rectGrob behind it. This fills transparent areas (logo
strip, padding gaps) with the plot's background color while keeping
the logo grob itself transparent so overlapping text remains visible.
The logo grob uses theme_void() (transparent background), so when
arrangeGrob() composites it with a dark-themed plot, the logo strip
falls back to the device default (white). Extract the plot's
plot.background fill and apply it to the logo grob before compositing.
Fixes the issue where theme_civilytics_dark(font_size = 16) piped to
civilytics_logo(variant = "dark") would show a light background in
the logo/caption area.
Add theme_civilytics_map(), theme_civilytics_dark_map(), and
theme_civilytics_slide_map() for choropleths — suppress axes, ticks,
gridlines, and axis labels while preserving titles, captions, and legends.
Fix subtitle, caption, and axis text colors in theme_civilytics_dark()
which were inheriting dark ink_2/ink_3 values meant for light backgrounds,
making them hard to read on navy. Now uses navy_200/navy_300 instead.
Supports "bottom-right" (default), "bottom-left", "top-right", and
"top-left". The position controls both horizontal alignment of the logo
grob and whether it is placed above or below the plot.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The old fig.retina=2 at 150 DPI rendered PNGs at 2x resolution that
GitHub markdown can't use, making text appear half its intended size.
Switching to 96 DPI without retina produces images at their natural
display size. Combined with the base font bump (14 → 16pt), titles
and labels now render with proper editorial presence.
- Change rel_large default from 16/14 to 20/14 (~1.43x) to match the
Civilytics editorial design system. Subtitle now renders at 1.0x base
instead of 0.86x.
- Switch axis.text to rel() sizing so all text elements cascade from the
root font_size, enabling uniform scaling.
- Add font_scale parameter (default 1.1) to civilytics_logo(),
add_logo(), and add_logo_ga() — inflates text by ~10% before
arrangeGrob composition to compensate for viewport shrinkage.
- Ship SVG logo variants (mark, wordmark, pulse) in inst/img/ for
Quarto/HTML templates.
- Add "Maintaining brand assets" section to README documenting inst/img/
file inventory and update workflow.
- Document full font size hierarchy in theme_civilytics() roxygen.
Replace the 16-color / 3-palette system with the full Civilytics design
system: 53 named colors (full navy, ember, violet ramps plus teal, plum,
moss, brass supporting hues) and 10 visualization palettes (qual,
qual_warm, qual_cool, seq_ember, seq_navy, seq_violet, seq_paper_ink,
div_navy_ember, div_violet_ember).
Enrich theme_civilytics() with grid and paper_bg parameters, add
theme_civilytics_slide() for presentations, and load all four brand fonts
(Inter, Libre Franklin, Source Serif 4, JetBrains Mono).
Add README.Rmd with rendered gallery showing all palettes, theme
variants, grid options, dark/slide modes, facets, and scale usage.
R's |> has higher precedence than +, so parentheses ARE required
around the ggplot chain before piping to civilytics_logo():
(ggplot(df, aes(x, y)) + geom_point() + theme_civilytics()) |>
civilytics_logo()
Updated docs, examples, and pipe test accordingly.
- Replace old civilytics_logo.png/white.png/jpg/pdf with new rebrand
assets: civilytics-wordmark.png, civilytics-wordmark-reverse.png,
civilytics-mark.png, civilytics-mark-reverse.png (all transparent bg)
- make_logo_grob() now accepts type = c("wordmark", "mark") alongside
variant = c("light", "dark") for 4 combinations
- New civilytics_logo() pipe-friendly convenience function:
ggplot(df, aes(x, y)) + geom_point() + theme_civilytics() |>
civilytics_logo()
R's |> has lower precedence than +, so the full ggplot chain pipes
through without parentheses
- Remove old icon/favicon assets no longer used
- Wrap showtext-dependent examples in \dontrun{} to prevent R CMD check
failures in headless PostScript environments
- R/colors.R: civilytics_colors named vector (from --cv-* CSS vars on
civilytics.com), three palettes (main/sequential/diverging),
scale_color_civilytics() and scale_fill_civilytics() for ggplot2
- R/fonts.R: auto-loads Inter + Libre Franklin from Google Fonts via
showtext in .onLoad(); exports civilytics_load_fonts() for manual retry
- R/theme.R: wires ggplot2 4.0 ink/paper/accent params into theme_grey()
base, adds title_family + strip_color params; new theme_civilytics_dark()
using navy_dark background and warm off-white text
- R/logo.R: make_logo_grob(variant) accepts "light"/"dark" to select the
white logo for dark-background compositions
- DESCRIPTION: adds showtext, sysfonts; pins ggplot2 >= 4.0.0
- tests/testthat/test_theme.R: full test suite for colors, palettes,
scales, both theme variants, and logo grob variants
theme.R:
- Remove deprecated legend.text.align and legend.title.align (ggplot2 3.5.0)
- Remove stale @importFrom graphics plot (unused in theme function)
logo.R:
- Fix make_logo_grob() spurious two-row data frame (drop aes/data from canvas)
- Fix add_logo_ga() caption measurement always using first plot; now uses max
across all plots with captions
- Fix add_logo_ga() ncol hardcoded to 2; now uses length(plot_list)
- Fix add_logo_ga() widths silently ignored in nrow > 1 path; now warns
- Replace deprecated qplot() in examples with ggplot() equivalents
- Fix native = T -> TRUE in plot_jpeg()
@importFrom does not work for base R lazy data objects — replaced with
utils::globalVariables() in the package file to suppress the R CMD check
NOTE. Removed the invalid @importFrom datasets tag from utils.R.
Also commits all man/ and NAMESPACE changes from devtools::document().
- Wrap get_fips/get_stabbr examples in dontrun (tidycensus is Suggests)
- Add .gitea to .Rbuildignore (hidden dir note)
- Add importFrom(datasets, state.abb/state.name) for postcode_lookup
- Remove LazyData: true (no data/ directory)
Replace actions/checkout@v4 (JS action, requires Node.js) with plain git
commands using the auto-injected gitea.token for auth. This lets the workflow
run entirely inside rocker/r-ver:4.4 without any Node.js dependency.
Remove container directive — rocker/r-ver has no Node.js so actions/checkout
(a JS action) fails with exit 127. Install R 4.x from the official CRAN
Ubuntu PPA on the host runner instead.
- Add real R CMD check workflow via Gitea Actions (rocker/r-ver:4.4)
- Remove Jenkinsfile and demo workflow
- Modernize DESCRIPTION: Authors@R, R >= 4.1.0, URL/BugReports fields,
move tidycensus from Imports to Suggests, testthat edition 3
- Fix agresti_coull_interval: correct implementation, export it
- Convert get_fips/get_stabbr to use requireNamespace for tidycensus
- Remove civilytics:: self-reference in rnh()