RinteRface / shinydashboardPlus

extensions for shinydashboard
https://shinydashboardplus.rinterface.com
Other
454 stars 77 forks source link

flipBox doesn't flip when using shinydashboardPlus #34

Closed InkStein closed 3 years ago

InkStein commented 5 years ago

I'm still new to R Shiny, so my apologies if this is a user error.

I can't get flipBox() to work in my app. It will generate, but the flip action will not trigger anything. It appears that if you use useShinydashboardPlus() in your code (see example) it disables this action. My original app uses dashboardPlus natively (called directly in the body, not through useShinydashboard). I'm also attempting to use flipBox inside of a tabItem in case that compounds the issue. But the gallery implies that it should work, though I'm having trouble finding the R code to look at for that.

Package Versions: shiny - 1.2.0 shinydashboard - 0.7.1 shinydashboardPlus - 0.7.0

Suggestions? Examples?

library(shiny)

ui <- fluidPage(

  useShinydashboardPlus(), # disable to use flipBox

  setBackgroundColor(color = "ghostwhite"),

  flipBox(
    id = 1,
    main_img = "https://image.flaticon.com/icons/svg/149/149076.svg",
    header_img = "https://image.flaticon.com/icons/svg/119/119595.svg",
    front_title = "John Doe",
    back_title = "About John",
      "text",
    back_content = tagList(
      "more text"
    )
  )
  )

server <- function(input, output, session) {

}

shinyApp(ui, server)

## End(Not run)

edit: added package versions

DivadNojnarg commented 5 years ago

We need to update shinyWidgets. In the meantime, you can use this code:

library(shiny)
library(shinyWidgets)
library(shinydashboardPlus)

useShinydashboardPlus <- function() {
  if (!requireNamespace(package = "shinydashboardPlus")) 
    message("Package 'shinydashboardPlus' is required to run this function")
  deps <- htmltools::findDependencies(
    dashboardPagePlus(
      header = dashboardHeaderPlus(), 
      sidebar = dashboardSidebar(), 
      body = dashboardBody()
    )
  )
  htmltools::attachDependencies(tags$div(class = "main-sidebar", style = "display: none;"), value = deps)
}

ui <- fluidPage(

  useShinydashboardPlus(), # disable to use flipBox

  setBackgroundColor(color = "ghostwhite"),

  flipBox(
    id = 1,
    main_img = "https://image.flaticon.com/icons/svg/149/149076.svg",
    header_img = "https://image.flaticon.com/icons/svg/119/119595.svg",
    front_title = "John Doe",
    back_title = "About John",
    "text",
    back_content = tagList(
      "more text"
    )
  )
)

server <- function(input, output, session) {}

shinyApp(ui, server)
DivadNojnarg commented 5 years ago

You can now download the devel version of shinyWidgets:

devtools::install_github("dreamRs/shinyWidgets")

and load your script

nhnminh commented 5 years ago

Hello @DivadNojnarg

I have another problem with flipBox, that I cannot use it with uiOutput ( in ui) and renderUI (in the server-side). When I put it completely in the ui part (like the example above), it works well.

This problem was also mentioned once in #19 but has not been solved yet.

Could you please take a look at this? Thank you

InkStein commented 5 years ago

You can now download the devel version of shinyWidgets:

devtools::install_github("dreamRs/shinyWidgets")

and load your script

Sorry for the delayed response. Thank you, that did fix the issue in the example I posted.

It didn't work in my larger code because I'm wrapping the flipbox in a renderUI() on the server side and that appears to break functionality as well. Below is the code that breaks the flipbox (with comments). I did try this with the github version of shinyWidgets.

library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(shinydashboardPlus)

ui <- fluidPage(
  dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(

      flipBox(
        id = 1,
        main_img = "https://image.flaticon.com/icons/svg/149/149076.svg",
        header_img = "https://image.flaticon.com/icons/svg/119/119595.svg",
        front_title = "John Doe",
        back_title = "About John",
        "UI side flip box",
        back_content = tagList(
          "more text"
        )),
        tags$br(),

      uiOutput("flip_server")
    )
  )

)

server <- function(input, output) {

  output$flip_server <- renderUI(

    flipBox(
      id = 2,
      main_img = "https://image.flaticon.com/icons/svg/149/149076.svg",
      header_img = "https://image.flaticon.com/icons/svg/119/119595.svg",
      front_title = "Jane Doe",
      back_title = "About Jane",
      "Server Side flipbox",
      back_content = tagList(
        "more text"
      ))
  )

}

shinyApp(ui = ui, server = server)

Many thanks

DivadNojnarg commented 3 years ago

Fixed in latest devel version

munishkgitbub commented 2 years ago

Is there any way in flipbox to only let it flip through updateFlipBox and block from Click or Hover trigger?