From 2d1756ed47436416b72230fd3b9005a40456a9a7 Mon Sep 17 00:00:00 2001 From: Pingfan Hu Date: Wed, 25 Sep 2024 14:37:15 -0400 Subject: [PATCH] question containers centered --- R/ui.R | 20 +++----------------- inst/css/surveydown.css | 12 +++++++++--- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/R/ui.R b/R/ui.R index cf8f3c38..5618fb75 100644 --- a/R/ui.R +++ b/R/ui.R @@ -194,7 +194,6 @@ sd_question <- function( output <- shiny::selectInput( inputId = id, label = markdown_to_html(label), - width = width, choices = option, multiple = FALSE, selected = FALSE @@ -205,7 +204,6 @@ sd_question <- function( output <- shiny::radioButtons( inputId = id, label = markdown_to_html(label), - width = width, choices = option, selected = FALSE ) @@ -215,7 +213,6 @@ sd_question <- function( output <- shiny::checkboxGroupInput( inputId = id, label = markdown_to_html(label), - width = width, choices = option, selected = FALSE ) @@ -227,8 +224,7 @@ sd_question <- function( label = markdown_to_html(label), choices = list_name_md_to_html(option), direction = direction, - selected = character(0), - class = "narrow-screen-vertical" + selected = character(0) ) output <- shiny::tagAppendChild(output, shiny::tags$script(shiny::HTML(sprintf(" @@ -245,8 +241,7 @@ sd_question <- function( choices = list_name_md_to_html(option), direction = direction, individual = individual, - justified = FALSE, - class = "narrow-screen-vertical" + justified = FALSE ) output <- shiny::tagAppendChild(output, shiny::tags$script(shiny::HTML(sprintf(" @@ -260,7 +255,6 @@ sd_question <- function( output <- shiny::textInput( inputId = id, label = markdown_to_html(label), - width = width, placeholder = option ) @@ -269,7 +263,6 @@ sd_question <- function( output <- shiny::textAreaInput( inputId = id, label = markdown_to_html(label), - width = width, height = height, cols = cols, value = NULL, @@ -283,7 +276,6 @@ sd_question <- function( output <- shiny::numericInput( inputId = id, label = markdown_to_html(label), - width = width, value = NULL ) @@ -292,7 +284,6 @@ sd_question <- function( output <- shinyWidgets::sliderTextInput( inputId = id, label = markdown_to_html(label), - width = width, choices = option, selected = selected, force_edges = force_edges, @@ -315,7 +306,6 @@ sd_question <- function( output <- shiny::dateInput( inputId = id, label = markdown_to_html(label), - width = width, value = NULL, min = NULL, max = NULL, @@ -335,7 +325,6 @@ sd_question <- function( output <- shiny::dateRangeInput( inputId = id, label = markdown_to_html(label), - width = width, start = NULL, end = NULL, min = NULL, @@ -352,15 +341,12 @@ sd_question <- function( } - # Check for the 2 types of buttons - is_button <- type %in% c("mc_buttons", "mc_multiple_buttons") - # Wrap the output in a div with custom data attributes output_div <- shiny::tags$div( id = paste0("container-", id), `data-question-id` = id, class = "question-container", - style = if (is_button) sprintf("width: %s;", width), + style = sprintf("width: %s;", width), oninput = js_interaction, output ) diff --git a/inst/css/surveydown.css b/inst/css/surveydown.css index c6835aa4..224ccbae 100644 --- a/inst/css/surveydown.css +++ b/inst/css/surveydown.css @@ -149,18 +149,24 @@ p, .form-group, .control-label { background-color: #f9f9f9; } +.form-group > label.control-label { + margin-top: 0; + margin-bottom: 0.3rem; +} + .form-control:focus { border-color: var(--theme-color); box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-color) 25%, transparent); } .question-container { + margin-left: auto; + margin-right: auto; margin-bottom: 1rem; } -.form-group > label.control-label { - margin-top: 0; - margin-bottom: 0.3rem; +.shiny-input-container:not(.shiny-input-container-inline) { + width: 100%; } /* Page Navigation Buttons */