Skip to content

Commit

Permalink
chore: simplify slider render
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhav committed Oct 25, 2024
1 parent 5332e0b commit 75f1321
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions R/toggleable_slider.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,18 @@ toggle_slider_server <- function(id, initial_state, print = FALSE, ...) {

output$slider_view <- renderUI({
req(slider_update_state())
args <- list(
inputId = session$ns("slider"),
label = NULL,
min = slider_update_state()$min,
max = slider_update_state()$max,
value = slider_update_state()$value,
step = slider_update_state()$step,
...
)
if (length(seq(slider_update_state()$min, slider_update_state()$max)) < 10) {
args$ticks <- TRUE
html <- do.call("sliderInput", args)
} else {
html <- do.call("sliderInput", args)
}
tags$div(
class = "teal-goshawk toggle-slider-container",
html,
sliderInput(
inputId = session$ns("slider"),
label = NULL,
min = slider_update_state()$min,
max = slider_update_state()$max,
value = slider_update_state()$value,
step = slider_update_state()$step,
ticks = TRUE,
...
),
tags$script(HTML(sprintf(
'
$(".teal-goshawk.toggle-slider-container #%s").ready(function () {
Expand Down

0 comments on commit 75f1321

Please sign in to comment.