Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for Health Icons #74

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Authors@R: c(
person("Mitchell", "O'Hara-Wild", email = "[email protected]", role = c("aut", "cre")),
person("Earo", "Wang", role = "ctb"),
person("Timothy", "Hyndman", role = "ctb"),
person("Matthew T. Warkentin", role = "ctb")
person("Matthew T. Warkentin", role = "ctb"),
person("Tom", "Jemmett", email = "[email protected]", role = "ctb", comment = c(ORCID="0000-0002-6943-2990")),
)
Description: Easily embed SVG icons into R Markdown documents or shiny apps. A collection of popular icon sets are supported by the package, including Font Awesome, Academicons and Ionicons.
Depends:
Expand Down Expand Up @@ -34,5 +35,5 @@ VignetteBuilder: knitr
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE, roclets=c('rd', 'collate', 'namespace'))
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export(download_bioicons)
export(download_feather_icons)
export(download_fontawesome)
export(download_google_material)
export(download_health_icons)
export(download_ionicons)
export(download_octicons)
export(download_simple_icons)
export(fa)
export(feather_icons)
export(fontawesome)
export(google_material)
export(health_icons)
export(icon_find)
export(icon_installed)
export(icon_save)
Expand Down
45 changes: 45 additions & 0 deletions R/health_icons.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

#' @rdname health_icons
#' @export
download_health_icons <- function(){
url <- "https://healthicons.org/icons.zip"

meta <- jsonlite::read_json(
"https://raw.githubusercontent.com/resolvetosavelives/healthicons/main/package.json"
)

install_icon_zip(
"health_icons", url, function(dl_dir) file.path(dl_dir, "icons", "svg"),
tomjemmett marked this conversation as resolved.
Show resolved Hide resolved
meta = list(
name = "Health Icons",
version = meta$version,
licence = c("CC-0", "MIT")
)
)

invisible(health_icons)
}

#' Health icons
#'
#' @param name Name of the icon
#' @param category The icon's category, either "blood", "body", "conditions",
#' "devices", "diagnostics", "emotions", "family", "medications", "objects",
#' "people", "places", "shapes", "specialties", "symbols", "typography", or
#' "vehicles"
#' @param theme The style variant for the icon, requires v4.0.0 or greater.
tomjemmett marked this conversation as resolved.
Show resolved Hide resolved
#' Available themes vary by icon, but can be either "filled", "negative",
#' "outline". If NULL, it will default to the
#' first available variant in this order.
#' @rdname health_icons
#' @export
health_icons <- new_icon_set(
"health_icons",
function(name, category = NULL, theme = NULL){
if(is.null(category)){
icon_guess(name, "health_icons", pattern = theme)
} else {
icon_fn$get(c(theme, category, name))
}
}
)
27 changes: 27 additions & 0 deletions man/health_icons.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/icons-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.