diff --git a/.Rbuildignore b/.Rbuildignore index 6d8038a..bcc1d64 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,4 @@ ^cran-comments\.md$ ^CRAN-SUBMISSION$ ^revdep$ +^vignettes/articles$ diff --git a/DESCRIPTION b/DESCRIPTION index 6ee0391..8e3e480 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/NEWS.md b/NEWS.md index b8cf399..135e4af 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ - Added a variety of global options to adjust the printing behaviour of colour vectors. See `help("palettes-options")` and `vignette("palettes")` for details and examples. +- Added a "Made with palettes" article to the pkgdown site showcasing colour palette packages made with palettes. + - Improved error message for invalid colours to support singular and plural grammar (@olivroy, #32) # palettes 0.1.1 diff --git a/R/sysdata.rda b/R/sysdata.rda index 8d96b8a..c5373a6 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/README.md b/data-raw/README.md new file mode 100644 index 0000000..12e1b56 --- /dev/null +++ b/data-raw/README.md @@ -0,0 +1,20 @@ +## Package Listings + +If you have a colour palette package that you would like included in the listing of [packages made with palettes](https://mccarthy-m-g.github.io/palettes/articles/made-with-palettes.html), please send me a pull request that includes an addition to the `made-with-palettes.R` file in this directory. + +### Requirements + +Colour palette packages submitted for listing should meet the following requirements: + +1. Hosted from a GitHub repository. +2. Made using the palettes package. + +### Instructions + +In your pull request, add the package info to the the `made_with_palettes <- tibble::tribble(...)` on line 8. The columns in the tribble are as follows: + +- `package`: R package name. +- `gh_owner`: The account owner of the repository. +- `gh_repo`: The name of the repository. + +Please add new entries in alphabetical order, according to the package name. diff --git a/data-raw/colour-names.R b/data-raw/colour-names.R index 6e5bb26..0fab1c7 100644 --- a/data-raw/colour-names.R +++ b/data-raw/colour-names.R @@ -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") diff --git a/data-raw/made-with-palettes.R b/data-raw/made-with-palettes.R new file mode 100644 index 0000000..67b22fe --- /dev/null +++ b/data-raw/made-with-palettes.R @@ -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") diff --git a/data-raw/sysdata.R b/data-raw/sysdata.R new file mode 100644 index 0000000..2caa251 --- /dev/null +++ b/data-raw/sysdata.R @@ -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 +) diff --git a/data-raw/sysdata/colour_names.rds b/data-raw/sysdata/colour_names.rds new file mode 100644 index 0000000..284a389 Binary files /dev/null and b/data-raw/sysdata/colour_names.rds differ diff --git a/data-raw/sysdata/made-with-palettes.rds b/data-raw/sysdata/made-with-palettes.rds new file mode 100644 index 0000000..a9a75b9 Binary files /dev/null and b/data-raw/sysdata/made-with-palettes.rds differ diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 4d5a863..ccad2d7 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -60,3 +60,8 @@ articles: navbar: Developer contents: - creating-packages + +- title: Community + navbar: Community + contents: + - articles/made-with-palettes diff --git a/vignettes/articles/made-with-palettes.Rmd b/vignettes/articles/made-with-palettes.Rmd new file mode 100644 index 0000000..31b7c40 --- /dev/null +++ b/vignettes/articles/made-with-palettes.Rmd @@ -0,0 +1,137 @@ +--- +title: "Packages made with palettes" +--- + +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](https://github.com/mccarthy-m-g/palettes/tree/main/data-raw) 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, message=FALSE, warning=FALSE} +library(palettes) +library(dplyr) +library(gt) +library(fontawesome) + +palettes:::made_with_palettes |> + rename(description = title) |> + gt(id = "one") |> + cols_label( + package = md("**Package**"), + description = md("**Description**"), + authors = md("**Author**") + ) |> + fmt_url( + columns = gh_url, + label = html(fontawesome::fa("github")), + color = "#0d6efd", + show_underline = FALSE + ) |> + fmt_url( + columns = cran_url, + label = html(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 [id='Package'] { + width: 25%; + } + + #one [id='Description'] { + width: 50%; + } + + #one [id='Author'] { + width: 25%; + } + + #one svg { + height: 1.25rem !important; + width: 1.25rem !important; + box-sizing: content-box; + } + + @media screen and (max-width: 768px) { + + table th, + table td { + padding: .625em; + } + + #one table thead { + border: none; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + } + + #one table tr { + border-top-width: 2px; + border-top-style: solid !important; + border-bottom-width: 2px; + border-bottom-style: solid !important; + display: block; + margin-bottom: .625em; + padding: .35em; + } + + #one table td, + #one table svg { + display: inline-block; + width: calc(100% - 7rem - .625rem); + padding-left: 7rem !important; + text-indent: -7rem; + vertical-align: middle !important; + box-sizing: content-box; + } + + #one table td::before { + content: attr(headers); + float: left; + width: 7rem; + font-weight: bold; + text-transform: capitalize; + } + + #one table td:last-child { + border-bottom-width: 0px !important; + } + + #one .gt_table, + #one .gt_col_headings, + #one .gt_table_body { + border-top-style: none !important; + border-bottom-style: none !important; + } + + #one .gt_row { + border-top-style: none !important; + border-bottom-width: 1px; + border-bottom-style: solid; + border-bottom-color: #D3D3D3; + margin: 0px !important; + } + + } + " + ) +```