Skip to content

Commit

Permalink
deprecated knob and switch input
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Oct 30, 2024
1 parent 6361c7c commit 65c8494
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyWidgets
Title: Custom Inputs Widgets for Shiny
Version: 0.8.7
Version: 0.8.7.9000
Authors@R: c(
person("Victor", "Perrier", email = "victor.perrier@dreamrs.fr", role = c("aut", "cre", "cph")),
person("Fanny", "Meyer", role = "aut"),
Expand Down
5 changes: 5 additions & 0 deletions R/input-knob.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#' Knob Input
#'
#' @description
#' \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
#' The JavaScript library used by this widget is no longer actively maintained.
#'
#'
#' @param inputId The \code{input} slot that will be used to access the value.
#' @param label Display label for the control, or NULL for no label.
#' @param value Initial value.
Expand Down
42 changes: 24 additions & 18 deletions R/input-pretty.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,22 @@ prettyToggle <- function(inputId,
inline = FALSE,
width = NULL) {
value <- shiny::restoreInput(id = inputId, default = value)
status_on <- match.arg(status_on, c("default", "primary", "success",
"info", "danger", "warning"))
status_off <- match.arg(status_off, c("default", "primary",
"success", "info", "danger", "warning"))
status_on <- match.arg(
status_on,
c("default", "primary", "success", "info", "danger", "warning")
)
status_off <- match.arg(
status_off,
c("default", "primary", "success", "info", "danger", "warning")
)
shape <- match.arg(shape)
icon_on <- tag_add_class_icon(icon_on)
icon_off <- tag_add_class_icon(icon_off)
if (!is.null(animation))
animation <- match.arg(animation, c("smooth", "jelly", "tada",
"rotate", "pulse"))
if (!is.null(animation)) {
animation <- match.arg(
animation, c("smooth", "jelly", "tada", "rotate", "pulse")
)
}
inputTag <- tags$input(id = inputId, type = "checkbox")
if (!is.null(value) && value)
inputTag$attribs$checked <- "checked"
Expand All @@ -155,23 +161,23 @@ prettyToggle <- function(inputId,
style = if (inline) "display: inline-block; margin-right: 10px;",
tags$div(
class = "pretty p-toggle", inputTag,
class = if(is.null(icon_on) & is.null(icon_off)) "p-default",
class = if(plain) "p-plain",
class = if(bigger) "p-bigger",
class = if(shape!="square") paste0("p-", shape),
class = if(fill) "p-fill", class=if(thick) "p-thick",
class = if(!is.null(icon_on) | !is.null(icon_off)) "p-icon",
class = if(!is.null(animation)) paste0("p-", animation),
class = if (is.null(icon_on) & is.null(icon_off)) "p-default",
class = if (plain) "p-plain",
class = if (bigger) "p-bigger",
class = if (shape != "square") paste0("p-", shape),
class = if (fill) "p-fill", class = if (thick) "p-thick",
class = if (!is.null(icon_on) | !is.null(icon_off)) "p-icon",
class = if (!is.null(animation)) paste0("p-", animation),
tags$div(
class = "state p-on",
class = if(status_on != "default") paste0("p-", status_on, if(outline)"-o"),
if(!is.null(icon_on)) icon_on,
class = if (status_on != "default") paste0("p-", status_on, if (outline) "-o"),
if (!is.null(icon_on)) icon_on,
tags$label(tags$span(label_on))
),
tags$div(
class = "state p-off",
class = if(status_off != "default") paste0("p-", status_off, if(outline)"-o"),
if(!is.null(icon_off)) icon_off,
class = if (status_off != "default") paste0("p-", status_off, if (outline) "-o"),
if (!is.null(icon_off)) icon_off,
tags$label(tags$span(label_off))
)
)
Expand Down
3 changes: 2 additions & 1 deletion R/input-switch.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @title Bootstrap Switch Input Control
#'
#' @description
#' Create a toggle switch.
#' \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
#' The JavaScript library used by this widget is no longer actively maintained.
#'
#' @param inputId The `input` slot that will be used to access the value.
#' @param label Display a text in the center of the switch.
Expand Down
21 changes: 21 additions & 0 deletions man/figures/lifecycle-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion man/knobInput.Rd

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

3 changes: 2 additions & 1 deletion man/switchInput.Rd

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

0 comments on commit 65c8494

Please sign in to comment.