Sfoglia il codice sorgente

Add splash screen body

master
Garrick Aden-Buie 8 anni fa
parent
commit
fa74d252fc
3 ha cambiato i file con 78 aggiunte e 29 eliminazioni
  1. +47
    -29
      t4c/app.R
  2. +31
    -0
      t4c/t4c.css
  3. BIN
      t4c/www/images/splash-bg.png

+ 47
- 29
t4c/app.R Vedi File

library(dplyr) library(dplyr)
library(shinyjs) library(shinyjs)


# ---- APP PARAMETERS ----
APP_TITLE <- "App Title"
HELP_TEXT <- "Some guidance text can go here"

questions <- readxl::read_xlsx(here::here("docs/questions.xlsx")) %>% questions <- readxl::read_xlsx(here::here("docs/questions.xlsx")) %>%
arrange(order) arrange(order)


includeCSS("animate.css"), includeCSS("animate.css"),
shinyjs::useShinyjs(), shinyjs::useShinyjs(),
tags$link(rel = "stylesheet", type = "text/css", href = "https://fonts.googleapis.com/css?family=IBM+Plex+Sans:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i"), tags$link(rel = "stylesheet", type = "text/css", href = "https://fonts.googleapis.com/css?family=IBM+Plex+Sans:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i"),
tags$link(rel = "stylesheet", type = "text/css", href = "https://fonts.googleapis.com/css?family=Amatic+SC:400,700|Coming+Soon"),


# h1("A Good Name and Logo"), # h1("A Good Name and Logo"),
# p("This is a simple demo app..."), # p("This is a simple demo app..."),
# hr(), # hr(),
p(), p(),
phone_container( phone_container(
div(class = "overlay splash animated", id = "splash-overlay"),
div(
class = "overlay splash animated", id = "splash-overlay",
div(
class = "splash-body",
h1("Welcome!"),
p("Talking about cancer treatment options is hard, but we're here to help."),
actionButton("splash_next_screen", "Get Started", class = "btn-bottom-right btn-primary")
)
),
div( div(
id = "app-main", id = "app-main",
class = "app-main animated", class = "app-main animated",
h1("App Title", class = "app-title"),
p("Help Text", class = "help-text"),
h1(APP_TITLE, class = "app-title"),
p(HELP_TEXT, class = "help-text"),
shinyswiprUI( shinyswiprUI(
"card_swipe_ui", "card_swipe_ui",
div(class = "swiperCard-header", div(class = "swiperCard-header",
h4(class = "card-title", h4(class = "card-title",
textOutput("question_category") textOutput("question_category")
# "Card Title",
) )
), ),
div(class = "swiperCard-body", div(class = "swiperCard-body",




server <- function(input, output, session) { server <- function(input, output, session) {
app_data <- reactiveValues(
init = 1L,
iter = 1L,
results = data_frame(question_id = integer(), swipe = character()),
complete = FALSE,
splash = TRUE
)

question <- reactive({
if (app_data$iter > length(question_ids)) return(NULL)
questions %>%
filter(id == question_ids[[app_data$iter]])
})

card_swipe <- callModule(shinyswipr, "card_swipe_ui") card_swipe <- callModule(shinyswipr, "card_swipe_ui")


question_ids <- arrange(questions, order) %>% pull(id) question_ids <- arrange(questions, order) %>% pull(id)


# Init outputs
output$question_text <- renderText({ output$question_text <- renderText({
if (!app_data$complete) { if (!app_data$complete) {
question()$`Question Text` question()$`Question Text`
} }
}) })
output$question_category <- renderText({ output$question_category <- renderText({
if (!app_data$complete) {
question()$Category
} else {
"Thank You!"
}
if (!app_data$complete) question()$Category else "Thank You!"
}) })
output$question_topic <- renderText({ output$question_topic <- renderText({
if (!app_data$complete) {
question()$Topic
} else {
"All Done!"
}
if (!app_data$complete) question()$Topic else "All Done!"
}) })
output$results_table <- renderDataTable({ output$results_table <- renderDataTable({
app_data$results app_data$results
}) })


app_data <- reactiveValues(
iter = 1L,
results = data_frame(question_id = integer(), swipe = character()),
complete = FALSE,
splash = FALSE
)

question <- reactive({
if (app_data$iter > length(question_ids)) return(NULL)
questions %>%
filter(id == question_ids[[app_data$iter]])
})


observe({ observe({
cat("iter:", app_data$iter, "\n") cat("iter:", app_data$iter, "\n")
# output$results_table <- renderDataTable({app_data$results}) # output$results_table <- renderDataTable({app_data$results})
}) })


observeEvent(input$splash_next_screen, {
if (app_data$splash) app_data$splash <- FALSE
})

observeEvent(input$toggle_splash, { observeEvent(input$toggle_splash, {
app_data$splash <- !app_data$splash app_data$splash <- !app_data$splash
if (app_data$splash) {
})

observeEvent(app_data$splash, {
if (app_data$init) {
app_data$init <- app_data$init - 1L
return()
}
if (!app_data$splash) {
# cli::cat_line(strftime(Sys.time(), "%F %T"), " splash out")
shinyjs::removeClass("splash-overlay", "slideInLeft") shinyjs::removeClass("splash-overlay", "slideInLeft")
shinyjs::removeClass("app-main", "slideOutRight") shinyjs::removeClass("app-main", "slideOutRight")
shinyjs::addClass("app-main", "slideInRight") shinyjs::addClass("app-main", "slideInRight")
shinyjs::addClass("splash-overlay", "slideOutLeft") shinyjs::addClass("splash-overlay", "slideOutLeft")
} else { } else {
# cli::cat_line(strftime(Sys.time(), "%F %T"), " splash in")
shinyjs::removeClass("splash-overlay", "slideOutLeft") shinyjs::removeClass("splash-overlay", "slideOutLeft")
shinyjs::removeClass("app-main", "slideInRight") shinyjs::removeClass("app-main", "slideInRight")
shinyjs::addClass("app-main", "slideOutRight") shinyjs::addClass("app-main", "slideOutRight")
shinyjs::addClass("splash-overlay", "slideInLeft") shinyjs::addClass("splash-overlay", "slideInLeft")
} }
})
}, priority = -100)
} }


shinyApp(ui = ui, server = server) shinyApp(ui = ui, server = server)

+ 31
- 0
t4c/t4c.css Vedi File

background-image: url("/images/splash-bg.png"); background-image: url("/images/splash-bg.png");
background-size: cover; background-size: cover;
} }

.splash-body {
font-family: Amatic SC;
color: black;
font-size: 2.5em;
}
.splash-body h1 {
font-size: 2.5em;
margin-top: 44%;
font-weight: 600;
}
.splash-body p {
padding-left: 40px;
padding-right: 40px;
padding-top: 10px;
}
.btn-bottom-right {
display: block;
position: absolute;
bottom: 25px;
right: 25px;
font-size: 0.6em;
width: 125px;
}
.btn-moffitt {
background-color: #00589a;
color: white;
font-weight: 600;
border-color: white;
font-family: IBM Plex Sans;
}

BIN
t4c/www/images/splash-bg.png Vedi File

Before After
Width: 414  |  Height: 736  |  Size: 364KB Width: 414  |  Height: 736  |  Size: 339KB

Loading…
Annulla
Salva