Skip to content

Commit

Permalink
Merge pull request #13 from moj-analytical-services/Fields-fix
Browse files Browse the repository at this point in the history
Fields fix
  • Loading branch information
rosswyatt authored Oct 16, 2019
2 parents cc0d696 + 69bb6d0 commit 4de7877
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyGovstyle
Title: Custom Gov Style Inputs for Shiny
Version: 0.0.3
Version: 0.0.4
Authors@R: person("Ross", "Wyatt", email = "[email protected]", role = c("aut", "cre"))
Description: Collection of 'shiny' application styling that are the based on the GOV.UK Design System.
See https://design-system.service.gov.uk/components/ for details.
Expand Down
9 changes: 5 additions & 4 deletions R/input_field.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
#' @param labels A list of labels for the text inputs
#' @param inputIds A list input slots that will be used to access the value.
#' @param widths control the size of the box based on number of characters required. Options are 30, 20, 10, 5, 4, 3, 2. NULL will not limit the size
#' @param types text box types. Will default to text.
#' @keywords input field
#' @export
#' @examples
#' input_field("List of three text boxes", c("Option 1", "Option 2", "Option 3"), c("op1", "op2", "op3"))

input_field <- function(legend, labels, inputIds, widths=NULL){
input_field <- function(legend, labels, inputIds, widths=NULL, types = "text"){
govInputField <- tags$fieldset(class="govuk-fieldset",
tags$legend(legend, class="govuk-fieldset__legend govuk-fieldset__legend--xl"),
Map(function(x, y, z){
Map(function(x, y, z, a){
if (is.null(z)){
width_class <- "govuk-input"
}
Expand All @@ -22,9 +23,9 @@ input_field <- function(legend, labels, inputIds, widths=NULL){
}
tags$div(class="govuk-form-group",
tags$label(HTML(x), class="govuk-label"),
tags$input(id=y, class=width_class)
tags$input(id=y, class=width_class, type = a)
)
}, x = labels, y = inputIds, z = widths)
}, x = labels, y = inputIds, z = widths, a = types)
)
attachDependency(govInputField)
}
5 changes: 3 additions & 2 deletions R/radio_button_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @param hint_label Additional hint text you may want to display below the label. Defaults to NULL
#' @param error Whenever you want to include error handle on the component.
#' @param error_message If you want a default error message.
#' @param custom_class If you want to add additional classes to the radio buttons
#' @keywords radiobuttons
#' @export
#' @examples
Expand All @@ -22,7 +23,7 @@ radio_button_Input <- function (inputId, label, choices = NULL,
selected = NULL, inline = FALSE, small = FALSE,
choiceNames = NULL,
choiceValues = NULL, hint_label = NULL, error = FALSE,
error_message = NULL){
error_message = NULL, custom_class = ""){
args <- shiny:::normalizeChoicesArgs(choices, choiceNames, choiceValues)
selected <- shiny::restoreInput(id = inputId, default = selected)
selected <- if (is.null(selected))
Expand All @@ -32,7 +33,7 @@ radio_button_Input <- function (inputId, label, choices = NULL,
stop("The 'selected' argument must be of length 1")
options <- generateOptions2(inputId, selected, inline, small, "radio",
args$choiceNames, args$choiceValues)
divClass <- "govuk-form-group govuk-radios"
divClass <- paste("govuk-form-group govuk-radios", custom_class)
govRadio <- tags$div(id = inputId, class = divClass,
tags$div(class="govuk-form-group", id=paste0(inputId,"div"),
controlLabel2(inputId, label),
Expand Down
2 changes: 1 addition & 1 deletion man/checkbox_input.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/input_field.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/radio_button_input.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/text_area_input.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/text_input.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4de7877

Please sign in to comment.