Closed cthomson8 closed 3 years ago
@cthomson8
We made a (preliminary) version of this function in our open-source tychobratools package for this purpose. See the flip_box function's code for more details.
I have also attached a quick demonstration GIF here as well.
@DivadNojnarg let me know if you would be interested and I will dedicate some time to cleaning up the code in the future and can fork>PR if you want to implement this here.
Hi Jim, feel free to PR! This is a neat feature
@DivadNojnarg just submitted a PR for you to review. Let me know if you have any questions or concerns.
Closing as per latest update:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
column(
width = 6,
uiOutput("active_side"),
flipBox(
id = "myflipbox",
trigger = "hover",
width = 12,
front = div(
class = "text-center",
h1("Flip on hover"),
img(
src = "https://image.flaticon.com/icons/svg/149/149076.svg",
height = "300px",
width = "100%"
)
),
back = div(
class = "text-center",
height = "300px",
width = "100%",
h1("Flip on hover"),
p("More information....")
)
)
),
column(
width = 6,
uiOutput("active_side_2"),
flipBox(
id = "myflipbox2",
width = 12,
front = div(
class = "text-center",
h1("Flip on click"),
img(
src = "https://image.flaticon.com/icons/svg/149/149076.svg",
height = "300px",
width = "100%"
)
),
back = div(
class = "text-center",
height = "300px",
width = "100%",
h1("Flip on click"),
p("More information....")
)
)
)
)
)
),
server = function(input, output, session) {
output$active_side <- renderUI({
side <- if (input$myflipbox) "front" else "back"
dashboardBadge(side, color = "blue")
})
output$active_side_2<- renderUI({
side <- if (input$myflipbox2) "front" else "back"
dashboardBadge(side, color = "blue")
})
}
)
Is it possible to use flipBox without an image? I have tried using main_img = NULL but this produces a distorted green circle with the word "Avatar". I want to be able to use icons (svgs) in the main_img field but these get filled with the same green colour.