-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from mccarthy-m-g/made-with-palettes
Add new article showcasing colour palette packages made with palettes
- Loading branch information
Showing
12 changed files
with
225 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
^cran-comments\.md$ | ||
^CRAN-SUBMISSION$ | ||
^revdep$ | ||
^vignettes/articles$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
" | ||
) | ||
``` |