From 61a60bbf19921b000fefbd8df2af537d92d0c715 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Mon, 25 Jan 2021 16:41:46 +0100 Subject: [PATCH 01/18] added missing news items --- NEWS.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS.md b/NEWS.md index 891c8b4..7b6b5cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,15 @@ +# rheroicons 0.2.4 + +* Upgraded to latest version of heroicons ([v0.4.2](https://github.com/tailwindlabs/heroicons/releases/tag/v0.4.2)) + +# rheroicons 0.2.3 + +This is a minor package update. The main issue was the handling of error messages via the cli package. These changes are listed below. + +* Updated error message for rheroicon function. It now uses {.val {value}} +* Removed error message for find_icons as the default query is "". +* Reinit pkgbump configuration file + # rheroicons 0.2.21 * Switched to webpack as the bundler of choice :tada: From 0e15cbb7146422beda443611f00dc4b7407fc1a1 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Mon, 25 Jan 2021 17:08:54 +0100 Subject: [PATCH 02/18] added heroicons license info (#20) --- LICENSE | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index fffdf12..f002403 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,8 @@ +The rheroicons package as a whole is distributed under MIT License. + MIT License -Copyright (c) 2020 dcruvolo +Copyright (c) 2021 dcruvolo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,3 +21,35 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +The rheroicons package includes other open source software components. The following +is a list of these components (full copies of the license agreements used by +these components are included below): + +- heroicons, https://github.com/tailwindlabs/heroicons + +Heriocons License +-------------------------------- + +MIT License + +Copyright (c) 2020 Refactoring UI Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From 1ee7ae3e43c54d1b7a199363f084741a4862a114 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Mon, 25 Jan 2021 17:15:09 +0100 Subject: [PATCH 03/18] updated title, authors, and description (#20) --- DESCRIPTION | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 34912a5..ed072b1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,25 @@ Package: rheroicons -Title: The Heroicons library for use in R-based web projects +Title: A zero dependency svg icon library for use in R web-based projects Version: 0.2.4 -Authors@R: - person(given = "David", - family = "Ruvolo", - role = c("aut", "cre"), - email = "dcruvolo@gmail.com", - comment = c(ORCID = "0000-0002-5745-5298")) -Description: The rheroicons provides access to the fantastic SVG icon collection heroicons, developed by @adamwathan and @sschoger, as R functions for use in your R-based web projects (i.e., shiny, Rmarkdown, etc.). This package requires no HTML, CSS, or JavaScript dependencies as all icons are rendered inline as SVG elements. +Authors@R: c( + person( + given = "David", + family = "Ruvolo", + role = c("aut", "cre"), + email = "dcruvolo@gmail.com", + comment = c(ORCID = "0000-0002-5745-5298")), + person( + "Refactoring UI Inc", + role = c("ctb", "cph"), + comment = "Author of heroicons library" + ) +) +Description: The rheroicons provides access to the fantastic SVG icon + collection heroicons, originally developed by Adam Wathan and + Steve Schoger at Tailwind Labs, as R functions for use in your + web-based projects (i.e., shiny Rmarkdown, etc.). All icons are + rendered as inline SVG elements. Therefore no HTML, CSS, or + JavaScript dependencies are loaded into your app. License: MIT + file LICENSE Encoding: UTF-8 LazyData: true From 9abb5f6eb9ea4674110d0c1d4beeace6aed8cf3e Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Wed, 27 Jan 2021 21:19:43 +0100 Subject: [PATCH 04/18] init cran comments (#20) --- .Rbuildignore | 20 +++----------------- DESCRIPTION | 3 +-- cran-comments.md | 7 +++++++ 3 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index 719ce81..8accc73 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,30 +1,16 @@ -dev -rheroicons.code-workspace -package.json -README.md -.gitignore -node_modules -inst/rheroicons-gallery -inst/gallery-assets/src -.cache -.postcssrc -.babelrc -^\.travis\.yml$ -^\.github$ -yarn.lock -yarn-error.log -^\.pkgbump\.json$ ^node_modules$ ^inst/rheroicons-gallery/rsconnect$ ^yarn-error\.log$ +^\.github$ ^config$ ^dev$ ^inst/rheroicons-gallery$ ^\.babelrc$ ^\.gitignore$ +^cran-comments\.md$ ^package\.json$ +^pkgbump\.config\.json$ ^postcss\.config\.js$ ^rheroicons\.code-workspace$ ^webpack\.config\.js$ ^yarn\.lock$ -^pkgbump\.config\.json$ diff --git a/DESCRIPTION b/DESCRIPTION index ed072b1..d3c381f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,9 +11,8 @@ Authors@R: c( person( "Refactoring UI Inc", role = c("ctb", "cph"), - comment = "Author of heroicons library" + comment = "Author of heroicons library") ) -) Description: The rheroicons provides access to the fantastic SVG icon collection heroicons, originally developed by Adam Wathan and Steve Schoger at Tailwind Labs, as R functions for use in your diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..d33d94b --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,7 @@ +# CRAN Comments + +## Test environments + +## R CMD check results + +## Downstream dependencies From 751cd6663d7ac4c3b6675caf453e8d25e1aa565e Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Wed, 27 Jan 2021 21:21:24 +0100 Subject: [PATCH 05/18] init 'find_icon' test and updated docs (#20) --- R/find_icon.R | 9 ++++----- tests/testthat/test-find-icon.R | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 tests/testthat/test-find-icon.R diff --git a/R/find_icon.R b/R/find_icon.R index 99a6142..7fa13e6 100644 --- a/R/find_icon.R +++ b/R/find_icon.R @@ -1,15 +1,14 @@ -#' Find Icons +#' Find available icons #' -#' Find an icon using a search term -#' -#' @param query a search term passed down to \code{stringr::str_subset} +#' @param query a search term passed down to \code{stringr::str_subset}. +#' Alternatively, leave blank to view all icon names. #' #' @examples #' find_icons(query = "chevron") #' find_icons(query = "chevron|arrow") #' find_icons(query = "down|up|left|right") #' -#' @return Find an icon using a search term +#' @return An array of icon names #' #' @export find_icons <- function(query = "") { diff --git a/tests/testthat/test-find-icon.R b/tests/testthat/test-find-icon.R new file mode 100644 index 0000000..6bd0df7 --- /dev/null +++ b/tests/testthat/test-find-icon.R @@ -0,0 +1,35 @@ +#' //////////////////////////////////////////////////////////////////////////// +#' FILE: test-find-icon.R +#' AUTHOR: David Ruvolo +#' CREATED: 2021-01-27 +#' MODIFIED: 2021-01-27 +#' PURPOSE: `find_icon` tests +#' STATUS: working +#' PACKAGES: testthat +#' COMMENTS: NA +#' //////////////////////////////////////////////////////////////////////////// + + +#' ~ 1 ~ +#' Function returns entire list of icons if no query is provided +test_that("entire icon list prints correctly", { + expect_equal( + object = length(find_icons()), + expected = length(rheroicons), + label = "Returned array does not match the length of the icon set" + ) +}) + +#' ~ 2 ~ +#' Query returns expected icons +test_that("query returns expected icons", { + expect_equal( + object = find_icons(query = "chevron_double"), + expected = c( + "chevron_double_down", + "chevron_double_left", + "chevron_double_right", + "chevron_double_up" + ) + ) +}) \ No newline at end of file From c5d661b27424b05c853a45d665bddfe14a701b30 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Wed, 27 Jan 2021 21:23:17 +0100 Subject: [PATCH 06/18] updated docs (#20) --- R/launch_gallery.R | 2 +- R/rheroicon.R | 36 +++++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/R/launch_gallery.R b/R/launch_gallery.R index c6edf7d..09dd3e0 100644 --- a/R/launch_gallery.R +++ b/R/launch_gallery.R @@ -3,7 +3,7 @@ #' Run the rheroicons gallery and search for icons. Click on an icon #' name to copy the function to the clipboard. #' -#' @param ... additional options passed down to runApp +#' @param ... additional options passed down to \code{shiny::runApp} #' #' @examples #' \dontrun{ diff --git a/R/rheroicon.R b/R/rheroicon.R index 06ba9b0..b33e230 100644 --- a/R/rheroicon.R +++ b/R/rheroicon.R @@ -1,25 +1,32 @@ -#' rheroicon +#' An inline SVG icon from heriocons #' #' Render an rheroicon icon by name. Use `launch_gallery` to view the icons -#' available in this package or visit the gallery on shinyapps.io (see link -#' below). All icons are rendered with three CSS classes: global ("rheroicons"), -#' icon style ("rheroicons_outline" or "rheroicons_solid"), and icon name ( -#' "rheroicons_academic_cap"). Use any of these classes to customize the style -#' of the icon or define your own classes using the argument `class`. +#' available in this package or visit the heroicons icon gallery +#' (see referenced urls). #' -#' @param name an icon name -#' @param type choose icon style "solid" or "outline" (default: "outline") -#' @param classnames a string containing one or more CSS classes +#' @param name a heroicon icon name +#' @param type render a "solid" or "outline" icon (default: "outline") +#' @param classnames a string containing one or more CSS classes (optional) +#' +#' @section Styling Icons with classnames: +#' +#' Icons are rendered from svg strings. All icons have three css classes +#' defined: global ("rheroicons"), icon style ("rheroicons_outline" or +#' "rheroicons_solid"), and icon name ("rheroicons_academic_cap"). +#' Use any of combination of these classes to style icons via css. +#' Alternatively, you can pass your own classes using the \code{classnames} +#' argument. #' #' @examples #' rheroicon(name = "academic_cap") #' rheroicon(name = "academic_cap", type = "solid") #' rheroicon(name = "academic_cap", classnames = "education-icons") #' +#' @return Returns an svg string of an Heroicon icon #' #' @references #' \url{https://github.com/tailwindlabs/heroicons} -#' \url{https://davidruvolo.shinyapps.io/rheroicons-demo/} +#' \url{https://heroicons.com} #' #' @export rheroicon <- function(name, type = "outline", classnames = NULL) { @@ -32,12 +39,15 @@ rheroicon <- function(name, type = "outline", classnames = NULL) { } # throw error if input value for "type" is invalid - if (!type %in% c("outline", "solid")) { - cli::cli_alert_danger("Icon type {.val {type}} is invalid. Use {.val outline} or {.val solid}") + valid_types <- c("outline", "solid") + if (!type %in% valid_types) { + cli::cli_alert_danger( + "Type {.val {type}} is invalid. Use {.val {.valid_types}}" + ) } # process only if icon exists - if (length(icon) && type %in% c("outline", "solid")) { + if (length(icon) && (type %in% valid_types)) { svg <- icon$icons[[type]] # append class attribute if applicable From 2a1fa44eb7017f08d6fbbb2e28654519febda67f Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Wed, 27 Jan 2021 21:26:16 +0100 Subject: [PATCH 07/18] rebuilt docs and bumped version (#20) --- DESCRIPTION | 2 +- dev/dev.R | 11 ++++++++--- man/find_icons.Rd | 9 +++++---- man/launch_gallery.Rd | 2 +- man/rheroicon.Rd | 32 +++++++++++++++++++++----------- package.json | 2 +- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d3c381f..1a52e95 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rheroicons Title: A zero dependency svg icon library for use in R web-based projects -Version: 0.2.4 +Version: 0.3.0 Authors@R: c( person( given = "David", diff --git a/dev/dev.R b/dev/dev.R index f39afa9..ade37cb 100644 --- a/dev/dev.R +++ b/dev/dev.R @@ -2,7 +2,7 @@ #' FILE: dev.R #' AUTHOR: David Ruvolo #' CREATED: 2020-08-07 -#' MODIFIED: 2020-10-10 +#' MODIFIED: 2021-01-27 #' PURPOSE: package management #' STATUS: ongoing #' PACKAGES: usethis; pkgbump @@ -23,12 +23,17 @@ usethis::use_package(package = "shiny") usethis::use_package(package = "stringr") usethis::use_package(package = "cli") +#'////////////////////////////////////// + +#' ~ 1 ~ # convert icons source("dev/convert.R") # use dataset usethis::use_data(rheroicons, internal = TRUE, overwrite = TRUE) +#'////////////////////////////////////// + # checks devtools::check_man() devtools::load_all() @@ -43,7 +48,7 @@ pkgbump::set_pkgbump( ) ) -pkgbump::pkgbump(version = "0.2.4") +pkgbump::pkgbump(version = "0.3.0") # ignore @@ -63,7 +68,7 @@ usethis::use_build_ignore( "inst/rheroicons-gallery", ".babelrc", ".gitignore", - ".travis.yml", + "cran-comments.md", "package.json", "pkgbump.config.json", "postcss.config.js", diff --git a/man/find_icons.Rd b/man/find_icons.Rd index 79118c0..c1cd7a4 100644 --- a/man/find_icons.Rd +++ b/man/find_icons.Rd @@ -2,18 +2,19 @@ % Please edit documentation in R/find_icon.R \name{find_icons} \alias{find_icons} -\title{Find Icons} +\title{Find available icons} \usage{ find_icons(query = "") } \arguments{ -\item{query}{a search term passed down to \code{stringr::str_subset}} +\item{query}{a search term passed down to \code{stringr::str_subset}. +Alternatively, leave blank to view all icon names.} } \value{ -Find an icon using a search term +An array of icon names } \description{ -Find an icon using a search term +Find available icons } \examples{ find_icons(query = "chevron") diff --git a/man/launch_gallery.Rd b/man/launch_gallery.Rd index 882fed0..92d77d7 100644 --- a/man/launch_gallery.Rd +++ b/man/launch_gallery.Rd @@ -7,7 +7,7 @@ launch_gallery(...) } \arguments{ -\item{...}{additional options passed down to runApp} +\item{...}{additional options passed down to \code{shiny::runApp}} } \description{ Run the rheroicons gallery and search for icons. Click on an icon diff --git a/man/rheroicon.Rd b/man/rheroicon.Rd index 3c77e96..e6d23f7 100644 --- a/man/rheroicon.Rd +++ b/man/rheroicon.Rd @@ -2,33 +2,43 @@ % Please edit documentation in R/rheroicon.R \name{rheroicon} \alias{rheroicon} -\title{rheroicon} +\title{An inline SVG icon from heriocons} \usage{ rheroicon(name, type = "outline", classnames = NULL) } \arguments{ -\item{name}{an icon name} +\item{name}{a heroicon icon name} -\item{type}{choose icon style "solid" or "outline" (default: "outline")} +\item{type}{render a "solid" or "outline" icon (default: "outline")} -\item{classnames}{a string containing one or more CSS classes} +\item{classnames}{a string containing one or more CSS classes (optional)} +} +\value{ +Returns an svg string of an Heroicon icon } \description{ Render an rheroicon icon by name. Use \code{launch_gallery} to view the icons -available in this package or visit the gallery on shinyapps.io (see link -below). All icons are rendered with three CSS classes: global ("rheroicons"), -icon style ("rheroicons_outline" or "rheroicons_solid"), and icon name ( -"rheroicons_academic_cap"). Use any of these classes to customize the style -of the icon or define your own classes using the argument \code{class}. +available in this package or visit the heroicons icon gallery +(see referenced urls). +} +\section{Styling Icons with classnames}{ + + +Icons are rendered from svg strings. All icons have three css classes +defined: global ("rheroicons"), icon style ("rheroicons_outline" or +"rheroicons_solid"), and icon name ("rheroicons_academic_cap"). +Use any of combination of these classes to style icons via css. +Alternatively, you can pass your own classes using the \code{classnames} +argument. } + \examples{ rheroicon(name = "academic_cap") rheroicon(name = "academic_cap", type = "solid") rheroicon(name = "academic_cap", classnames = "education-icons") - } \references{ \url{https://github.com/tailwindlabs/heroicons} -\url{https://davidruvolo.shinyapps.io/rheroicons-demo/} +\url{https://heroicons.com} } diff --git a/package.json b/package.json index 0efbb9c..1fa43b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rheroicons", - "version": "0.2.4", + "version": "0.3.0", "author": "dcruvolo", "description": "Heroicons for R", "license": "MIT", From 72af640477d91c6b5b27f59c2539f634bb08e388 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Wed, 27 Jan 2021 21:54:44 +0100 Subject: [PATCH 08/18] updated readme to fit CRAN suggestions (#20) --- README.md | 106 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 9968670..cdfb819 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ # rheroicons -The `rheroicons` provides access to the fantastic SVG icon collection [heroicons](https://github.com/refactoringui/heroicons), developed by [adamwathan](https://github.com/adamwathan) and [sschoger](https://github.com/sschoger), as R functions for use in your R-based web projects (i.e., shiny, Rmarkdown, etc.). This package requires no HTML, CSS, or JavaScript dependencies as all SVG icons are rendered inline. +The `rheroicons` packages brings to the [heroicons](https://github.com/refactoringui/heroicons) icon library, developed by [adamwathan](https://github.com/adamwathan) and [sschoger](https://github.com/sschoger), as R functions for use in your R-based web projects (i.e., shiny, Rmarkdown, etc.). + +All icons are rendered as inline svg icons. Therefore, no css or js dependencies are loaded into your Shiny application, Rmd file, or other web document at runtime! ## Install @@ -15,31 +17,56 @@ Use `devtools` or `remotes` to install the `rheroicons`. devtools::install_github("davidruvolo51/rheroicons") ``` +## Getting Started -## Use +### Finding Icons -There are well over a 200 icons in the collection and each icon has two styles (outline and solid). Icons can be found via the icon gallery. Click an icon name to copy the R code used to generate that icon. +There are over 200 icons in the collection. Each icon has two styles: outline and solid. Icons can be found using the icon gallery. ```r rheroicons::launch_gallery() ``` -Icons are created using the `rheroicon` function. +Click an icon name to copy the R code used to generate the icon. You can paste the R code directly into your Shiny app, Rmd file, or other web-based project. + +Alternatively, you can use the `find_icon` function to search for icons. + +```r +# returns all icon names +rheroicons::find_icon() + +# find icons with `chevron` in the name +rheroicons::find_icons(query = "chevron") + +# find icons with `chevron` OR `arrow` in the name +rheroicons::find_icons(query = "chevron|arrow") + +# find icons with `down`, `up`, `left`, OR `right` in the name +rheroicons::find_icons(query = "down|up|left|right") +``` + +### Rendering Icons + +When you have found the icon that you would like to use, you can render them into your app or web document using the `rheroicon` function. ```r # rheroicons version of `document-add` rheroicons::rheroicon(name = "document_add") ``` -\***NOTE**: You can use the [heroicons](https://heroicons.com) site to find icons. All icons that have a dash (`-`) in the original name were renamed using underscores (`_`). +You can use the [heroicons](https://heroicons.com) site to find icons. All icons that have a dash (`-`) in the original name were renamed using underscores (`_`). -### Arguments +#### Arguments All functions take the following arguments. -- `name`: an icon name -- `type`: select the icon style (either `outline` or `solid`; default `outline`) -- `classnames`: a CSS class to be applied to the SVG icon +| Argument | Description | Options | Default | +|--------------|------------------------|-------------------------------------|-----------| +| `name` | icon name | use `find_icon` or `launch_gallery` | --- | +| `type` | icon style | `outline` or `solid` | `outline` | +| `classnames` | add custom css classes | --- | `NULL` | + +Example use: ```r library(shiny) @@ -47,27 +74,27 @@ tags$button( id = "copy", class = "btn", tags$span("Add to clipboard"), - rheroicons::rheroicon( - name = "clipboard_copy", - type = "solid", - classnames = "btn__icons" - ) + rheroicons::rheroicon(name = "clipboard_copy") ) ``` -\***NOTE**: the default icon type is `outline` - - ### Customizing the appearance of icons -Use the argument `class` to define a custom css classes that can be used to select icons via CSS or JavaScript. +Use the argument `classnames` to add custom css classes to your icons. ```r -# clipboard_copy icon -rheroicons::rheroicon( - name = "clipboard_copy", - type = "outline", - class = "my__ui__icons" +library(shiny) + +# create a button with the `clipboard_copy` icon +tags$button( + id = "copy", + class = "btn", + tags$span("Add to clipboard"), + rheroicons::rheroicon( + name = "clipboard_copy", + type = "outline", + class = "my__ui__icons" + ) ) ``` @@ -75,16 +102,16 @@ However, you may find it easier to use the predefined classes generated by this - global: `rheroicons` - set: `rheroicons_solid` or `rheroicons_outline` -- icon: `rhericons_*`, where `*` is the name of the icon. In `rheroicons`, this is same as the function name. +- icon: `rhericons_*`, where `*` is the name of the icon. (This is same as the icon name.) The following table displays the CSS clases by set for the `arrow_circle_down` icon. -set | rheroicons function | rheroicons css classes -:------ | :------------------ | :--------- -outline | `rheroicon(name ="arrow_circle_down", type = "outline")` | `rheroicons rheroicons_outline rheroicons_arrow_circle_down` -solid | `rheroicon(name ="arrow_circle_down", type = "solid")` | `rheroicons rheroicons_solid rheroicons_arrow_circle_down` +| set | function | css classes | +|---------|----------------------------------------------------------|--------------------------------------------------------------| +| outline | `rheroicon(name ="arrow_circle_down", type = "outline")` | `rheroicons rheroicons_outline rheroicons_arrow_circle_down` | +| solid | `rheroicon(name ="arrow_circle_down", type = "solid")` | `rheroicons rheroicons_solid rheroicons_arrow_circle_down` | -In the Shiny UI, you can select items and style icons through CSS. Create a new `tags$style` element and define your styles (or use an external CSS file). +You can select and style icons through CSS using these classes. Create a new `tags$style` element and define your styles (or use an external CSS file). ```r library(shiny) @@ -129,12 +156,11 @@ ui <- tagList( ### Example -The following code demonstrates how to generate icons in Shiny, render solid and outlined icons, and style icons using CSS. +The following code demonstrates how to generate icons in Shiny, render solid and outlined icons, and style icons using CSS. ```r # pkgs library(shiny) -library(rheroicons) # ui ui <- tagList( @@ -156,18 +182,18 @@ ui <- tagList( tags$main( tags$h2("rheroicons"), tags$div( - rheroicon(name = "arrow_circle_down"), - rheroicon(name = "arrow_circle_up"), - rheroicon(name = "arrow_circle_left"), - rheroicon(name = "arrow_circle_right") + rheroicons::rheroicon(name = "arrow_circle_down"), + rheroicons::rheroicon(name = "arrow_circle_up"), + rheroicons::rheroicon(name = "arrow_circle_left"), + rheroicons::rheroicon(name = "arrow_circle_right") ), tags$div( - rheroicon(name = "chart_bar", type = "solid"), - rheroicon(name = "chart_bar") + rheroicons::rheroicon(name = "chart_bar", type = "solid"), + rheroicons::rheroicon(name = "chart_bar") ), tags$div( - rheroicon(name = "home", type = "solid"), - rheroicon(name = "home") + rheroicons::rheroicon(name = "home", type = "solid"), + rheroicons::rheroicon(name = "home") ) ) ) @@ -178,5 +204,3 @@ server <- function(input, output) { } # app shinyApp(ui, server) ``` - - From 0e26c36a5054d9664a30c4e343f384097470a927 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Fri, 29 Jan 2021 18:00:03 +0100 Subject: [PATCH 09/18] removed cli dependency (#20) --- DESCRIPTION | 1 - R/rheroicon.R | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1a52e95..8bdf626 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,6 @@ RoxygenNote: 7.1.1 Imports: htmltools (>= 0.5.0), shiny (>= 1.5.0), - cli, stringr Suggests: testthat diff --git a/R/rheroicon.R b/R/rheroicon.R index b33e230..43556a4 100644 --- a/R/rheroicon.R +++ b/R/rheroicon.R @@ -35,15 +35,13 @@ rheroicon <- function(name, type = "outline", classnames = NULL) { # warn if icon does not exist if (is.null(icon)) { - cli::cli_alert_danger("Icon {.val {name}} cannot be found.") + warning("Icon does not exist") } # throw error if input value for "type" is invalid valid_types <- c("outline", "solid") if (!type %in% valid_types) { - cli::cli_alert_danger( - "Type {.val {type}} is invalid. Use {.val {.valid_types}}" - ) + warning("Icon type is invalid. Use 'outline' or 'solid'") } # process only if icon exists From e31995f2ffdbf2830efabf2214cd02c86da520c3 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Fri, 29 Jan 2021 20:08:17 +0100 Subject: [PATCH 10/18] fixed errors found by (#20) --- NEWS.md | 29 ++++++++++++++++++----------- R/rheroicon.R | 16 ++++++++-------- README.md | 22 +++++++++++----------- man/rheroicon.Rd | 16 ++++++++-------- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7b6b5cd..2814d13 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,20 +1,27 @@ +# rheroicons 0.3.0 + +* Prepared package for CRAN submission +* Removed `cli` package as a dependency +* Added tests for `find_icon` +* Revised documentation + # rheroicons 0.2.4 -* Upgraded to latest version of heroicons ([v0.4.2](https://github.com/tailwindlabs/heroicons/releases/tag/v0.4.2)) +* Upgraded to latest version of Heroicons ([v0.4.2](https://github.com/tailwindlabs/heroicons/releases/tag/v0.4.2)) # rheroicons 0.2.3 -This is a minor package update. The main issue was the handling of error messages via the cli package. These changes are listed below. +This is a minor package update. The main issue was the handling of error messages via the `cli` package. These changes are listed below. -* Updated error message for rheroicon function. It now uses {.val {value}} +* Updated error message for `rheroicon` function. It now uses {.val {value}} * Removed error message for find_icons as the default query is "". -* Reinit pkgbump configuration file +* Reset `pkgbump` configuration file # rheroicons 0.2.21 -* Switched to webpack as the bundler of choice :tada: -* Tested assets in dev and prod environments using the `dev-app` -* Rebuilt assets +* The development side of this package now uses Webpack! +* Tested assets in `dev` and `prod` environments using the `dev-app` +* Rebuilt assets * Updated R package configuration and ignore files # rheroicons 0.2.2 @@ -28,13 +35,13 @@ This is a minor package update. The main issue was the handling of error message # rheroicons 0.2.0 -* New package structure :rocket: icons are now generated using the function `rheroicon`. Select an icon using the argument `name`. Icons can be found in the gallery via `launch_gallery()` function. Use the argument `type` to return define the icon style as `outline` or `solid`. Icons can be further customized by passing additional css classes using the `classnames` argument. -* Restructured rheroicons gallery as icons are available using an internal dataset. The gallery's ui, server, and modules are now located in `R/launch_gallery.R`. Static assets are still located in `inst/rheroicons-demo`. +* New package structure! Icons are now generated using the function `rheroicon`. Select an icon using the argument `name`. Icons can be found in the gallery via `launch_gallery()` function. Use the argument `type` to return define the icon style as `outline` or `solid`. Icons can be further customized by passing additional CSS classes using the `classnames` argument. +* Restructured rheroicons gallery as icons are available using an internal dataset. The gallery's client, server, and modules are now located in `R/launch_gallery.R`. Static assets are still located in `inst/rheroicons-demo`. * Rewrote unit tests ## rheroicons 0.1.6 -* Updated to heroicons `v0.4.0` +* Updated to Heroicons `v0.4.0` * Redesigned icon gallery ## rheroicons 0.1.5 @@ -48,4 +55,4 @@ This is a minor package update. The main issue was the handling of error message ## rheroicons 0.1.4 * Added a `NEWS.md` file to track changes to the package. -* Added Package management dir `dev`. Convert Icons using `dev/dev.R` \ No newline at end of file +* Added Package management directory `dev`. Convert Icons using `dev/dev.R` \ No newline at end of file diff --git a/R/rheroicon.R b/R/rheroicon.R index 43556a4..06d0ec9 100644 --- a/R/rheroicon.R +++ b/R/rheroicon.R @@ -1,19 +1,19 @@ -#' An inline SVG icon from heriocons +#' An inline SVG icon from Heroicons #' -#' Render an rheroicon icon by name. Use `launch_gallery` to view the icons -#' available in this package or visit the heroicons icon gallery +#' Render an icon by name. Use `launch_gallery` to view the icons +#' available in this package or visit the Heroicons icon gallery #' (see referenced urls). #' -#' @param name a heroicon icon name +#' @param name an icon name #' @param type render a "solid" or "outline" icon (default: "outline") #' @param classnames a string containing one or more CSS classes (optional) #' -#' @section Styling Icons with classnames: +#' @section Styling Icons with CSS class names: #' -#' Icons are rendered from svg strings. All icons have three css classes +#' Icons are rendered from SVG strings. All icons have three CSS classes #' defined: global ("rheroicons"), icon style ("rheroicons_outline" or #' "rheroicons_solid"), and icon name ("rheroicons_academic_cap"). -#' Use any of combination of these classes to style icons via css. +#' Use any of combination of these classes to style icons via CSS. #' Alternatively, you can pass your own classes using the \code{classnames} #' argument. #' @@ -22,7 +22,7 @@ #' rheroicon(name = "academic_cap", type = "solid") #' rheroicon(name = "academic_cap", classnames = "education-icons") #' -#' @return Returns an svg string of an Heroicon icon +#' @return Returns an SVG string #' #' @references #' \url{https://github.com/tailwindlabs/heroicons} diff --git a/README.md b/README.md index cdfb819..5660d91 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ # rheroicons -The `rheroicons` packages brings to the [heroicons](https://github.com/refactoringui/heroicons) icon library, developed by [adamwathan](https://github.com/adamwathan) and [sschoger](https://github.com/sschoger), as R functions for use in your R-based web projects (i.e., shiny, Rmarkdown, etc.). +The `rheroicons` packages brings to the [Heroicons](https://github.com/refactoringui/heroicons) icon library, developed by [Adam Wathan](https://github.com/adamwathan) and [Steve Schoger](https://github.com/sschoger), as R functions for use in your R-based web projects. -All icons are rendered as inline svg icons. Therefore, no css or js dependencies are loaded into your Shiny application, Rmd file, or other web document at runtime! +All icons are rendered as inline SVG icons. Therefore, no CSS or JavaScript dependencies are loaded into your Shiny application or other web document at runtime! ## Install @@ -27,7 +27,7 @@ There are over 200 icons in the collection. Each icon has two styles: outline an rheroicons::launch_gallery() ``` -Click an icon name to copy the R code used to generate the icon. You can paste the R code directly into your Shiny app, Rmd file, or other web-based project. +Click an icon name to copy the R code used to generate the icon. You can paste the R code directly into your Shiny app or other web-based document. Alternatively, you can use the `find_icon` function to search for icons. @@ -54,7 +54,7 @@ When you have found the icon that you would like to use, you can render them int rheroicons::rheroicon(name = "document_add") ``` -You can use the [heroicons](https://heroicons.com) site to find icons. All icons that have a dash (`-`) in the original name were renamed using underscores (`_`). +You can use the [Heroicons](https://heroicons.com) site to find icons. All icons that have a dash (`-`) in the original name were renamed using underscores (`_`). #### Arguments @@ -64,7 +64,7 @@ All functions take the following arguments. |--------------|------------------------|-------------------------------------|-----------| | `name` | icon name | use `find_icon` or `launch_gallery` | --- | | `type` | icon style | `outline` or `solid` | `outline` | -| `classnames` | add custom css classes | --- | `NULL` | +| `classnames` | add custom CSS classes | --- | `NULL` | Example use: @@ -80,7 +80,7 @@ tags$button( ### Customizing the appearance of icons -Use the argument `classnames` to add custom css classes to your icons. +Use the argument `classnames` to add custom CSS classes to your icons. ```r library(shiny) @@ -104,12 +104,12 @@ However, you may find it easier to use the predefined classes generated by this - set: `rheroicons_solid` or `rheroicons_outline` - icon: `rhericons_*`, where `*` is the name of the icon. (This is same as the icon name.) -The following table displays the CSS clases by set for the `arrow_circle_down` icon. +The following table displays the CSS classes by set for the `arrow_circle_down` icon. -| set | function | css classes | -|---------|----------------------------------------------------------|--------------------------------------------------------------| -| outline | `rheroicon(name ="arrow_circle_down", type = "outline")` | `rheroicons rheroicons_outline rheroicons_arrow_circle_down` | -| solid | `rheroicon(name ="arrow_circle_down", type = "solid")` | `rheroicons rheroicons_solid rheroicons_arrow_circle_down` | +| Icon Set | Function | CSS classes | +|----------|----------------------------------------------------------|--------------------------------------------------------------| +| outline | `rheroicon(name ="arrow_circle_down", type = "outline")` | `rheroicons rheroicons_outline rheroicons_arrow_circle_down` | +| solid | `rheroicon(name ="arrow_circle_down", type = "solid")` | `rheroicons rheroicons_solid rheroicons_arrow_circle_down` | You can select and style icons through CSS using these classes. Create a new `tags$style` element and define your styles (or use an external CSS file). diff --git a/man/rheroicon.Rd b/man/rheroicon.Rd index e6d23f7..d8efb21 100644 --- a/man/rheroicon.Rd +++ b/man/rheroicon.Rd @@ -2,32 +2,32 @@ % Please edit documentation in R/rheroicon.R \name{rheroicon} \alias{rheroicon} -\title{An inline SVG icon from heriocons} +\title{An inline SVG icon from Heroicons} \usage{ rheroicon(name, type = "outline", classnames = NULL) } \arguments{ -\item{name}{a heroicon icon name} +\item{name}{an icon name} \item{type}{render a "solid" or "outline" icon (default: "outline")} \item{classnames}{a string containing one or more CSS classes (optional)} } \value{ -Returns an svg string of an Heroicon icon +Returns an SVG string } \description{ -Render an rheroicon icon by name. Use \code{launch_gallery} to view the icons -available in this package or visit the heroicons icon gallery +Render an icon by name. Use \code{launch_gallery} to view the icons +available in this package or visit the Heroicons icon gallery (see referenced urls). } -\section{Styling Icons with classnames}{ +\section{Styling Icons with CSS class names}{ -Icons are rendered from svg strings. All icons have three css classes +Icons are rendered from SVG strings. All icons have three CSS classes defined: global ("rheroicons"), icon style ("rheroicons_outline" or "rheroicons_solid"), and icon name ("rheroicons_academic_cap"). -Use any of combination of these classes to style icons via css. +Use any of combination of these classes to style icons via CSS. Alternatively, you can pass your own classes using the \code{classnames} argument. } From ceacfe9715c8415b6883b3066f63835405cc311d Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Fri, 29 Jan 2021 20:08:38 +0100 Subject: [PATCH 11/18] revised copyright holders (#20) --- DESCRIPTION | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8bdf626..ec5aee6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: rheroicons -Title: A zero dependency svg icon library for use in R web-based projects +Title: A zero dependency SVG icon library for use in R web-based projects Version: 0.3.0 Authors@R: c( person( @@ -9,15 +9,20 @@ Authors@R: c( email = "dcruvolo@gmail.com", comment = c(ORCID = "0000-0002-5745-5298")), person( - "Refactoring UI Inc", + given = "Adam", + family = "Wathan", + role = c("ctb", "cph"), + comment = "Author of heroicons library"), + person( + given = "Steve", + family = "Schoger", role = c("ctb", "cph"), comment = "Author of heroicons library") ) Description: The rheroicons provides access to the fantastic SVG icon - collection heroicons, originally developed by Adam Wathan and - Steve Schoger at Tailwind Labs, as R functions for use in your - web-based projects (i.e., shiny Rmarkdown, etc.). All icons are - rendered as inline SVG elements. Therefore no HTML, CSS, or + collection Heroicons as R functions for use in your + web-based projects. All icons are + rendered as inline SVG elements. Therefore no CSS, or JavaScript dependencies are loaded into your app. License: MIT + file LICENSE Encoding: UTF-8 @@ -28,7 +33,9 @@ Imports: htmltools (>= 0.5.0), shiny (>= 1.5.0), stringr -Suggests: +Suggests: + spelling, testthat Depends: R (>= 2.10) +Language: en-US From 31b72a9c98340d597330da4f71a1ac2e848a366e Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Fri, 29 Jan 2021 20:20:06 +0100 Subject: [PATCH 12/18] added commands for cran checks (#20) --- dev/dev.R | 58 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/dev/dev.R b/dev/dev.R index ade37cb..4736069 100644 --- a/dev/dev.R +++ b/dev/dev.R @@ -9,49 +9,59 @@ #' COMMENTS: NA #'//////////////////////////////////////////////////////////////////////////// -# init primary files -usethis::use_namespace() -usethis::use_description() -usethis::use_travis() -usethis::use_github_action_check_standard() -usethis::use_news_md() -usethis::use_testthat() +#' init primary files +#' usethis::use_namespace() +#' usethis::use_description() +#' usethis::use_travis() +#' usethis::use_github_action_check_standard() +#' usethis::use_news_md() +#' usethis::use_testthat() + -# pkgs -usethis::use_package(package = "htmltools", min_version = TRUE) -usethis::use_package(package = "shiny") -usethis::use_package(package = "stringr") -usethis::use_package(package = "cli") #'////////////////////////////////////// #' ~ 1 ~ -# convert icons +#' SVG Processing + +#' load conversion tools source("dev/convert.R") -# use dataset +#' update internal data object usethis::use_data(rheroicons, internal = TRUE, overwrite = TRUE) #'////////////////////////////////////// -# checks +#' ~ 2 ~ +#' Package Management + +#' ~ 2a ~ +#' pkgs +usethis::use_package(package = "htmltools", min_version = TRUE) +usethis::use_package(package = "shiny") +usethis::use_package(package = "stringr") + +#' ~ 2b ~ +#' pkg checks devtools::check_man() devtools::load_all() devtools::test() devtools::check() -# init pkgbump -pkgbump::set_pkgbump( - files = c( - "package.json", - "DESCRIPTION" - ) -) +#' ~ 2c ~ +#' cran checks +devtools::check() +devtools::spell_check() +devtools::check_win_release() +devtools::check_win_devel() +#' ~ 2c ~ +#' pkgbump configuration +pkgbump::set_pkgbump(files = c("package.json", "DESCRIPTION")) pkgbump::pkgbump(version = "0.3.0") - -# ignore +#' ~ 2d ~ +# ignore files ignore <- c( "node_modules", "inst/rheroicons-gallery/rsconnect", From 0e07effafa6423ca6b1d3b6cb7603917b932b542 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Sat, 30 Jan 2021 15:40:01 +0100 Subject: [PATCH 13/18] improved docs and code for tests --- R/find_icon.R | 4 ++++ R/launch_gallery.R | 7 +++++-- R/rheroicon.R | 2 +- R/utils.R | 1 + man/find_icons.Rd | 4 ++++ man/rheroicon.Rd | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/R/find_icon.R b/R/find_icon.R index 7fa13e6..10ce929 100644 --- a/R/find_icon.R +++ b/R/find_icon.R @@ -10,6 +10,10 @@ #' #' @return An array of icon names #' +#' @references +#' \url{https://heroicons.com} +#' \url{https://github.com/tailwindlabs/heroicons} +#' #' @export find_icons <- function(query = "") { stringr::str_subset(string = names(rheroicons), pattern = query) diff --git a/R/launch_gallery.R b/R/launch_gallery.R index 09dd3e0..a99793d 100644 --- a/R/launch_gallery.R +++ b/R/launch_gallery.R @@ -28,7 +28,7 @@ launch_gallery <- function(...) { ns <- shiny::NS(id) shiny::tags$li( id = ns("icon"), - class = "icon-item", + class = paste0("icon-item set-", set), shiny::tags$button( id = ns("icon-copy"), class = "icon-name icon-button", @@ -58,7 +58,10 @@ launch_gallery <- function(...) { ns <- shiny::NS(id) # define elements - parent <- shiny::tags$ul(id = ns("icon-set"), class = "icon-list") + parent <- shiny::tags$ul( + id = ns("icon-set"), + class = paste0("icon-list set-", set) + ) children <- list() # outline icons diff --git a/R/rheroicon.R b/R/rheroicon.R index 06d0ec9..075ced9 100644 --- a/R/rheroicon.R +++ b/R/rheroicon.R @@ -25,8 +25,8 @@ #' @return Returns an SVG string #' #' @references -#' \url{https://github.com/tailwindlabs/heroicons} #' \url{https://heroicons.com} +#' \url{https://github.com/tailwindlabs/heroicons} #' #' @export rheroicon <- function(name, type = "outline", classnames = NULL) { diff --git a/R/utils.R b/R/utils.R index f2948c2..fa24184 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,6 +5,7 @@ #' customizing the appearance of icons. #' #' @param svg a string containing the SVG markup of an icon +#' @param class a string containing one or more CSS classes #' #' @noRd .set__classnames <- function(svg, class) { diff --git a/man/find_icons.Rd b/man/find_icons.Rd index c1cd7a4..4e777b0 100644 --- a/man/find_icons.Rd +++ b/man/find_icons.Rd @@ -22,3 +22,7 @@ find_icons(query = "chevron|arrow") find_icons(query = "down|up|left|right") } +\references{ +\url{https://heroicons.com} +\url{https://github.com/tailwindlabs/heroicons} +} diff --git a/man/rheroicon.Rd b/man/rheroicon.Rd index d8efb21..31926b7 100644 --- a/man/rheroicon.Rd +++ b/man/rheroicon.Rd @@ -39,6 +39,6 @@ rheroicon(name = "academic_cap", classnames = "education-icons") } \references{ -\url{https://github.com/tailwindlabs/heroicons} \url{https://heroicons.com} +\url{https://github.com/tailwindlabs/heroicons} } From 3fa26af9349b6512ea74154a6230263ca73cfdd3 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Sat, 30 Jan 2021 15:40:46 +0100 Subject: [PATCH 14/18] improved test coverage (#20) --- tests/testthat/test-launch-gallery.R | 109 +++++++++++++++++++++++++++ tests/testthat/test-rheroicon.R | 21 ++++++ 2 files changed, 130 insertions(+) create mode 100644 tests/testthat/test-launch-gallery.R diff --git a/tests/testthat/test-launch-gallery.R b/tests/testthat/test-launch-gallery.R new file mode 100644 index 0000000..b0ae15e --- /dev/null +++ b/tests/testthat/test-launch-gallery.R @@ -0,0 +1,109 @@ +#'//////////////////////////////////////////////////////////////////////////// +#' FILE: test-launch-gallery.R +#' AUTHOR: David Ruvolo +#' CREATED: 2021-01-30 +#' MODIFIED: 2021-01-30 +#' PURPOSE: unit tests for launch gallery +#' STATUS: in.progress +#' PACKAGES: usethis; rheroicons; shiny +#' COMMENTS: NA +#'//////////////////////////////////////////////////////////////////////////// + +#' .gallery__list__element() +#' Make sure icons are returned as li element +test_that("Markup of gallery element is expected", { + + # choose a random outline icon + res <- .gallery__list__element( + id = "test", + set = "outline", + icon = rheroicons[["zoom_out"]][["icons"]][["solid"]] + ) + + expect_equal( + object = c( + res$name, + res$attribs$class, + res$children[[1]]$name, + names(attributes(res$children[[1]]$children[[1]]))[1], + res$children[[1]]$children[[2]]$name + ), + expected = c( + "li", + "icon-item set-outline", + "button", + "html", # grab attribute instead + "span" + ), + label = "Gallery element does not have expected markup" + ) +}) + + +#' gallery_list() +#' Test both sets +test_that("Icon sets render properly", { + + set_sol <- .gallery__list(id = "test", set = "solid") + set_out <- .gallery__list(id = "test", set = "outline") + + expect_equal( + object = c( + set_sol$attribs$class, + set_out$attribs$class + ), + expected = c( + "icon-list set-solid", + "icon-list set-outline" + ), + label = "Solid and Outline icons are marked up properly" + ) +}) + +#' I'm not sure if these tests are helpful, but I guess I have to +#' please the coverage overlords! + +#' launch_gallery() +test_that("start gallery returns a shiny object", { + expect_equal( + object = class(launch_gallery(options = c(port = 1234))), + expected = "shiny.appobj", + label = "Start gallery does not return a shiny object" + ) +}) + +#' .ui() +#' This isn't a great unit test, but return and eval the primary +#' html elements +test_that("UI function returns expected markup", { + + res <- .ui() + expect_equal( + object = c( + class(res), + res[[2]]$name, + res[[3]]$name, + res[[4]]$name, + res[[5]]$name, + res[[6]]$name + ), + expected = c( + "shiny.tag.list", "list", + "nav", + "main", + "div", + "div", + "script" + ) + ) +}) + +#' .server() +#' This isn't really a test, but it maybe check to see the +#' server function returns something +test_that("Server returns R6 Shiny Observer", { + expect_equal( + object = class(.server()), + expected = c("Observer", "R6") + ) +}) \ No newline at end of file diff --git a/tests/testthat/test-rheroicon.R b/tests/testthat/test-rheroicon.R index f1814bb..80ee0ea 100644 --- a/tests/testthat/test-rheroicon.R +++ b/tests/testthat/test-rheroicon.R @@ -9,6 +9,27 @@ #' COMMENTS: NA #' //////////////////////////////////////////////////////////////////////////// +#' Icon is Null +#' +#' Function fails correctly if no name is provided +test_that("function properly errors out", { + expect_warning( + object = rheroicon() + ) +}) + +#' IconType fails +#' +#' If an invalid icon type is provided, function should +#' fail as expected. Pass a value other than `solid` or `outline` +test_that("invalid type properly returns error", { + expect_warning( + object = rheroicon( + name = "academic_cap", + type = "circle" + ) + ) +}) #' Class evaluation #' From 6e372ace8efeb55e7874a48da4891ba64b8241b3 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Sat, 30 Jan 2021 15:41:14 +0100 Subject: [PATCH 15/18] minor revisions and fixing broken links (#20) --- DESCRIPTION | 9 ++++----- README.md | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ec5aee6..3c1d0c1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,11 +19,10 @@ Authors@R: c( role = c("ctb", "cph"), comment = "Author of heroicons library") ) -Description: The rheroicons provides access to the fantastic SVG icon - collection Heroicons as R functions for use in your - web-based projects. All icons are - rendered as inline SVG elements. Therefore no CSS, or - JavaScript dependencies are loaded into your app. +Description: The rheroicons package brings the Heroicons icon library + to Shiny and other web-based projects. All icons are rendered as + inline SVG elements. Therefore, no CSS or JavaScript dependencies + are required! License: MIT + file LICENSE Encoding: UTF-8 LazyData: true diff --git a/README.md b/README.md index 5660d91..e58138f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ # rheroicons -The `rheroicons` packages brings to the [Heroicons](https://github.com/refactoringui/heroicons) icon library, developed by [Adam Wathan](https://github.com/adamwathan) and [Steve Schoger](https://github.com/sschoger), as R functions for use in your R-based web projects. +The `rheroicons` packages brings to the [Heroicons](https://github.com/tailwindlabs/heroicons) icon library, developed by [Adam Wathan](https://github.com/adamwathan) and [Steve Schoger](https://github.com/sschoger), as R functions for use in your R-based web projects. All icons are rendered as inline SVG icons. Therefore, no CSS or JavaScript dependencies are loaded into your Shiny application or other web document at runtime! From abab42761afa5be9536aba974f21b6895d2f8c89 Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Sat, 30 Jan 2021 15:41:36 +0100 Subject: [PATCH 16/18] updated cran comments and pkg management script --- cran-comments.md | 15 ++++++++++++++- dev/dev.R | 14 +++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index d33d94b..c200561 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,6 +2,19 @@ ## Test environments +* local OS X install, R 4.0.3 +* windows-latest release (on GitHub Actions), R 4.0.3 +* macOS-latest release (on GitHub Actions), R 4.0.3 +* ubuntu-20.04 release (on GitHub Actions), R 4.0.3 +* ubuntu-20.04 devel (on GitHub Actions), R 4.0.3 +* win-builder (devel and release) + ## R CMD check results -## Downstream dependencies +0 errors | 0 warnings | 1 note + +There was one note: + +* Possibly mis-spelled words in DESCRIPTION: Heroicons (24:16) rheroicons (23:18) + +Heroicons is the name of the original library and rheroicons is the name of the current library. \ No newline at end of file diff --git a/dev/dev.R b/dev/dev.R index 4736069..25406b3 100644 --- a/dev/dev.R +++ b/dev/dev.R @@ -2,13 +2,18 @@ #' FILE: dev.R #' AUTHOR: David Ruvolo #' CREATED: 2020-08-07 -#' MODIFIED: 2021-01-27 +#' MODIFIED: 2021-01-30 #' PURPOSE: package management #' STATUS: ongoing #' PACKAGES: usethis; pkgbump #' COMMENTS: NA #'//////////////////////////////////////////////////////////////////////////// +#' install dev packages +#' install.packages("devtools") +#' install.packages("usethis") +#' remotes::install_github("r-lib/revdepcheck") + #' init primary files #' usethis::use_namespace() #' usethis::use_description() @@ -17,8 +22,6 @@ #' usethis::use_news_md() #' usethis::use_testthat() - - #'////////////////////////////////////// #' ~ 1 ~ @@ -50,13 +53,18 @@ devtools::check() #' ~ 2c ~ #' cran checks +covr::package_coverage() +covr::report() devtools::check() devtools::spell_check() +devtools::run_examples() +devtools::test() devtools::check_win_release() devtools::check_win_devel() #' ~ 2c ~ #' pkgbump configuration +#' remotes::install_github("davidruvolo51/pkgbump") pkgbump::set_pkgbump(files = c("package.json", "DESCRIPTION")) pkgbump::pkgbump(version = "0.3.0") From 8145c18417383534576b8f9fac26f3a10122c28f Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Sat, 30 Jan 2021 16:37:10 +0100 Subject: [PATCH 17/18] fixed title case note --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3c1d0c1..ec3aa74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: rheroicons -Title: A zero dependency SVG icon library for use in R web-based projects +Title: A Zero Dependency SVG Icon Library for Use in R Web-Based Projects Version: 0.3.0 Authors@R: c( person( From de7b05e50d1f468ad794522e908dd83b003bdd7a Mon Sep 17 00:00:00 2001 From: davidruvolo51 Date: Sat, 30 Jan 2021 16:58:39 +0100 Subject: [PATCH 18/18] fixing license to meet CRAN policies (#20) --- .Rbuildignore | 1 + LICENSE | 57 ++------------------------------------------------- LICENSE.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++ dev/dev.R | 2 ++ 4 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 LICENSE.md diff --git a/.Rbuildignore b/.Rbuildignore index 8accc73..45d59c2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,3 +14,4 @@ ^rheroicons\.code-workspace$ ^webpack\.config\.js$ ^yarn\.lock$ +^LICENSE\.md$ diff --git a/LICENSE b/LICENSE index f002403..ae3e4ea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,55 +1,2 @@ -The rheroicons package as a whole is distributed under MIT License. - -MIT License - -Copyright (c) 2021 dcruvolo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - -The rheroicons package includes other open source software components. The following -is a list of these components (full copies of the license agreements used by -these components are included below): - -- heroicons, https://github.com/tailwindlabs/heroicons - -Heriocons License --------------------------------- - -MIT License - -Copyright (c) 2020 Refactoring UI Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +YEAR: 2021 +COPYRIGHT HOLDER: David Ruvolo diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e0fe5dd --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,53 @@ +# MIT License + +The rheroicons package as a whole is distributed under MIT License. + +Copyright (c) 2021 rheroicons authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +The rheroicons package includes other open source software components. The following +is a list of these components (full copies of the license agreements used by +these components are included below): + +- heroicons, [https://github.com/tailwindlabs/heroicons](https://github.com/tailwindlabs/heroicons) + +## Heriocons License + +MIT License + +Copyright (c) 2020 Refactoring UI Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dev/dev.R b/dev/dev.R index 25406b3..6f1e977 100644 --- a/dev/dev.R +++ b/dev/dev.R @@ -21,6 +21,7 @@ #' usethis::use_github_action_check_standard() #' usethis::use_news_md() #' usethis::use_testthat() +#' usethis::use_mit_license("David Ruvolo") #'////////////////////////////////////// @@ -87,6 +88,7 @@ usethis::use_build_ignore( ".babelrc", ".gitignore", "cran-comments.md", + "LICENSE.md", "package.json", "pkgbump.config.json", "postcss.config.js",