#' THe value box UI for bs4dash
#'
#' The value box creates a server-side function to be handled
#' by conditional logic at later dates
#'
#' @param id is unique ID associated with the button for the UI namespace
#'
#' @importFrom shiny uiOutput
#'
#' @export
vbox_ui <- function(id) {
ns <- NS(id)
uiOutput(ns('vbox'))
}
#' THe value box server for bs4dash
#'
#' The value box creates a server-side function to be handled
#' by conditional logic at later dates for the parameters
#'
#'
#' @param input list of inputs used in the shiny application session
#' @param output list of outputs used the shiny application session
#' @param session The shiny app session object
#' @param value The value of the valuebox
#' @param subtitle The subtitle of the valuebox
#' @param icon Icon function to pass as a reactive based on chart needs
#' @param color Default color settings
#' @param container The HTML wrapper function for the subtitle
#' @param end_text The text used in the footer of the valuebox
#' @param width Width of the value box
#'
#' @importFrom bs4Dash bs4ValueBox
#' @importFrom shiny renderText
#' @importFrom shiny req
#'
#' @export
vbox_server <- function(input,
output,
session,
value,
subtitle,
icon = "user-cog",
color = "info",
container = h4,
end_text = NULL,
width = 12) {
session$ns->ns
#Local variable declaration
val <- to_reactive(value)
subt <- to_reactive(subtitle)
ic <- to_reactive(icon)
color_<-to_reactive(color)
width<-to_reactive(width)
end_text<-to_reactive(end_text)
#Dynamic textOutput
output[["value"]] <- renderText({
req(val())
val()
})
output[['vbox']] <- renderUI({
req(val(), color_())
bs4Dash::bs4ValueBox(
value = textOutput(ns("value"), container = container),
subtitle = subt(),
icon = shiny::icon(ic()),
color = color_(),
width = width(),
footer = end_text()
)
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.