feat: add brand color system, showtext fonts, and dark theme
R-CMD-check / R CMD check (push) Failing after 1m39s

- 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
This commit is contained in:
2026-05-17 10:36:59 -06:00
parent 2d70d9aecf
commit c93c469267
17 changed files with 996 additions and 206 deletions
+53 -11
View File
@@ -2,33 +2,75 @@
% Please edit documentation in R/theme.R
\name{theme_civilytics}
\alias{theme_civilytics}
\title{Make the Civilytics plot theme}
\title{Civilytics ggplot2 theme}
\usage{
theme_civilytics(
font_size = 14,
font_family = "",
font_family = CV_FONT_SANS,
title_family = CV_FONT_DISPLAY,
line_size = 0.5,
rel_small = 12/14,
rel_tiny = 11/14,
rel_large = 16/14
rel_large = 16/14,
ink = unname(civilytics_colors["ink"]),
paper = unname(civilytics_colors["paper"]),
accent = unname(civilytics_colors["accent"]),
strip_color = unname(civilytics_colors["paper_2"])
)
}
\arguments{
\item{font_size}{default 14, a number representing the base font for the theme}
\item{font_size}{Numeric. Base font size in points. Default `14`.}
\item{font_family}{default "", a character for the font family to use in the theme}
\item{font_family}{Character. Font family for body/axis text. Default
`"Inter"` (loaded via showtext).}
\item{line_size}{default 0.5, the line size to use for the theme}
\item{title_family}{Character. Font family for plot titles and strip labels.
Default `"Libre Franklin"` (loaded via showtext).}
\item{rel_small}{default 12/14, the scale factor to create a small font from the base font_size}
\item{line_size}{Numeric. Base line width. Default `0.5`.}
\item{rel_tiny}{default 11/14, the scale factor to create a tiny font from the base font_size}
\item{rel_small}{Numeric. Scale factor for small text relative to
`font_size`. Default `12/14`.}
\item{rel_large}{default 16/14, the scale factor to create a large font from the base font_size}
\item{rel_tiny}{Numeric. Scale factor for tiny text relative to `font_size`.
Default `11/14`.}
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
`font_size`. Default `16/14`.}
\item{ink}{Character. Hex code for foreground/text color. Defaults to
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
\item{paper}{Character. Hex code for background color. Defaults to
[civilytics_colors]`["paper"]` (`#FAF7F2`).}
\item{accent}{Character. Hex code for accent/highlight color. Defaults to
[civilytics_colors]`["accent"]` (`#C25311`).}
\item{strip_color}{Character. Hex code for facet strip background. Defaults
to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
}
\value{
a ggplot2 theme object suitable for combining with ggplot objects to theme them
A complete ggplot2 [ggplot2::theme()] object.
}
\description{
Make the Civilytics plot theme
A complete ggplot2 theme built on [ggplot2::theme_grey()] using the
Civilytics brand color palette and typography. Requires ggplot2 >= 4.0.0
for the `ink`, `paper`, and `accent` base-theme parameters.
}
\details{
Brand fonts (Inter for UI text, Libre Franklin for titles) are loaded
automatically via [showtext] when the package is attached. Call
[civilytics_load_fonts()] to reload them if needed.
}
\examples{
library(ggplot2)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
scale_color_civilytics() +
theme_civilytics()
}