Skip to content

Commit

Permalink
Merge pull request #23 from davidruvolo51/dev
Browse files Browse the repository at this point in the history
rheriocons resubmission
  • Loading branch information
davidruvolo51 authored Feb 13, 2021
2 parents b795c76 + dd2c06a commit 30f2a57
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 122 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
^webpack\.config\.js$
^yarn\.lock$
^LICENSE\.md$
^CRAN-RELEASE$
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.cache
.parcel-cache
inst/rheroicons-gallery/rsconnect
yarn-error.log
yarn-error.log
CRAN-RELEASE
11 changes: 5 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions R/find_icon.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
69 changes: 33 additions & 36 deletions R/launch_gallery.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -245,7 +269,7 @@ launch_gallery <- function(...) {
rheroicon(
name = "check_circle",
type = "solid",
classnames = "selected-icon"
class = "selected-icon"
),
"Outline"
)
Expand All @@ -261,7 +285,7 @@ launch_gallery <- function(...) {
rheroicon(
name = "check_circle",
type = "solid",
classnames = "selected-icon"
class = "selected-icon"
),
"Solid"
)
Expand Down Expand Up @@ -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
})
}
})
}
47 changes: 30 additions & 17 deletions R/rheroicon.R
Original file line number Diff line number Diff line change
@@ -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]]

Expand All @@ -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
)
}

Expand Down
5 changes: 2 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 15 additions & 12 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -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.
0 errors | 0 warnings | 0 note
6 changes: 5 additions & 1 deletion dev/dev-app/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
#'////////////////////////////////////////////////////////////////////////////

devtools::load_all()
launch_gallery(options = list(port = 9000, launch.browser = TRUE))
launch_gallery(options = list(port = 9000, launch.browser = TRUE))

#" find icons tests
find_icons(query = "circle")
find_icons(query = "(\\_down)$")
14 changes: 11 additions & 3 deletions dev/dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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()
10 changes: 7 additions & 3 deletions man/find_icons.Rd

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

Loading

0 comments on commit 30f2a57

Please sign in to comment.