Skip to content

Commit

Permalink
add new article showcasing colour palette packages made with palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
mccarthy-m-g committed Feb 3, 2024
1 parent b7a8dd0 commit fac7e4c
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 2 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
^cran-comments\.md$
^CRAN-SUBMISSION$
^revdep$
^vignettes/articles$
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Suggests:
VignetteBuilder:
knitr
Config/Needs/website:
asciicast (>= 2.2.1)
asciicast (>= 2.2.1),
fontawesome
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-GB
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion data-raw/colour-names.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
colour_names <- grDevices::colors()

usethis::use_data(colour_names, overwrite = TRUE, internal = TRUE)
saveRDS(colour_names, "data-raw/sysdata/colour_names.rds")
48 changes: 48 additions & 0 deletions data-raw/made-with-palettes.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
library(dplyr)
library(purrr)
library(gh)
library(desc)
library(readr)

# Please add new entries in alphabetical order, according to the package name.
made_with_palettes <- tibble::tribble(
~package, ~gh_owner, ~gh_repo,
"hutchplot", "fhdsl", "hutchplot",
"palettes", "mccarthy-m-g", "palettes",
"warwickplots", "Warwick-Stats-Resources", "warwickplots"
)

cran_pkgs <- tools::CRAN_package_db()$Package

made_with_palettes <- made_with_palettes |>
rowwise() |>
mutate(
# Check whether package is also on CRAN
on_cran = package %in% cran_pkgs,
# Get and read DESCRIPTION from package GitHub repositories
pkg_description = list(gh::gh(
"/repos/:owner/:repo/contents/:path",
owner = gh_owner,
repo = gh_repo,
path = "DESCRIPTION",
.accept = "application/vnd.github.raw+json"
)),
pkg_description = purrr::pluck(pkg_description, 1),
pkg_description = list(desc(text = pkg_description)),
# Get and format fields from DESCRIPTION
title = pkg_description$get("Title"),
authors = format(
pkg_description$get_author("aut"),
include = c("given", "family")
),
# Get URLs
# url = pkg_description$get_field("URL", default = NA),
gh_url = paste0("https://github.com/", gh_owner, "/", gh_repo, ""),
cran_url = ifelse(
on_cran, paste0("https://CRAN.R-project.org/package=", package), NA
)
) |>
select(-c(gh_owner:pkg_description)) |>
arrange(package)

saveRDS(made_with_palettes, "data-raw/sysdata/made-with-palettes.rds")
9 changes: 9 additions & 0 deletions data-raw/sysdata.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
colour_names <- readRDS("data-raw/sysdata/colour_names.rds")
made_with_palettes<- readRDS("data-raw/sysdata/made-with-palettes.rds")

usethis::use_data(
colour_names,
made_with_palettes,
overwrite = TRUE,
internal = TRUE
)
Binary file added data-raw/sysdata/colour_names.rds
Binary file not shown.
Binary file added data-raw/sysdata/made-with-palettes.rds
Binary file not shown.
5 changes: 5 additions & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ articles:
navbar: Developer
contents:
- creating-packages

- title: Community
navbar: Community
contents:
- articles/made-with-palettes
57 changes: 57 additions & 0 deletions vignettes/articles/made-with-palettes.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: "Packages made with palettes"
---

<!-- TODO: Add instructions like: https://github.com/quarto-dev/quarto-web/tree/main/docs/extensions/listings -->

Colour palette packages are a nice way to distribute colour palettes while getting access to all the features of **palettes** for free. Below is a listing of colour palette packages made with palettes (please [let me know]() if you have a package you’d like to see added to the list).

See the vignette on creating a colour palette package to learn how to develop your own colour palette package; `vignette("creating-packages")`.

```{r, echo=FALSE}
library(palettes)
library(gt)
library(fontawesome)
palettes:::made_with_palettes |>
gt(id = "one") |>
cols_label(
package = md("**Package**"),
title = md("**Description**"),
authors = md("**Author**")
) |>
fmt_url(
columns = gh_url,
label = fontawesome::fa("github"),
color = "#0d6efd",
show_underline = FALSE
) |>
fmt_url(
columns = cran_url,
label = fontawesome::fa("r-project"),
color = "#0d6efd",
show_underline = FALSE
) |>
sub_missing() |>
cols_merge(
columns = c(package, gh_url, cran_url),
pattern = "{2} \u2002 {3} \u2002 {1}"
) |>
cols_width(
package ~ pct(25),
title ~ pct(40),
authors ~ pct(35)
) |>
tab_options(
table.width = pct(100),
table.font.size = "100%"
) |>
opt_css(
css = "
#one svg {
height: 1.25rem !important;
width: 1.25rem !important;
}
"
)
```

0 comments on commit fac7e4c

Please sign in to comment.