rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
894 stars 298 forks source link

Added a new optional argument, called `headerText` to the `dropdownMenu()` function #207

Closed bborgesr closed 7 years ago

bborgesr commented 7 years ago

If provided by the user, this text (instead of the default) will be shown on the header of the menu (only visible when the menu is expanded).

Closes #165.

Example app (covers 3 scenarios):

library(shiny)
library(shinydashboard)

messages <- list(
  messageItem("Support", "This is the content of a message.", time = "5 mins"),
  messageItem("Support", "This is the content of another message.", time = "2 hours"),
  messageItem("New User", "Can I get some help?", time = "Today" )
)

notifications <- list(
  notificationItem(icon = icon("users"), status = "info", "5 new members joined today"),
  notificationItem(icon = icon("warning"), status = "danger", "Resource usage near limit."),
  notificationItem(icon = icon("shopping-cart", lib = "glyphicon"),  status = "success", "25 sales made"),
  notificationItem(icon = icon("user", lib = "glyphicon"), status = "danger", "You changed your username")
)

tasks <- list(
  taskItem(value = 20, color = "aqua", "Refactor code"),
  taskItem(value = 40, color = "green", "Design new layout"),
  taskItem(value = 60, color = "yellow", "Another task"),
  taskItem(value = 80, color = "red", "Write documentation")
)

ui <- dashboardPage(
  dashboardHeader(
    title = "Dashboard Demo",

    # Keeps default text
    dropdownMenu(type = "messages", badgeStatus = "success", .list = messages),

    # Overrides default text
    dropdownMenu(type = "notifications", badgeStatus = "warning",
      headerText = "These are important notifications!",
      .list = notifications
    ),

    # Overrides default text in a more complicated way
    dropdownMenu(type = "tasks", badgeStatus = "danger",
      .list = tasks, headerText = paste("Tens", length(tasks), "tarefas.")
    )
  ),
  dashboardSidebar(),
  dashboardBody()
)

server <- function(input, output, session) {}
shinyApp(ui, server)
federicomarini commented 7 years ago

Great, thank you @bborgesr and @wch !!