feat: resolve #7 theme_civilytics(): default to a transparent background, opt-in for Civilytics cream
R-CMD-check / R CMD check (pull_request) Failing after 3m52s

This commit is contained in:
2026-06-20 03:02:46 +00:00
parent 41162597cf
commit bbee17ef16
2 changed files with 19 additions and 10 deletions
+11 -9
View File
@@ -29,17 +29,19 @@
#' @param ink Character. Hex code for foreground/text color. Defaults to
#' [civilytics_colors]`["ink"]` (`#0E1A2B`).
#' @param paper Character. Hex code for background color. Defaults to
#' [civilytics_colors]`["paper"]` (`#FAF7F2`).
#' [civilytics_colors]`["paper"]` (`#FAF7F2`). Only used when
#' `paper_bg = TRUE`.
#' @param accent Character. Hex code for accent/highlight color. Defaults to
#' [civilytics_colors]`["ember_600"]` (`#C25311`).
#' @param strip_color Character. Hex code for facet strip background. Defaults
#' to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).
#' @param grid Character. Which major gridlines to draw: `"y"` (default,
#' horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.
#' @param paper_bg Logical. If `TRUE` (default), fill the plot and panel
#' backgrounds with the warm `paper` color. Set to `FALSE` for a
#' transparent background (useful for slides or overlay on colored
#' surfaces).
#' @param paper_bg Logical. If `TRUE`, fill the plot and panel
#' backgrounds with the warm `paper` color. Default `FALSE` for a
#' transparent background (recommended for embedding figures on
#' colored surfaces, slides, or report pages). Set to `TRUE` to
#' enable the branded cream canvas.
#'
#' @section Font size hierarchy:
#' All text sizes are derived from `font_size` using relative scale factors.
@@ -68,7 +70,7 @@
#' \dontrun{
#' library(ggplot2)
#'
#' # Default editorial theme
#' # Default transparent background
#' ggplot(mpg, aes(displ, hwy)) +
#' geom_point() +
#' theme_civilytics()
@@ -79,10 +81,10 @@
#' scale_color_civilytics() +
#' theme_civilytics(grid = "both")
#'
#' # Transparent background for embedding
#' # Branded cream canvas (opt-in)
#' ggplot(mpg, aes(displ, hwy)) +
#' geom_point() +
#' theme_civilytics(paper_bg = FALSE)
#' theme_civilytics(paper_bg = TRUE)
#'
#' # Larger text for poster or display
#' ggplot(mpg, aes(displ, hwy)) +
@@ -102,7 +104,7 @@ theme_civilytics <- function(
accent = unname(civilytics_colors["ember_600"]),
strip_color = unname(civilytics_colors["paper_2"]),
grid = c("y", "x", "both", "none"),
paper_bg = TRUE) {
paper_bg = FALSE) {
grid <- match.arg(grid)
half_line <- font_size / 2