juba / shinyglide

Glide.js component for Shiny apps
https://juba.github.io/shinyglide/
91 stars 8 forks source link

Going back to first screen #46

Closed howardbaek closed 10 months ago

howardbaek commented 10 months ago

Hi @juba! Thanks for this awesome package.

I was trying to add a button on the last screen which sends the user back to the first screen. I looked at your example code (https://github.com/juba/shinyglide/blob/master/inst/examples/04_custom_controls/app.R#L7C1-L7C1), but failed.

See below for reproducible example:

# Packages ----
library(shiny)
library(shinyglide)
library(shinyWidgets)
library(googlesheets4)
library(dplyr)

controls <- tags$div(
    tags$div(class="my-control prev-screen"),
    tags$div(class="my-control next-screen"),
    div(`data-glide-el`="controls",
      tags$a(
        class="my-control last-screen",
        `data-glide-dir` = "<<",
        icon("repeat", lib = "glyphicon")
      )
    )
  )

# App
ui <- fluidPage(style = "max-width: 500px;",
                titlePanel("Omics Resources Explorer", windowTitle = "Omics Resources Explorer (WIP)"),
                br(),
                glide(
                  height = "350px",
                  custom_controls = controls,
                  screen(
                    p("Please click on Next to go to the next screen.")
                  ),
                  screen(
                    h3("Question 1"),
                   selectInput("cloud", "What molecule is analyzed?", choices = NULL)
                  ),
                  screen(
                    h3("Question 2"),
                    selectInput("technique", "What technique is used?", choices = NULL)
                  )
                )
)

server <- function(input, output, session) {
# Server code omitted for brevity
}

shinyApp(ui, server)

This just puts the buttons in a weird place. Any help would be appreciated!

juba commented 10 months ago

The buttons placement and style is because you didn't include the CSS code in the example. To reproduce button styling you would have to include at least the rules relative to the my-control, prev-screen and next-screen classes.

howardbaek commented 10 months ago

Thanks for the super fast reply!