feat: add position argument to civilytics_logo() for corner placement
R-CMD-check / R CMD check (push) Successful in 3m37s

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>
This commit is contained in:
2026-05-19 15:44:18 -06:00
co-authored by Claude Opus 4.6
parent 95b8ba1da4
commit 328d9d2fd6
5 changed files with 152 additions and 41 deletions
+33
View File
@@ -298,3 +298,36 @@ test_that("civilytics_logo accepts type and variant params", {
result <- suppressWarnings(civilytics_logo(p, type = "mark", variant = "dark"))
expect_s3_class(result, "grob")
})
# --- position argument -------------------------------------------------------
test_that("civilytics_logo accepts all four position values", {
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
for (pos in c("bottom-right", "bottom-left", "top-right", "top-left")) {
result <- suppressWarnings(civilytics_logo(p, position = pos))
expect_s3_class(result, "grob")
}
})
test_that("civilytics_logo errors on invalid position", {
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
expect_error(civilytics_logo(p, position = "center"))
})
test_that("make_logo_grob accepts position argument", {
for (pos in c("bottom-right", "bottom-left", "top-right", "top-left")) {
logo <- make_logo_grob(position = pos)
expect_s3_class(logo, "gg")
}
})
test_that("top positions place logo before plot in arrangeGrob", {
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
result_top <- suppressWarnings(civilytics_logo(p, position = "top-right"))
result_bot <- suppressWarnings(civilytics_logo(p, position = "bottom-right"))
# Top: logo is first grob; bottom: plot is first grob.
# The arrangeGrob heights differ in order
expect_s3_class(result_top, "grob")
expect_s3_class(result_bot, "grob")
})