Skip to content

Commit

Permalink
question containers centered
Browse files Browse the repository at this point in the history
  • Loading branch information
pingfan-hu committed Sep 25, 2024
1 parent ef351ca commit 2d1756e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
20 changes: 3 additions & 17 deletions R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -205,7 +204,6 @@ sd_question <- function(
output <- shiny::radioButtons(
inputId = id,
label = markdown_to_html(label),
width = width,
choices = option,
selected = FALSE
)
Expand All @@ -215,7 +213,6 @@ sd_question <- function(
output <- shiny::checkboxGroupInput(
inputId = id,
label = markdown_to_html(label),
width = width,
choices = option,
selected = FALSE
)
Expand All @@ -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("
Expand All @@ -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("
Expand All @@ -260,7 +255,6 @@ sd_question <- function(
output <- shiny::textInput(
inputId = id,
label = markdown_to_html(label),
width = width,
placeholder = option
)

Expand All @@ -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,
Expand All @@ -283,7 +276,6 @@ sd_question <- function(
output <- shiny::numericInput(
inputId = id,
label = markdown_to_html(label),
width = width,
value = NULL
)

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
)
Expand Down
12 changes: 9 additions & 3 deletions inst/css/surveydown.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 2d1756e

Please sign in to comment.