shinyFeedback icon indicating copy to clipboard operation
shinyFeedback copied to clipboard

added virtual select feedback

Open pvictor opened this issue 4 months ago • 0 comments

Hello !

I've added support for shinyWidgets::virtualSelectInput().

To test it you can use:

library(shiny)
library(shinyWidgets)
library(shinyFeedback)

ui <- fluidPage(
  useShinyFeedback(), 
  fluidRow(
    column(
      width = 6,
      virtualSelectInput(
        inputId = "virtual_select_input",
        label = "Select:",
        choices = c("Nothing", "Error", "Warning", "Success")
      ),
      verbatimTextOutput("virtual_select_res")
    ),
    column(
      width = 6,
      pickerInput(
        inputId = "picker_input",
        label = "Select:",
        choices = c("Nothing", "Error", "Warning", "Success")
      ),
      verbatimTextOutput("picker_res")
    )
  )
)

server <- function(input, output, session) {
  
  observeEvent(input$virtual_select_input, {
    if (input$virtual_select_input == "Error") {
      showFeedbackDanger("virtual_select_input", text = "Error !", icon = icon("exclamation-circle"))
    } else if (input$virtual_select_input == "Warning") {
      showFeedbackWarning("virtual_select_input", text = "Warning !", icon = icon("exclamation-triangle"))
    } else if (input$virtual_select_input == "Success") {
      showFeedbackSuccess("virtual_select_input", text = "Success !", icon = icon("check-circle"))
    } else {
      hideFeedback("virtual_select_input")
    }
  })
  
  observeEvent(input$picker_input, {
    if (input$picker_input == "Error") {
      showFeedbackDanger("picker_input", text = "Error !", icon = icon("exclamation-circle"))
    } else if (input$picker_input == "Warning") {
      showFeedbackWarning("picker_input", text = "Warning !", icon = icon("exclamation-triangle"))
    } else if (input$picker_input == "Success") {
      showFeedbackSuccess("picker_input", text = "Success !", icon = icon("check-circle"))
    } else {
      hideFeedback("picker_input")
    }
  })
  
  output$virtual_select_res <- renderText({
    input$virtual_select_input
  })
  
  output$picker_res <- renderText({
    input$picker_input
  })
}

shinyApp(ui, server)

Which render as :

image

Let me know if it's good for you

Victor

pvictor avatar Oct 25 '24 12:10 pvictor