diff --git a/DESCRIPTION b/DESCRIPTION index 05bae1b..369362c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "ross.wyatt@justice.gov.uk", 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. diff --git a/R/input_field.R b/R/input_field.R index 9912c25..aca5152 100644 --- a/R/input_field.R +++ b/R/input_field.R @@ -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" } @@ -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) } diff --git a/R/radio_button_input.R b/R/radio_button_input.R index ce3b4b9..b4280d3 100644 --- a/R/radio_button_input.R +++ b/R/radio_button_input.R @@ -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 @@ -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)) @@ -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), diff --git a/man/checkbox_input.Rd b/man/checkbox_input.Rd index 8a2a0e9..7b3e45d 100644 --- a/man/checkbox_input.Rd +++ b/man/checkbox_input.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/checkbox_Input.R +% Please edit documentation in R/checkbox_input.R \name{checkbox_Input} \alias{checkbox_Input} \title{Checkbox Function} diff --git a/man/input_field.Rd b/man/input_field.Rd index 0101f5a..b9868b7 100644 --- a/man/input_field.Rd +++ b/man/input_field.Rd @@ -4,7 +4,7 @@ \alias{input_field} \title{Input Field Function} \usage{ -input_field(legend, labels, inputIds, widths = NULL) +input_field(legend, labels, inputIds, widths = NULL, types = "text") } \arguments{ \item{legend}{Lengand that goes above the fieldset} @@ -14,6 +14,8 @@ input_field(legend, labels, inputIds, widths = NULL) \item{inputIds}{A list input slots that will be used to access the value.} \item{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} + +\item{types}{text box types. Will default to text.} } \description{ This function inserts number of text inputs. Useful for addresses. diff --git a/man/radio_button_input.Rd b/man/radio_button_input.Rd index 3787c4f..9e36d7f 100644 --- a/man/radio_button_input.Rd +++ b/man/radio_button_input.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/radio_button_Input.R +% Please edit documentation in R/radio_button_input.R \name{radio_button_Input} \alias{radio_button_Input} \title{Radio Button Function} @@ -7,7 +7,7 @@ radio_button_Input(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 = "") } \arguments{ \item{inputId}{The \code{input} slot that will be used to access the value.} @@ -31,6 +31,8 @@ the user in the app and correspond to the each choice (for this reason,} \item{error}{Whenever you want to include error handle on the component.} \item{error_message}{If you want a default error message.} + +\item{custom_class}{If you want to add additional classes to the radio buttons} } \description{ This function create radio buttons diff --git a/man/text_area_input.Rd b/man/text_area_input.Rd index b22e93a..a79c3da 100644 --- a/man/text_area_input.Rd +++ b/man/text_area_input.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/text_area_Input.R +% Please edit documentation in R/text_area_input.R \name{text_area_Input} \alias{text_area_Input} \title{Text Area Input Function} diff --git a/man/text_input.Rd b/man/text_input.Rd index 74f358d..761671f 100644 --- a/man/text_input.Rd +++ b/man/text_input.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/text_Input.R +% Please edit documentation in R/text_input.R \name{text_Input} \alias{text_Input} \title{Text Input Function}