闪亮的showshowification不再与dashboardthemes一起使用

时间:2020-08-18 15:22:36

标签: css r shiny shinydashboard

加载dashboardthemes后,引导通知样式似乎不再起作用(它们都显示为灰色,即默认值)。

在2 Shiny应用程序下面,第一个似乎运行正常,第二个显示问题。

有人知道如何管理/修复此问题吗?

注意:dashboardthemes似乎对按钮有相同的影响,请参见this SO post

require(shiny)
require(shinydashboardPlus)
require(dashboardthemes)

# APP #1: WORKING
shinyApp(
  ui = fluidPage(
    actionButton("show_default", "Show Default"),
    actionButton("show_message", "Show Message"),
    actionButton("show_warning", "Show Warning"),
    actionButton("show_error", "Show Error")
  ),
  
  
  server = function(input, output) {
    
    observeEvent(input$show_default, {
      showNotification("This is a notification.")
    })
    
    observeEvent(input$show_message, {
      showNotification("This is a notification.", type = "message")
    })
    
    observeEvent(input$show_warning, {
      showNotification("This is a notification.", type = "warning")
    })
    
    observeEvent(input$show_error, {
      showNotification("This is a notification.", type = "error")
    })
  }
)


# APP #2: WITH STYLING ISSUE
shinyApp(
  ui = dashboardPagePlus(
    title = "hello",
    
    header = dashboardHeaderPlus(title = "hello"),
    
    sidebar = dashboardSidebar(),
    
    body = dashboardBody(
      shinyDashboardThemes(
        theme = "grey_light"
      ),
      
      fluidPage(
        actionButton("show_default", "Show Default"),
        actionButton("show_message", "Show Message"),
        actionButton("show_warning", "Show Warning"),
        actionButton("show_error", "Show Error")
      )
    )
  ),
  
  server = function(input, output) {
    
    observeEvent(input$show_default, {
      showNotification("This is a notification.")
    })
    
    observeEvent(input$show_message, {
      showNotification("This is a notification.", type = "message")
    })
    
    observeEvent(input$show_warning, {
      showNotification("This is a notification.", type = "warning")
    })
    
    observeEvent(input$show_error, {
      showNotification("This is a notification.", type = "error")
    })
  }
)

1 个答案:

答案 0 :(得分:2)

问题在于,dashboardthemes程序包为所有通知设置了单一背景色,即使它们的状态不同。 我已经在该软件包的最新v1.1.2版本中修复了该问题,该版本现在可以在GitHub上找到。在CRAN上发布需要几天的时间。