【问题标题】:Shiny `showNotification` no longer working with `dashboardthemes`闪亮的`showNotification`不再与`dashboardthemes`一起使用
【发布时间】:2020-12-07 19:46:29
【问题描述】:

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

下面 2 个闪亮的应用程序,第一个看起来工作正常,第二个显示问题。

有人知道如何管理/解决这个问题吗?

注意: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")
    })
  }
)

【问题讨论】:

    标签: css r shiny shinydashboard


    【解决方案1】:

    问题是仪表板主题包为所有通知设置了单一背景颜色,即使它们具有不同的状态。 我已经在最新的 v1.1.2 版本的包中修复了这个问题,现在可以在 GitHub 上找到。在 CRAN 上发布需要几天时间。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 2020-10-25
    • 2018-08-14
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    相关资源
    最近更新 更多