Skip to content

Commit

Permalink
Merge pull request #21 from davidruvolo51/dev
Browse files Browse the repository at this point in the history
Prepared package for CRAN submission
  • Loading branch information
davidruvolo51 authored Jan 30, 2021
2 parents 4550067 + de7b05e commit b795c76
Show file tree
Hide file tree
Showing 19 changed files with 484 additions and 164 deletions.
21 changes: 4 additions & 17 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
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$
^LICENSE\.md$
38 changes: 27 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
Package: rheroicons
Title: The Heroicons library for use in R-based web projects
Version: 0.2.4
Authors@R:
person(given = "David",
family = "Ruvolo",
role = c("aut", "cre"),
email = "[email protected]",
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.
Title: A Zero Dependency SVG Icon Library for Use in R Web-Based Projects
Version: 0.3.0
Authors@R: c(
person(
given = "David",
family = "Ruvolo",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-5745-5298")),
person(
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 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
Expand All @@ -16,9 +31,10 @@ RoxygenNote: 7.1.1
Imports:
htmltools (>= 0.5.0),
shiny (>= 1.5.0),
cli,
stringr
Suggests:
Suggests:
spelling,
testthat
Depends:
R (>= 2.10)
Language: en-US
23 changes: 2 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
MIT License

Copyright (c) 2020 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.
YEAR: 2021
COPYRIGHT HOLDER: David Ruvolo
53 changes: 53 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 26 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +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))

# 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 "".
* 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
Expand All @@ -16,13 +35,13 @@

# 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
Expand All @@ -36,4 +55,4 @@
## 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`
* Added Package management directory `dev`. Convert Icons using `dev/dev.R`
13 changes: 8 additions & 5 deletions R/find_icon.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#' 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
#'
#' @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
9 changes: 6 additions & 3 deletions R/launch_gallery.R
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down
36 changes: 22 additions & 14 deletions R/rheroicon.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
#' rheroicon
#' 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 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`.
#' 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 an icon name
#' @param type choose icon style "solid" or "outline" (default: "outline")
#' @param classnames a string containing one or more CSS classes
#' @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 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.
#'
#' @examples
#' rheroicon(name = "academic_cap")
#' rheroicon(name = "academic_cap", type = "solid")
#' rheroicon(name = "academic_cap", classnames = "education-icons")
#'
#' @return Returns an SVG string
#'
#' @references
#' \url{https://heroicons.com}
#' \url{https://github.com/tailwindlabs/heroicons}
#' \url{https://davidruvolo.shinyapps.io/rheroicons-demo/}
#'
#' @export
rheroicon <- function(name, type = "outline", classnames = NULL) {
Expand All @@ -28,16 +35,17 @@ 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
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) {
warning("Icon type is invalid. Use 'outline' or 'solid'")
}

# 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
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit b795c76

Please sign in to comment.