diff --git a/R/theme.R b/R/theme.R index 503e5ac..5d49f3c 100644 --- a/R/theme.R +++ b/R/theme.R @@ -36,10 +36,9 @@ #' 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 `FALSE` (default), the plot and panel +#' backgrounds are transparent (`fill = NA`). Set to `TRUE` to fill them +#' with the warm `paper` color (the Civilytics cream canvas). #' #' @section Font size hierarchy: #' All text sizes are derived from `font_size` using relative scale factors. @@ -68,22 +67,22 @@ #' \dontrun{ #' library(ggplot2) #' -#' # Default editorial theme +#' # Transparent background (default) — composites cleanly onto any surface #' ggplot(mpg, aes(displ, hwy)) + #' geom_point() + #' theme_civilytics() #' +#' # Warm paper canvas (opt-in) +#' ggplot(mpg, aes(displ, hwy)) + +#' geom_point() + +#' theme_civilytics(paper_bg = TRUE) +#' #' # With both gridlines and brand colors #' ggplot(mpg, aes(displ, hwy, colour = class)) + #' geom_point() + #' scale_color_civilytics() + #' theme_civilytics(grid = "both") #' -#' # Transparent background for embedding -#' ggplot(mpg, aes(displ, hwy)) + -#' geom_point() + -#' theme_civilytics(paper_bg = FALSE) -#' #' # Larger text for poster or display #' ggplot(mpg, aes(displ, hwy)) + #' geom_point() + @@ -102,7 +101,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 diff --git a/tests/testthat/test_theme.R b/tests/testthat/test_theme.R index 720f8a7..1cd65cf 100644 --- a/tests/testthat/test_theme.R +++ b/tests/testthat/test_theme.R @@ -133,9 +133,16 @@ test_that("theme_civilytics uses brand ink color for text", { expect_equal(th$text$colour, unname(civilytics_colors["ink"])) }) -test_that("theme_civilytics uses brand paper color for plot background", { +test_that("theme_civilytics has transparent background by default", { th <- theme_civilytics() + expect_true(is.na(th$plot.background$fill)) + expect_true(is.na(th$panel.background$fill)) +}) + +test_that("theme_civilytics paper_bg=TRUE opt-in fills with cream", { + th <- theme_civilytics(paper_bg = TRUE) expect_equal(th$plot.background$fill, unname(civilytics_colors["paper"])) + expect_equal(th$panel.background$fill, unname(civilytics_colors["paper"])) }) test_that("theme_civilytics uses paper_2 for strip background by default", {