Skip to content

Commit 4de7877

Browse files
authored
Merge pull request #13 from moj-analytical-services/Fields-fix
Fields fix
2 parents cc0d696 + 69bb6d0 commit 4de7877

8 files changed

+19
-13
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: shinyGovstyle
22
Title: Custom Gov Style Inputs for Shiny
3-
Version: 0.0.3
3+
Version: 0.0.4
44
Authors@R: person("Ross", "Wyatt", email = "[email protected]", role = c("aut", "cre"))
55
Description: Collection of 'shiny' application styling that are the based on the GOV.UK Design System.
66
See https://design-system.service.gov.uk/components/ for details.

R/input_field.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
#' @param labels A list of labels for the text inputs
66
#' @param inputIds A list input slots that will be used to access the value.
77
#' @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
8+
#' @param types text box types. Will default to text.
89
#' @keywords input field
910
#' @export
1011
#' @examples
1112
#' input_field("List of three text boxes", c("Option 1", "Option 2", "Option 3"), c("op1", "op2", "op3"))
1213

13-
input_field <- function(legend, labels, inputIds, widths=NULL){
14+
input_field <- function(legend, labels, inputIds, widths=NULL, types = "text"){
1415
govInputField <- tags$fieldset(class="govuk-fieldset",
1516
tags$legend(legend, class="govuk-fieldset__legend govuk-fieldset__legend--xl"),
16-
Map(function(x, y, z){
17+
Map(function(x, y, z, a){
1718
if (is.null(z)){
1819
width_class <- "govuk-input"
1920
}
@@ -22,9 +23,9 @@ input_field <- function(legend, labels, inputIds, widths=NULL){
2223
}
2324
tags$div(class="govuk-form-group",
2425
tags$label(HTML(x), class="govuk-label"),
25-
tags$input(id=y, class=width_class)
26+
tags$input(id=y, class=width_class, type = a)
2627
)
27-
}, x = labels, y = inputIds, z = widths)
28+
}, x = labels, y = inputIds, z = widths, a = types)
2829
)
2930
attachDependency(govInputField)
3031
}

R/radio_button_input.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#' @param hint_label Additional hint text you may want to display below the label. Defaults to NULL
1414
#' @param error Whenever you want to include error handle on the component.
1515
#' @param error_message If you want a default error message.
16+
#' @param custom_class If you want to add additional classes to the radio buttons
1617
#' @keywords radiobuttons
1718
#' @export
1819
#' @examples
@@ -22,7 +23,7 @@ radio_button_Input <- function (inputId, label, choices = NULL,
2223
selected = NULL, inline = FALSE, small = FALSE,
2324
choiceNames = NULL,
2425
choiceValues = NULL, hint_label = NULL, error = FALSE,
25-
error_message = NULL){
26+
error_message = NULL, custom_class = ""){
2627
args <- shiny:::normalizeChoicesArgs(choices, choiceNames, choiceValues)
2728
selected <- shiny::restoreInput(id = inputId, default = selected)
2829
selected <- if (is.null(selected))
@@ -32,7 +33,7 @@ radio_button_Input <- function (inputId, label, choices = NULL,
3233
stop("The 'selected' argument must be of length 1")
3334
options <- generateOptions2(inputId, selected, inline, small, "radio",
3435
args$choiceNames, args$choiceValues)
35-
divClass <- "govuk-form-group govuk-radios"
36+
divClass <- paste("govuk-form-group govuk-radios", custom_class)
3637
govRadio <- tags$div(id = inputId, class = divClass,
3738
tags$div(class="govuk-form-group", id=paste0(inputId,"div"),
3839
controlLabel2(inputId, label),

man/checkbox_input.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/input_field.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/radio_button_input.Rd

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/text_area_input.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/text_input.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)