Skip to content

Commit

Permalink
manage nouislider.js with packer
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 9, 2022
1 parent fd23d25 commit f555d46
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 453 deletions.
8 changes: 3 additions & 5 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,9 @@ html_dependency_airdatepicker <- function() {
html_dependency_nouislider <- function() {
htmlDependency(
name = "nouislider",
version = "11.0.3",
package = "shinyWidgets",
src = c(href = "shinyWidgets/nouislider", file = "assets/nouislider"),
script = c("nouislider.min.js", "wNumb.js"),
stylesheet = "nouislider.min.css"
version = "15.6.1",
src = c(file = system.file("packer", package = "shinyWidgets")),
script = "nouislider.js"
)
}

Expand Down
56 changes: 4 additions & 52 deletions R/input-noUiSlider.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,55 +44,7 @@
#' @importFrom htmltools tags validateCssUnit
#' @importFrom jsonlite toJSON
#'
#' @examples
#' if (interactive()) {
#'
#' ### examples ----
#'
#' # see ?demoNoUiSlider
#' demoNoUiSlider("more")
#'
#'
#' ### basic usage ----
#'
#' library( shiny )
#' library( shinyWidgets )
#'
#'
#' ui <- fluidPage(
#'
#' tags$br(),
#'
#' noUiSliderInput(
#' inputId = "noui1",
#' min = 0, max = 100,
#' value = 20
#' ),
#' verbatimTextOutput(outputId = "res1"),
#'
#' tags$br(),
#'
#' noUiSliderInput(
#' inputId = "noui2", label = "Slider vertical:",
#' min = 0, max = 1000, step = 50,
#' value = c(100, 400), margin = 100,
#' orientation = "vertical",
#' width = "100px", height = "300px"
#' ),
#' verbatimTextOutput(outputId = "res2")
#'
#' )
#'
#' server <- function(input, output, session) {
#'
#' output$res1 <- renderPrint(input$noui1)
#' output$res2 <- renderPrint(input$noui2)
#'
#' }
#'
#' shinyApp(ui, server)
#'
#' }
#' @example examples/noUiSlider.R
noUiSliderInput <- function(inputId, label = NULL, min, max, value,
step = NULL, tooltips = TRUE,
connect = TRUE, padding = 0,
Expand Down Expand Up @@ -129,7 +81,7 @@ noUiSliderInput <- function(inputId, label = NULL, min, max, value,
behaviour = behaviour,
format = format
))
noUiTag <- tags$div(
tags$div(
class = "form-group shiny-input-container",
class = if (inline) "shiny-input-container-inline",
style = if (!is.null(width)) paste0("width: ", validateCssUnit(width), ";"),
Expand All @@ -156,9 +108,9 @@ noUiSliderInput <- function(inputId, label = NULL, min, max, value,
`data-for` = inputId,
jsonlite::toJSON(noUiProps, auto_unbox = TRUE, json_verbatim = TRUE)
)
)
),
html_dependency_nouislider()
)
attachShinyWidgetsDep(noUiTag, "nouislider")
}


Expand Down
34 changes: 34 additions & 0 deletions examples/noUiSlider.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library(shiny)
library(shinyWidgets)

ui <- fluidPage(
tags$h2("noUiSliderInput example"),

noUiSliderInput(
inputId = "noui1",
min = 0, max = 100,
value = 20
),
verbatimTextOutput(outputId = "res1"),

tags$br(),

noUiSliderInput(
inputId = "noui2", label = "Slider vertical:",
min = 0, max = 1000, step = 50,
value = c(100, 400), margin = 100,
orientation = "vertical",
width = "100px", height = "300px"
),
verbatimTextOutput(outputId = "res2")
)

server <- function(input, output, session) {

output$res1 <- renderPrint(input$noui1)
output$res2 <- renderPrint(input$noui2)

}

if (interactive())
shinyApp(ui, server)
1 change: 0 additions & 1 deletion inst/assets/nouislider/nouislider.min.css

This file was deleted.

3 changes: 0 additions & 3 deletions inst/assets/nouislider/nouislider.min.js

This file was deleted.

Loading

0 comments on commit f555d46

Please sign in to comment.