Skip to content

Commit

Permalink
Merge pull request #37 from mccarthy-m-g/made-with-palettes
Browse files Browse the repository at this point in the history
Add new article showcasing colour palette packages made with palettes
  • Loading branch information
mccarthy-m-g authored Feb 4, 2024
2 parents b7a8dd0 + 8093a2b commit a2670fc
Show file tree
Hide file tree
Showing 12 changed files with 225 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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
20 changes: 20 additions & 0 deletions data-raw/README.md
Original file line number Diff line number Diff line change
@@ -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.
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
137 changes: 137 additions & 0 deletions vignettes/articles/made-with-palettes.Rmd
Original file line number Diff line number Diff line change
@@ -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='<strong>Package</strong>'] {
width: 25%;
}
#one [id='<strong>Description</strong>'] {
width: 50%;
}
#one [id='<strong>Author</strong>'] {
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;
}
}
"
)
```

0 comments on commit a2670fc

Please sign in to comment.