R/bootstrap_slider_colour.R

Defines functions bootstrap_slider_colour

Documented in bootstrap_slider_colour

#' Changes bootstrap slider input color individually.
#' @description Note there is currently no solution to change all of them simultaneously
#' Put this function in a for loop for the range of slider_index arguments
#' to make this work
#' 
#' @param slider_index A numeric of length one 
#' @param colour A character of length one that takes names, rgb or rgba character vectors of rthe slider color
#' 
#' @return A HTML head element incliuding the necessary css.
#' @examples
#' bootstrap_slider_colour()
#' bootstrap_slider_colour(colour='blue')
#' @import htmltools
#' @import shiny
#' @export
bootstrap_slider_colour <- function(slider_index=0, colour='mediumseagreen') {
  y <- 
    shiny::tags$head(
    shiny::tags$style(
      htmltools::HTML(paste0('.js-irs-',slider_index,'  .irs-single, .js-irs-',slider_index,' .irs-bar-edge, .js-irs-',slider_index,' .irs-bar {
                                                    background: ',colour,';
                                                    border-top: 1px solid ',colour,' ;
                                                    border-bottom: 1px solid ',colour,' ;}
  
                              /* changes the colour of the number tags */
                             .irs-from, .irs-to, .irs-single { background: ',colour,' }'))))
  
  return(y)
}
aarong1/RshinyHelpers documentation built on June 15, 2022, 4:52 a.m.