feat: bump title sizes, add font_scale to logo functions, ship SVGs
R-CMD-check / R CMD check (push) Successful in 3m36s
R-CMD-check / R CMD check (push) Successful in 3m36s
- 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.
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
#' @param rel_tiny Numeric. Scale factor for tiny text relative to `font_size`.
|
||||
#' Default `11/14`.
|
||||
#' @param rel_large Numeric. Scale factor for large text (titles) relative to
|
||||
#' `font_size`. Default `16/14`.
|
||||
#' `font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
|
||||
#' design system.
|
||||
#' @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
|
||||
@@ -40,6 +41,26 @@
|
||||
#' transparent background (useful for slides or overlay on colored
|
||||
#' surfaces).
|
||||
#'
|
||||
#' @section Font size hierarchy:
|
||||
#' All text sizes are derived from `font_size` using relative scale factors.
|
||||
#' At the default `font_size = 14`:
|
||||
#'
|
||||
#' | Element | Scale factor | Default size |
|
||||
#' |:--------|:-------------|:-------------|
|
||||
#' | Plot title | `rel_large` (1.43x) | ~20 pt |
|
||||
#' | Subtitle | 1.0x | 14 pt |
|
||||
#' | Axis text (tick labels) | `rel_small` (0.86x) | ~12 pt |
|
||||
#' | Axis titles | `rel_small` (0.86x) | ~12 pt |
|
||||
#' | Legend text | `rel_small` (0.86x) | ~12 pt |
|
||||
#' | Caption | `rel_tiny` (0.79x) | ~11 pt |
|
||||
#' | Legend title | `rel_tiny` (0.79x) | ~11 pt |
|
||||
#' | Strip text (facets) | `rel_small` (0.86x) | ~12 pt |
|
||||
#'
|
||||
#' To uniformly scale all text, change `font_size`. To adjust only the title
|
||||
#' prominence, change `rel_large`. When using [civilytics_logo()] to add a
|
||||
#' logo below the plot, pass `font_scale` to compensate for viewport
|
||||
#' shrinkage.
|
||||
#'
|
||||
#' @return A complete ggplot2 [ggplot2::theme()] object.
|
||||
#' @export
|
||||
#'
|
||||
@@ -62,6 +83,11 @@
|
||||
#' 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() +
|
||||
#' theme_civilytics(font_size = 18)
|
||||
#' }
|
||||
theme_civilytics <- function(
|
||||
font_size = 14,
|
||||
@@ -70,7 +96,7 @@ theme_civilytics <- function(
|
||||
line_size = 0.5,
|
||||
rel_small = 12 / 14,
|
||||
rel_tiny = 11 / 14,
|
||||
rel_large = 16 / 14,
|
||||
rel_large = 20 / 14,
|
||||
ink = unname(civilytics_colors["ink"]),
|
||||
paper = unname(civilytics_colors["paper"]),
|
||||
accent = unname(civilytics_colors["ember_600"]),
|
||||
@@ -132,7 +158,7 @@ theme_civilytics <- function(
|
||||
axis.line.y = ggplot2::element_blank(),
|
||||
axis.text = ggplot2::element_text(
|
||||
color = ink_2,
|
||||
size = small_size
|
||||
size = ggplot2::rel(rel_small)
|
||||
),
|
||||
axis.text.x = ggplot2::element_text(
|
||||
margin = ggplot2::margin(t = small_size / 4),
|
||||
@@ -249,7 +275,7 @@ theme_civilytics <- function(
|
||||
),
|
||||
plot.title.position = "plot",
|
||||
plot.subtitle = ggplot2::element_text(
|
||||
size = ggplot2::rel(rel_small),
|
||||
size = ggplot2::rel(1),
|
||||
color = ink_2,
|
||||
hjust = 0,
|
||||
vjust = 1,
|
||||
@@ -307,7 +333,7 @@ theme_civilytics_dark <- function(
|
||||
line_size = 0.5,
|
||||
rel_small = 12 / 14,
|
||||
rel_tiny = 11 / 14,
|
||||
rel_large = 16 / 14,
|
||||
rel_large = 20 / 14,
|
||||
ink = unname(civilytics_colors["paper"]),
|
||||
paper = unname(civilytics_colors["navy_700"]),
|
||||
accent = unname(civilytics_colors["ember_400"]),
|
||||
@@ -359,7 +385,7 @@ theme_civilytics_slide <- function(
|
||||
line_size = 0.5,
|
||||
rel_small = 12 / 14,
|
||||
rel_tiny = 11 / 14,
|
||||
rel_large = 16 / 14,
|
||||
rel_large = 20 / 14,
|
||||
ink = unname(civilytics_colors["ink"]),
|
||||
paper = unname(civilytics_colors["paper"]),
|
||||
accent = unname(civilytics_colors["ember_600"]),
|
||||
|
||||
Reference in New Issue
Block a user