diff --git a/.Rbuildignore b/.Rbuildignore index 45d59c2..549fb21 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,3 +15,4 @@ ^webpack\.config\.js$ ^yarn\.lock$ ^LICENSE\.md$ +^CRAN-RELEASE$ diff --git a/.gitignore b/.gitignore index d37027e..4f64bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules .cache .parcel-cache inst/rheroicons-gallery/rsconnect -yarn-error.log \ No newline at end of file +yarn-error.log +CRAN-RELEASE diff --git a/DESCRIPTION b/DESCRIPTION index ec3aa74..678b41e 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.3.0 +Title: A Zero Dependency 'SVG' Icon Library for 'Shiny' +Version: 0.3.1 Authors@R: c( person( given = "David", @@ -19,10 +19,9 @@ Authors@R: c( role = c("ctb", "cph"), comment = "Author of heroicons library") ) -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! +Description: An implementation of the 'Heroicons' icon library for 'shiny' + applications and other 'R' web-based projects. You can search, render, + and customize icons without 'CSS' or 'JavaScript' dependencies. License: MIT + file LICENSE Encoding: UTF-8 LazyData: true diff --git a/R/find_icon.R b/R/find_icon.R index 10ce929..694ae9d 100644 --- a/R/find_icon.R +++ b/R/find_icon.R @@ -1,19 +1,25 @@ #' Find available icons #' -#' @param query a search term passed down to \code{stringr::str_subset}. -#' Alternatively, leave blank to view all icon names. +#' You can search for icons by querying the icon set. For example, if you would +#' like to find icons that are arrows and chevrons, then type in you query as a +#' regexp: 'arrows|chevrons'. Alternatively, if you would like to view all icon +#' names, leave the value for 'query' blank. +#' +#' @param query a string containing a search term #' #' @examples #' find_icons(query = "chevron") #' find_icons(query = "chevron|arrow") #' find_icons(query = "down|up|left|right") +#' find_icons(query = "_circle_") +#' find_icons(query = "(\\_down)$") #' #' @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 a99793d..1a28cf0 100644 --- a/R/launch_gallery.R +++ b/R/launch_gallery.R @@ -1,18 +1,42 @@ -#' rheroicons gallery +#' Icon gallery #' -#' Run the rheroicons gallery and search for icons. Click on an icon -#' name to copy the function to the clipboard. +#' Run the gallery to view and search for icons. Click on an icon +#' name to copy the 'R' code to the clipboard. #' -#' @param ... additional options passed down to \code{shiny::runApp} +#' @param ... additional 'shiny' options #' #' @examples -#' \dontrun{ +#' if (interactive()) { #' rheroicons::launch_gallery() #' } #' +#' @return A 'shiny' app containing the icon gallery +#' #' @export launch_gallery <- function(...) { - shiny::shinyApp(ui = .ui, server = .server, ...) + shiny::shinyApp( + ui = .ui, + server = function(input, output, session) { + outline_gallery <- .gallery__list("outline-icons", "outline") + solid_gallery <- .gallery__list("solid-icons", "solid") + + shiny::observe({ + shiny::req(input$iconSet) + + if (input$iconSet == "outline") { + output$icons <- shiny::renderUI({ + outline_gallery + }) + } + if (input$iconSet == "solid") { + output$icons <- shiny::renderUI({ + solid_gallery + }) + } + }) + }, + ... + ) } #' gallery icon list element @@ -227,7 +251,7 @@ launch_gallery <- function(...) { rheroicon( name = "chevron_down", type = "outline", - classnames = "select-input-parent-icon" + class = "select-input-parent-icon" ) ), shiny::tags$ol( @@ -245,7 +269,7 @@ launch_gallery <- function(...) { rheroicon( name = "check_circle", type = "solid", - classnames = "selected-icon" + class = "selected-icon" ), "Outline" ) @@ -261,7 +285,7 @@ launch_gallery <- function(...) { rheroicon( name = "check_circle", type = "solid", - classnames = "selected-icon" + class = "selected-icon" ), "Solid" ) @@ -296,31 +320,4 @@ launch_gallery <- function(...) { ), shiny::tags$script(src = "rheroicons/rheroicons.min.js") ) -} - - -#' rheroicons server -#' -#' @param input required shiny object -#' @param output required shiny object -#' @param session required shiny object -#' -#' @noRd -.server <- function(input, output, session) { - - outline_gallery <- .gallery__list("outline-icons", "outline") - solid_gallery <- .gallery__list("solid-icons", "solid") - - shiny::observe({ - if (input$iconSet == "outline") { - output$icons <- shiny::renderUI({ - outline_gallery - }) - } - if (input$iconSet == "solid") { - output$icons <- shiny::renderUI({ - solid_gallery - }) - } - }) } \ No newline at end of file diff --git a/R/rheroicon.R b/R/rheroicon.R index 075ced9..ecff235 100644 --- a/R/rheroicon.R +++ b/R/rheroicon.R @@ -1,35 +1,48 @@ #' An inline SVG icon from Heroicons #' -#' 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). +#' Render an icon by name. Run 'launch_gallery' to view all available icons +#' or search for icons using the 'find_icons' function. #' #' @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) +#' @param type render a 'solid' or 'outline' icon (default: 'outline') +#' @param class a string containing one or more 'CSS' classes (optional) #' -#' @section Styling Icons with CSS class names: +#' @section Styling Icons with 'CSS' class names: #' -#' 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. +#' Icons are rendered from 'SVG' strings. All icons have three 'CSS' classes +#' defined: global, icon style, and icon name. +#' +#' \describe{ +#' \item{global}{All icons are returned with the 'CSS' class 'rheroicons'} +#' \item{icon style}{ +#' All icons have a solid and an outlined version. +#' The icon style 'CSS' class is determined by the value entered for +#' 'type'. Icons can have 'rheroicons_outline' of 'rheroicons_solid'. +#' } +#' \item{icon name}{ +#' The icon name is also passed into the list of 'CSS' class. These +#' are always structured in the following format: 'rheroicons_icon'. +#' If the icon is 'thumb_down', the 'CSS' class would be +#' 'rheroicons_thumb_down'. +#' } +#' } +#' +#' Use any of combination of these classes to style icons via 'CSS'. +#' In addition, you apply your own 'CSS' classes using the 'class' argument. #' #' @examples #' rheroicon(name = "academic_cap") #' rheroicon(name = "academic_cap", type = "solid") -#' rheroicon(name = "academic_cap", classnames = "education-icons") +#' rheroicon(name = "academic_cap", class = "education-icons") #' -#' @return Returns an SVG string +#' @return An string containing the 'SVG' markup of an icon #' #' @references #' \url{https://heroicons.com} #' \url{https://github.com/tailwindlabs/heroicons} #' #' @export -rheroicon <- function(name, type = "outline", classnames = NULL) { +rheroicon <- function(name, type = "outline", class = NULL) { icon <- rheroicons[[name]] @@ -49,10 +62,10 @@ rheroicon <- function(name, type = "outline", classnames = NULL) { svg <- icon$icons[[type]] # append class attribute if applicable - if (!is.null(classnames)) { + if (!is.null(class)) { svg <- .set__classnames( svg = svg, - class = classnames + class = class ) } diff --git a/R/utils.R b/R/utils.R index fa24184..2d0909d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,8 +1,7 @@ #' Process CSS Classes #' -#' In the `rheroicon` function, the optional function `class` can be -#' used add custom CSS classes to an icon. This may be useful for -#' customizing the appearance of icons. +#' In the main icon function, the optional argument 'class' can be +#' used add custom CSS classes to an icon. #' #' @param svg a string containing the SVG markup of an icon #' @param class a string containing one or more CSS classes diff --git a/cran-comments.md b/cran-comments.md index c200561..86ca9cf 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,20 +1,23 @@ # CRAN Comments -## Test environments +## Resubmission -* 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) +This is a resubmission. In this version, I have: -## R CMD check results +- revised the package description so that the phrase 'this package' is no longer used +- revised documentation so that all references to tools are wrapped in single quotes rather than double quotes +- added missing `value` tags for the function `launch_gallery` and revised existing value tags to clearly document what each function returns +- changed `\dontRun` to `if (interactive())` in the documentation for `launch_gallery` -0 errors | 0 warnings | 1 note +## Test environments -There was one note: +- 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) -* Possibly mis-spelled words in DESCRIPTION: Heroicons (24:16) rheroicons (23:18) +## R CMD check results -Heroicons is the name of the original library and rheroicons is the name of the current library. \ No newline at end of file +0 errors | 0 warnings | 0 note diff --git a/dev/dev-app/app.R b/dev/dev-app/app.R index 166ea5c..ab7fcc5 100644 --- a/dev/dev-app/app.R +++ b/dev/dev-app/app.R @@ -10,4 +10,8 @@ #'//////////////////////////////////////////////////////////////////////////// devtools::load_all() -launch_gallery(options = list(port = 9000, launch.browser = TRUE)) \ No newline at end of file +launch_gallery(options = list(port = 9000, launch.browser = TRUE)) + +#" find icons tests +find_icons(query = "circle") +find_icons(query = "(\\_down)$") \ No newline at end of file diff --git a/dev/dev.R b/dev/dev.R index 6f1e977..14df2c2 100644 --- a/dev/dev.R +++ b/dev/dev.R @@ -2,7 +2,7 @@ #' FILE: dev.R #' AUTHOR: David Ruvolo #' CREATED: 2020-08-07 -#' MODIFIED: 2021-01-30 +#' MODIFIED: 2021-02-13 #' PURPOSE: package management #' STATUS: ongoing #' PACKAGES: usethis; pkgbump @@ -56,7 +56,7 @@ devtools::check() #' cran checks covr::package_coverage() covr::report() -devtools::check() +devtools::check(cran = TRUE, env_vars = c(NOT_CRAN = FALSE), manual = TRUE) devtools::spell_check() devtools::run_examples() devtools::test() @@ -67,7 +67,7 @@ devtools::check_win_devel() #' pkgbump configuration #' remotes::install_github("davidruvolo51/pkgbump") pkgbump::set_pkgbump(files = c("package.json", "DESCRIPTION")) -pkgbump::pkgbump(version = "0.3.0") +pkgbump::pkgbump(version = "0.3.1") #' ~ 2d ~ # ignore files @@ -97,3 +97,11 @@ usethis::use_build_ignore( "yarn.lock" ) ) + +#' ~ 2e ~ +#' Release / Submit Package +#' Run the following code only if all checks have passed. This includes +#' all checks in 2B and 2C, as well as GitHub Actions. Push to GitHub +#' after `check_win_*` tests have been run and you have received the +#' confirmation email. +devtools::release() \ No newline at end of file diff --git a/man/find_icons.Rd b/man/find_icons.Rd index 4e777b0..120a3a8 100644 --- a/man/find_icons.Rd +++ b/man/find_icons.Rd @@ -7,19 +7,23 @@ find_icons(query = "") } \arguments{ -\item{query}{a search term passed down to \code{stringr::str_subset}. -Alternatively, leave blank to view all icon names.} +\item{query}{a string containing a search term} } \value{ An array of icon names } \description{ -Find available icons +You can search for icons by querying the icon set. For example, if you would +like to find icons that are arrows and chevrons, then type in you query as a +regexp: 'arrows|chevrons'. Alternatively, if you would like to view all icon +names, leave the value for 'query' blank. } \examples{ find_icons(query = "chevron") find_icons(query = "chevron|arrow") find_icons(query = "down|up|left|right") +find_icons(query = "_circle_") +find_icons(query = "(\\\\_down)$") } \references{ diff --git a/man/launch_gallery.Rd b/man/launch_gallery.Rd index 92d77d7..c25b927 100644 --- a/man/launch_gallery.Rd +++ b/man/launch_gallery.Rd @@ -2,19 +2,22 @@ % Please edit documentation in R/launch_gallery.R \name{launch_gallery} \alias{launch_gallery} -\title{rheroicons gallery} +\title{Icon gallery} \usage{ launch_gallery(...) } \arguments{ -\item{...}{additional options passed down to \code{shiny::runApp}} +\item{...}{additional 'shiny' options} +} +\value{ +A 'shiny' app containing the icon gallery } \description{ -Run the rheroicons gallery and search for icons. Click on an icon -name to copy the function to the clipboard. +Run the gallery to view and search for icons. Click on an icon +name to copy the 'R' code to the clipboard. } \examples{ -\dontrun{ +if (interactive()) { rheroicons::launch_gallery() } diff --git a/man/rheroicon.Rd b/man/rheroicon.Rd index 31926b7..4a245be 100644 --- a/man/rheroicon.Rd +++ b/man/rheroicon.Rd @@ -4,38 +4,51 @@ \alias{rheroicon} \title{An inline SVG icon from Heroicons} \usage{ -rheroicon(name, type = "outline", classnames = NULL) +rheroicon(name, type = "outline", class = NULL) } \arguments{ \item{name}{an icon name} -\item{type}{render a "solid" or "outline" icon (default: "outline")} +\item{type}{render a 'solid' or 'outline' icon (default: 'outline')} -\item{classnames}{a string containing one or more CSS classes (optional)} +\item{class}{a string containing one or more 'CSS' classes (optional)} } \value{ -Returns an SVG string +An string containing the 'SVG' markup of an icon } \description{ -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). +Render an icon by name. Run 'launch_gallery' to view all available icons +or search for icons using the 'find_icons' function. } -\section{Styling Icons with CSS class names}{ +\section{Styling Icons with 'CSS' class names}{ -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. +Icons are rendered from 'SVG' strings. All icons have three 'CSS' classes +defined: global, icon style, and icon name. + +\describe{ +\item{global}{All icons are returned with the 'CSS' class 'rheroicons'} +\item{icon style}{ +All icons have a solid and an outlined version. +The icon style 'CSS' class is determined by the value entered for +'type'. Icons can have 'rheroicons_outline' of 'rheroicons_solid'. +} +\item{icon name}{ +The icon name is also passed into the list of 'CSS' class. These +are always structured in the following format: 'rheroicons_icon'. +If the icon is 'thumb_down', the 'CSS' class would be +'rheroicons_thumb_down'. +} +} + +Use any of combination of these classes to style icons via 'CSS'. +In addition, you apply your own 'CSS' classes using the 'class' argument. } \examples{ rheroicon(name = "academic_cap") rheroicon(name = "academic_cap", type = "solid") -rheroicon(name = "academic_cap", classnames = "education-icons") +rheroicon(name = "academic_cap", class = "education-icons") } \references{ diff --git a/package.json b/package.json index 1fa43b6..0c12b43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rheroicons", - "version": "0.3.0", + "version": "0.3.1", "author": "dcruvolo", "description": "Heroicons for R", "license": "MIT", diff --git a/rheroicons.code-workspace b/rheroicons.code-workspace index 731278b..8d452e9 100644 --- a/rheroicons.code-workspace +++ b/rheroicons.code-workspace @@ -4,5 +4,19 @@ "path": "." } ], - "settings": {} + "settings": { + "markdownlint.config": { + "MD041": false + } + }, + "extensions": { + "recommendations": [ + "davidanson.vscode-markdownlint", + "shd101wyy.markdown-preview-enhanced", + "fcrespo82.markdown-table-formatter", + "alanwalk.markdown-toc", + "ikuyadeu.r", + "reditorsupport.r-lsp" + ] + } } diff --git a/tests/testthat/test-launch-gallery.R b/tests/testthat/test-launch-gallery.R index b0ae15e..ec2a142 100644 --- a/tests/testthat/test-launch-gallery.R +++ b/tests/testthat/test-launch-gallery.R @@ -2,9 +2,9 @@ #' FILE: test-launch-gallery.R #' AUTHOR: David Ruvolo #' CREATED: 2021-01-30 -#' MODIFIED: 2021-01-30 +#' MODIFIED: 2021-02-13 #' PURPOSE: unit tests for launch gallery -#' STATUS: in.progress +#' STATUS: working; ongoing #' PACKAGES: usethis; rheroicons; shiny #' COMMENTS: NA #'//////////////////////////////////////////////////////////////////////////// @@ -96,14 +96,4 @@ test_that("UI function returns expected markup", { "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 80ee0ea..7718bcf 100644 --- a/tests/testthat/test-rheroicon.R +++ b/tests/testthat/test-rheroicon.R @@ -2,9 +2,9 @@ #' FILE: test-rheroicon.R #' AUTHOR: David Ruvolo #' CREATED: 2020-09-06 -#' MODIFIED: 2020-09-06 +#' MODIFIED: 2021-02-09 #' PURPOSE: tests for the function `rheroicon` -#' STATUS: in.progress +#' STATUS: working; ongoing #' PACKAGES: usethis; rheroicons; #' COMMENTS: NA #' //////////////////////////////////////////////////////////////////////////// @@ -78,7 +78,7 @@ test_that("icon type", { test_that("classnames", { expect_equal( object = stringr::str_extract( - string = rheroicon(name = "map", classnames = "my-icons"), + string = rheroicon(name = "map", class = "my-icons"), pattern = "class=.([\\w\\s-])+." ), expected = "class=\"rheroicons rheroicons_outline rheroicons_map my-icons\"",