dreamRs / shinyWidgets
Showing 1 of 1 files from the diff.

@@ -21,7 +21,7 @@
Loading
21 21
#'
22 22
#'
23 23
#' @importFrom shiny restoreInput
24 -
#' @importFrom htmltools tags validateCssUnit
24 +
#' @importFrom htmltools tags validateCssUnit attachDependencies findDependencies
25 25
#'
26 26
#' @export
27 27
#'
@@ -48,17 +48,35 @@
Loading
48 48
#' }
49 49
#' shinyApp(ui, server)
50 50
#' }
51 -
switchInput <- function(inputId, label = NULL, value = FALSE, onLabel = 'ON', offLabel = 'OFF',
52 -
                        onStatus = NULL, offStatus = NULL, size = "default", labelWidth = "auto",
53 -
                        handleWidth = "auto", disabled = FALSE, inline = FALSE, width = NULL) {
51 +
switchInput <- function(inputId,
52 +
                        label = NULL,
53 +
                        value = FALSE,
54 +
                        onLabel = "ON",
55 +
                        offLabel = "OFF",
56 +
                        onStatus = NULL,
57 +
                        offStatus = NULL,
58 +
                        size = "default",
59 +
                        labelWidth = "auto",
60 +
                        handleWidth = "auto",
61 +
                        disabled = FALSE,
62 +
                        inline = FALSE,
63 +
                        width = NULL) {
54 64
  value <- shiny::restoreInput(id = inputId, default = value)
55 65
  size <- match.arg(arg = size, choices = c('default', 'mini', 'small', 'normal', 'large'))
56 66
  switchProps <- dropNulls(
57 67
    list(
58 -
      id = inputId, type = "checkbox", class = "sw-switchInput", `data-input-id` = inputId,
59 -
      `data-on-text` = onLabel, `data-off-text` = offLabel, `data-label-text` = label,
60 -
      `data-on-color` = onStatus, `data-off-color` = offStatus, #`data-state` = value,
61 -
      `data-label-width` = labelWidth, `data-handle-width` = handleWidth,
68 +
      id = inputId,
69 +
      type = "checkbox",
70 +
      class = "sw-switchInput",
71 +
      `data-input-id` = inputId,
72 +
      `data-on-text` = onLabel,
73 +
      `data-off-text` = offLabel,
74 +
      `data-label-text` = label,
75 +
      `data-on-color` = onStatus,
76 +
      `data-off-color` = offStatus,
77 +
      #`data-state` = value,
78 +
      `data-label-width` = labelWidth,
79 +
      `data-handle-width` = handleWidth,
62 80
      `disabled` =  if (!disabled) NULL else disabled,
63 81
      `data-size` = if (size == "default") "" else size
64 82
    )
@@ -80,7 +98,11 @@
Loading
80 98
    style = if (!is.null(width)) paste0("width: ", htmltools::validateCssUnit(width), ";"),
81 99
    inputTag
82 100
  )
83 -
  # Dep
101 +
  # Dependencies
102 +
  switchInputTag <- attachDependencies(
103 +
    switchInputTag,
104 +
    htmltools::findDependencies(tagList(label, offLabel, onLabel))
105 +
  )
84 106
  attachShinyWidgetsDep(switchInputTag, "bsswitch")
85 107
}
86 108
Files Coverage
R 74.89%
Project Totals (51 files) 74.89%
Notifications are pending CI completion. Periodically Codecov will check the CI state, when complete notifications will be submitted. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading