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

Add sidebarSearchForm #181

Open
osenan opened this issue Apr 25, 2022 · 0 comments
Open

Add sidebarSearchForm #181

osenan opened this issue Apr 25, 2022 · 0 comments

Comments

@osenan
Copy link
Contributor

osenan commented Apr 25, 2022

Include a component similar to shinydashboard::sidebarSearchForm using shiny.semantic components

The sidebarSearchForm is a ui component that queries a search and is placed on the sidebar.
https://github.com/rstudio/shinydashboard/blob/main/R/dashboardSidebar.R#L188
It contains as argument a textId for the id of the input text, a buttonId for the created icon button to be reactive in the server, a label for the label of the input and an icon for selecting the icon that will act as a button.

Here an example app of the sidebarSearchForm



library(shiny)
library(shinydashboard)

header <- dashboardHeader()
sidebar <- dashboardSidebar(
  sidebarSearchForm(label = "Enter a number", "searchText", "searchButton"),
  sidebarMenu(
    # Setting id makes input$tabs give the tabName of currently-selected tab
    id = "tabs",
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
    menuItem("Widgets", icon = icon("th"), tabName = "widgets", badgeLabel = "new",
             badgeColor = "green"),
    menuItem("Charts", icon = icon("calendar"),
      menuSubItem("Sub-item 1", tabName = "subitem1"),
      menuSubItem("Sub-item 2", tabName = "subitem2")
    )
  )
)
body <- dashboardBody(
  tabItems(
    tabItem("dashboard",
      div(p("Dashboard tab content"))
    ),
    tabItem("widgets",
      "Widgets tab content"
    ),
    tabItem("subitem1",
      "Sub-item 1 tab content"
    ),
    tabItem("subitem2",
      "Sub-item 2 tab content"
    )
  )
)
shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) { }
)

In our implementation, we could create a function that acts as a wrapper of [shiny semantic search functions](https://github.com/rstudio/shinydashboard/blob/main/R/dashboardSidebar.R#L188) and include - if needed - format to display it nicely on the sidebar. New arguments can be created appart from the current ones avaiable in shiny.dashboard.

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

No branches or pull requests

1 participant