Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added virtual select feedback #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pvictor
Copy link

@pvictor pvictor commented Oct 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant