Skip to content

Commit

Permalink
Add documentation + bump version + linting
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMc1089 committed Nov 15, 2023
1 parent 9a142d2 commit 8fcf7fb
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nhsbsaShinyR
Title: Template for NHSBSA {shiny} apps
Version: 0.0.0.9002
Version: 0.0.0.9003
Authors@R:
c(person(given = "DALL",
family = "",
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(accessible_action_link)
export(accessible_radio_button)
export(h1_tabstop)
export(h2_tabstop)
export(h3_tabstop)
Expand Down
50 changes: 31 additions & 19 deletions R/utils_accessibility.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,53 +126,65 @@ nhs_card_tabstop <- function(header, tabindex = 0, ...) {
}







#' accessible_radio_button
#'
#' @param ... radio content
#' @inheritParams shiny::radioButtons
#'
#' @noRd
#' @return HTML
#' @export
#'
#' @examples
#' accessible_radio_button("rb", "Choose one:",
#' choiceNames = list(
#' "apple",
#' "banana",
#' "cherry"
#' ),
#' choiceValues = list(
#' "A", "B", "C"
#' ))
# Begin Exclude Linting
accessible_radio_button <- function(inputId, label, choices = NULL, selected = NULL,
inline = FALSE, width = NULL, choiceNames = NULL,
choiceValues = NULL) {
# End Exclude Linting
args <- shiny:::normalizeChoicesArgs(choices, choiceNames, choiceValues)
selected <- shiny::restoreInput(id = inputId, default = selected)

selected <- restoreInput(id = inputId, default = selected)

selected <- if (is.null(selected)) args$choiceValues[[1]] else as.character(selected)
if (length(selected) > 1) stop("The 'selected' argument must be of length 1")

options <- shiny:::generateOptions(
inputId, selected, inline, "radio", args$choiceNames, args$choiceValues
)
divClass <- "form-group shiny-input-radiogroup shiny-input-container"
if (inline) divClass <- paste(divClass, "shiny-input-container-inline")

div_class <- "form-group shiny-input-radiogroup shiny-input-container"
if (inline) div_class <- paste(div_class, "shiny-input-container-inline")

tags$fieldset(
tags$legend(label),
tags$div(
id = inputId,
style = htmltools::css(width = validateCssUnit(width)),
class = divClass,
class = div_class,
role = "radiogroup",
options
)
)
}


#' accessible_action_link
#'
#' @param ... action link text
#' @inheritParams shiny::actionLink
#'
#' @noRd
#' @return HTML
#' @export
#'
accessible_action_link <- function(inputId, label, icon = NULL, ...) {
#' @examples
#' accessible_action_link("infoLink", "Information Link", class = "btn-info")
accessible_action_link <- function(inputId, label, icon = NULL, ...) { # Exclude Linting
value <- restoreInput(id = inputId, default = NULL)
tags$a(id = inputId, href = "#", class = "action-button",
`data-val` = value, style = "color: #004280; text-decoration: underline;",
Expand Down
27 changes: 27 additions & 0 deletions man/accessible_action_link.Rd

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

63 changes: 63 additions & 0 deletions man/accessible_radio_button.Rd

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

0 comments on commit 8fcf7fb

Please sign in to comment.