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

Possibility to capture argonDropNavItem in server as an input? #28

Open
sarthi2395 opened this issue Sep 4, 2020 · 3 comments
Open

Comments

@sarthi2395
Copy link

Currently, the dropdown options in argonDropNavItem carry only weblinks, which when clicked redirects to corresponding webpage. Is is possible to update this as a button instead and capture the selection in server?

@DivadNojnarg
Copy link
Member

Yup that could be. This is what I am currently doing on all other RinteRface package to allow for more interactivity

@sarthi2395
Copy link
Author

Do you have a gist available as an example?

@DivadNojnarg
Copy link
Member

DivadNojnarg commented Sep 4, 2020

Something really quick and dirty before I push a fix:

library(shiny)
library(argon)
library(argonR)


argonDropdownItem <- function (inputId = NULL, name = NULL, description = NULL, src = NULL, icon = NULL, 
                               status = NULL) {
  
  itemCl <- "media d-flex align-items-center"
  
  # add class action-button to rely on the existing shiny input binding
  if (!is.null(inputId)) {
    itemCl <- paste0(itemCl, " btn action-button")
  }
  
  tags$a(
    id = if (!is.null(inputId)) inputId, 
    class = itemCl, 
    href = src, 
    if (!is.null(icon)) {
      argonIconWrapper(
        iconTag = icon, gradient_color = status, 
        circle = TRUE, size = NULL, status = status, 
        shadow = FALSE, hover_shadow = FALSE)
    },
    tags$div(
      class = "media-body ml-3",
      tags$h6(class = paste0("heading text-", status, " mb-md-1"), name), 
      tags$p(class = "description d-none d-md-inline-block mb-0", description)
    )
  )
}



shinyApp(
  ui = argonDashPage(
    navbar = argonDashNavbar(
      argonDropNav(
        title = "Menu",
        argonDropdownItem(inputId = "test", name = "Hello")
      )
    ),
    sidebar = argonDashSidebar(
      id = "sidebar",
      side = "left",
      size = "md",
      skin = "light"
    ),
    body = argonDashBody("Hello World")
  ),
  server = function(input, output) {
    observeEvent(input$test, {
      showNotification("plop")
    })
  }
)

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

No branches or pull requests

2 participants