Skip to content

Commit

Permalink
prepare for cran
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 26, 2020
1 parent 5f2b813 commit 2522d49
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 30 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinybusy
Title: Busy Indicator for 'Shiny' Applications
Version: 0.2.1.900
Version: 0.2.2
Authors@R: c(person("Fanny", "Meyer", role = "aut"),
person("Victor", "Perrier", email = "[email protected]", role = c("aut", "cre")),
person("Silex Technologies", comment = "https://www.silex-ip.com", role = "fnd"))
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# shinybusy 0.2.2

* Fixed a bug in `spin_kit()` ([#12](https://github.com/dreamRs/shinybusy/issues/12)).



# shinybusy 0.2.1

* New function `add_loading_state()` to add loading state to several outputs.
Expand Down
67 changes: 47 additions & 20 deletions R/busy-gif.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,40 @@
#' @description Make a GIF play when server is busy and stop when idle.
#'
#' @param src Path to the GIF, an URL or a file in www/ folder.
#' @param timeout Number of milliseconds after the server is busy to display the Gif
#' @param position Where to display the spinner: \code{'top-right'}, \code{'top-left'}, \code{'bottom-right'},
#' @param timeout Number of milliseconds after the server is busy to display the GIF.
#' @param position Where to display the GIF: \code{'top-right'}, \code{'top-left'}, \code{'bottom-right'},
#' \code{'bottom-left'}, \code{'full-page'}.
#' @param margins Distance from margins, a vector of length two, where first element is distance from top/bottom,
#' second element distance from right/left.
#' @param overlay_color Background color for the overlay if \code{position = "full-page"}.
#' @param overlay_css Additional CSS for the overlay, for example \code{"z-index: 1000;"} to make it appear of everything.
#' @param overlay_css Additional CSS for the overlay, for example \code{"z-index: 1000;"} to make it appear above everything.
#' @param height,width Height and width of the spinner, default to \code{'50px'} for both, must be specified.
#'
#' @export
#'
#' @return An HTML tag that should be used in UI.
#'
#' @importFrom htmltools validateCssUnit attachDependencies tags
#' @importFrom jsonlite toJSON
#'
#' @example examples/add_busy_gif.R
add_busy_gif <- function(src, timeout = 100,
position = c("top-right", "top-left", "bottom-right", "bottom-left", "full-page", "free"),
margins = c(10, 10), overlay_color = "rgba(0, 0, 0, 0.5)", overlay_css = NULL,
height = "50px", width = "50px") {
margins = c(10, 10),
overlay_color = "rgba(0, 0, 0, 0.5)",
overlay_css = NULL,
height = "50px",
width = "50px") {
busy_gif(
src = src, timeout = timeout,
position = position, margins = margins,
overlay_color = overlay_color, overlay_css = overlay_css,
height = height, width = width, type = "auto"
src = src,
timeout = timeout,
position = position,
margins = margins,
overlay_color = overlay_color,
overlay_css = overlay_css,
height = height,
width = width,
type = "auto"
)
}

Expand All @@ -38,18 +48,28 @@ add_busy_gif <- function(src, timeout = 100,
#'
#' @export
#'
#' @return An HTML tag that should be used in UI.
#'
#' @name manual-gif
#'
#' @example examples/use_busy_gif.R
use_busy_gif <- function(src, timeout = 100,
position = c("top-right", "top-left", "bottom-right", "bottom-left", "full-page", "free"),
margins = c(10, 10), overlay_color = "rgba(0, 0, 0, 0.5)", overlay_css = NULL,
height = "50px", width = "50px") {
margins = c(10, 10),
overlay_color = "rgba(0, 0, 0, 0.5)",
overlay_css = NULL,
height = "50px",
width = "50px") {
busy_gif(
src = src, timeout = timeout,
position = position, margins = margins,
overlay_color = overlay_color, overlay_css = overlay_css,
height = height, width = width, type = "manual"
src = src,
timeout = timeout,
position = position,
margins = margins,
overlay_color = overlay_color,
overlay_css = overlay_css,
height = height,
width = width,
type = "manual"
)
}

Expand Down Expand Up @@ -77,10 +97,15 @@ stop_gif <- function(session = shiny::getDefaultReactiveDomain()) {
}


busy_gif <- function(src, timeout = 100,
busy_gif <- function(src,
timeout = 100,
position = c("top-right", "top-left", "bottom-right", "bottom-left", "full-page", "free"),
margins = c(10, 10), overlay_color = "rgba(0, 0, 0, 0.5)", overlay_css = NULL,
height = "50px", width = "50px", type = "auto") {
margins = c(10, 10),
overlay_color = "rgba(0, 0, 0, 0.5)",
overlay_css = NULL,
height = "50px",
width = "50px",
type = "auto") {
stopifnot(length(margins) == 2)
marg1 <- validateCssUnit(margins[1])
marg2 <- validateCssUnit(margins[2])
Expand Down Expand Up @@ -120,8 +145,10 @@ busy_gif <- function(src, timeout = 100,
type = "application/json",
`data-for` = "shinybusy",
toJSON(list(
timeout = timeout, mode = "gif",
position = position, type = type
timeout = timeout,
mode = "gif",
position = position,
type = type
), auto_unbox = TRUE, json_verbatim = TRUE)
)
)
Expand Down
9 changes: 6 additions & 3 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#'
html_dependency_spinkit <- function() {
htmlDependency(
name = "spinkit", version = "0.1.0",
name = "spinkit",
version = "0.1.0",
src = list(href = "shinybusy", file = "assets"),
package = "shinybusy",
stylesheet = "spinkit/spin.min.css"
Expand All @@ -22,7 +23,8 @@ html_dependency_spinkit <- function() {
#' @rdname html-dependencies
html_dependency_epic <- function() {
htmlDependency(
name = "epic-spinners", version = "1.1.0",
name = "epic-spinners",
version = "1.1.0",
src = list(href = "shinybusy", file = "assets"),
package = "shinybusy",
stylesheet = "epic-spinners/epic-spinners.css"
Expand All @@ -46,7 +48,8 @@ html_dependency_shinybusy <- function() {
#' @rdname html-dependencies
html_dependency_freezeframe <- function() {
htmlDependency(
name = "freezeframe", version = "3.0.10",
name = "freezeframe",
version = "3.0.10",
src = list(href = "shinybusy", file = "assets"),
package = "shinybusy",
script = "freezeframe/freezeframe.pkgd.min.js",
Expand Down
9 changes: 6 additions & 3 deletions man/add_busy_gif.Rd

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

9 changes: 6 additions & 3 deletions man/manual-gif.Rd

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

0 comments on commit 2522d49

Please sign in to comment.