CommandBar
- Source:R/components.R
, R/documentation.R
, R/examples.R
+ Source: R/components.R
, R/documentation.R
, R/examples.R
, and 1 more
CommandBar.Rd
Usage
-CommandBar(...)
CommandBar(...)
+
+CommandBar.shinyInput(inputId, ..., itemValueGetter = function(el) el$key)
@@ -163,6 +165,14 @@ Arguments
Arguments
Value
@@ -203,69 +213,91 @@ Exampleslibrary(shiny)
library(shiny.fluent)
-items <- list(
+items <- function(ns) {
list(
- key = "newItem",
- text = "New",
- cacheKey = "myCacheKey",
- iconProps = list(iconName = "Add"),
- subMenuProps = list(
- items = list(
- list(
- key = "emailMessage",
- text = "Email message",
- iconProps = list(iconName = "Mail")
- ),
- list(
- key = "calendarEvent",
- text = "Calendar event",
- iconProps = list(iconName = "Calendar")
+ CommandBarItem(
+ key = ns("newItem"),
+ text = "New",
+ cacheKey = "myCacheKey",
+ split = TRUE,
+ iconProps = list(iconName = "Add"),
+ subMenuProps = list(
+ items = list(
+ CommandBarItem(
+ key = ns("emailMessage"),
+ text = "Email message",
+ iconProps = list(iconName = "Mail")
+ ),
+ CommandBarItem(
+ key = ns("calendarEvent"),
+ text = "Calendar event",
+ iconProps = list(iconName = "Calendar")
+ )
)
)
+ ),
+ CommandBarItem(
+ key = ns("upload"),
+ text = "Upload",
+ iconProps = list(iconName = "Upload")
+ ),
+ CommandBarItem(
+ key = ns("share"),
+ text = "Share",
+ iconProps = list(iconName = "Share")
+ ),
+ CommandBarItem(
+ key = ns("download"),
+ text = "Download",
+ iconProps = list(iconName = "Download")
)
- ),
- list(
- key = "upload",
- text = "Upload",
- iconProps = list(iconName = "Upload")
- ),
- list(
- key = "share",
- text = "Share",
- iconProps = list(iconName = "Share")
- ),
- list(
- key = "download",
- text = "Download",
- iconProps = list(iconName = "Download")
)
-)
+}
-farItems <- list(
- list(
- key = "tile",
- text = "Grid view",
- ariaLabel = "Grid view",
- iconOnly = TRUE,
- iconProps = list(iconName = "Tiles")
- ),
+farItems <- function(ns) {
list(
- key = "info",
- text = "Info",
- ariaLabel = "Info",
- iconOnly = TRUE,
- iconProps = list(iconName = "Info")
+ CommandBarItem(
+ key = ns("tile"),
+ text = "Grid view",
+ ariaLabel = "Grid view",
+ iconOnly = TRUE,
+ iconProps = list(iconName = "Tiles")
+ ),
+ CommandBarItem(
+ key = ns("info"),
+ text = "Info",
+ ariaLabel = "Info",
+ iconOnly = TRUE,
+ iconProps = list(iconName = "Info")
+ )
)
-)
-
+}
ui <- function(id) {
ns <- NS(id)
- CommandBar(items = items, farItems = farItems)
+ tagList(
+ CommandBar(
+ items = items(ns),
+ farItems = farItems(ns)
+ ),
+ textOutput(ns("commandBarItems")),
+ CommandBar.shinyInput(
+ inputId = ns("commandBar"),
+ items = items(identity),
+ farItems = farItems(identity)
+ ),
+ textOutput(ns("commandBar"))
+ )
}
server <- function(id) {
- moduleServer(id, function(input, output, session) { })
+ moduleServer(id, function(input, output, session) {
+ commandBarItemClicked <- reactiveVal()
+ observeEvent(input$newItem, commandBarItemClicked("newItem clicked"))
+ observeEvent(input$upload, commandBarItemClicked("upload clicked"))
+ output$commandBarItems <- renderText(commandBarItemClicked())
+ output$commandBar <- renderText(input$commandBar)
+ })
}
if (interactive()) {
diff --git a/reference/CommandBarItem.html b/reference/CommandBarItem.html
index 955a8053..c54e42be 100644
--- a/reference/CommandBarItem.html
+++ b/reference/CommandBarItem.html
@@ -1,5 +1,5 @@
-Command bar item — CommandBarItem • shiny.fluent Command bar item — CommandBarItem • shiny.fluent
library(shiny)
library(shiny.fluent)
-items <- list(
+items <- function(ns) {
list(
- key = "newItem",
- text = "New",
- cacheKey = "myCacheKey",
- iconProps = list(iconName = "Add"),
- subMenuProps = list(
- items = list(
- list(
- key = "emailMessage",
- text = "Email message",
- iconProps = list(iconName = "Mail")
- ),
- list(
- key = "calendarEvent",
- text = "Calendar event",
- iconProps = list(iconName = "Calendar")
+ CommandBarItem(
+ key = ns("newItem"),
+ text = "New",
+ cacheKey = "myCacheKey",
+ split = TRUE,
+ iconProps = list(iconName = "Add"),
+ subMenuProps = list(
+ items = list(
+ CommandBarItem(
+ key = ns("emailMessage"),
+ text = "Email message",
+ iconProps = list(iconName = "Mail")
+ ),
+ CommandBarItem(
+ key = ns("calendarEvent"),
+ text = "Calendar event",
+ iconProps = list(iconName = "Calendar")
+ )
)
)
+ ),
+ CommandBarItem(
+ key = ns("upload"),
+ text = "Upload",
+ iconProps = list(iconName = "Upload")
+ ),
+ CommandBarItem(
+ key = ns("share"),
+ text = "Share",
+ iconProps = list(iconName = "Share")
+ ),
+ CommandBarItem(
+ key = ns("download"),
+ text = "Download",
+ iconProps = list(iconName = "Download")
)
- ),
- list(
- key = "upload",
- text = "Upload",
- iconProps = list(iconName = "Upload")
- ),
- list(
- key = "share",
- text = "Share",
- iconProps = list(iconName = "Share")
- ),
- list(
- key = "download",
- text = "Download",
- iconProps = list(iconName = "Download")
)
-)
+}
-farItems <- list(
- list(
- key = "tile",
- text = "Grid view",
- ariaLabel = "Grid view",
- iconOnly = TRUE,
- iconProps = list(iconName = "Tiles")
- ),
+farItems <- function(ns) {
list(
- key = "info",
- text = "Info",
- ariaLabel = "Info",
- iconOnly = TRUE,
- iconProps = list(iconName = "Info")
+ CommandBarItem(
+ key = ns("tile"),
+ text = "Grid view",
+ ariaLabel = "Grid view",
+ iconOnly = TRUE,
+ iconProps = list(iconName = "Tiles")
+ ),
+ CommandBarItem(
+ key = ns("info"),
+ text = "Info",
+ ariaLabel = "Info",
+ iconOnly = TRUE,
+ iconProps = list(iconName = "Info")
+ )
)
-)
-
+}
ui <- function(id) {
ns <- NS(id)
- CommandBar(items = items, farItems = farItems)
+ tagList(
+ CommandBar(
+ items = items(ns),
+ farItems = farItems(ns)
+ ),
+ textOutput(ns("commandBarItems")),
+ CommandBar.shinyInput(
+ inputId = ns("commandBar"),
+ items = items(identity),
+ farItems = farItems(identity)
+ ),
+ textOutput(ns("commandBar"))
+ )
}
server <- function(id) {
- moduleServer(id, function(input, output, session) { })
+ moduleServer(id, function(input, output, session) {
+ commandBarItemClicked <- reactiveVal()
+ observeEvent(input$newItem, commandBarItemClicked("newItem clicked"))
+ observeEvent(input$upload, commandBarItemClicked("upload clicked"))
+ output$commandBarItems <- renderText(commandBarItemClicked())
+ output$commandBar <- renderText(input$commandBar)
+ })
}
if (interactive()) {
diff --git a/reference/CommandBarItem.html b/reference/CommandBarItem.html
index 955a8053..c54e42be 100644
--- a/reference/CommandBarItem.html
+++ b/reference/CommandBarItem.html
@@ -1,5 +1,5 @@
-Command bar item — CommandBarItem • shiny.fluent Command bar item — CommandBarItem • shiny.fluent