-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from dfe-analytical-services/improve-support-f…
…eedback-tab Improve support feedback tab
- Loading branch information
Showing
10 changed files
with
673 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: dfeshiny | ||
Title: DfE R Shiny Standards | ||
Version: 0.4.3 | ||
Version: 0.5.0 | ||
Authors@R: c( | ||
person("Rich", "Bielby", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-9070-9969")), | ||
|
@@ -10,33 +10,34 @@ Authors@R: c( | |
Description: R package containing preferred methods for creating official | ||
DfE R-Shiny dashboards. | ||
License: GPL (>= 3) | ||
URL: https://dfe-analytical-services.github.io/dfeshiny/ | ||
https://www.github.com/dfe-analytical-services/dfeshiny/ | ||
Depends: | ||
R (>= 2.10) | ||
Imports: | ||
magrittr, | ||
checkmate, | ||
glue, | ||
htmltools, | ||
magrittr, | ||
RCurl, | ||
shiny, | ||
shinyGovstyle, | ||
shinyjs, | ||
stringr, | ||
styler | ||
Suggests: | ||
devtools, | ||
diffviewer, | ||
knitr, | ||
rmarkdown, | ||
shinytest2, | ||
devtools, | ||
testthat (>= 3.0.0), | ||
spelling | ||
spelling, | ||
testthat (>= 3.0.0) | ||
VignetteBuilder: | ||
knitr | ||
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
Language: en-US | ||
LazyData: true | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.2 | ||
URL: https://dfe-analytical-services.github.io/dfeshiny/ | ||
https://www.github.com/dfe-analytical-services/dfeshiny/ | ||
VignetteBuilder: knitr | ||
Depends: | ||
R (>= 2.10) | ||
LazyData: true | ||
Language: en-US |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#' Create `shiny::tagList()` for HTML section | ||
#' | ||
#' @description | ||
#' Create a list of tags that generate a HTML section. | ||
#' This generates a header using `shiny::tags$h2()` | ||
#' and a paragraph body using `shiny::tags$p()` | ||
#' | ||
#' This is to be used with functions in the `dfeshiny` package | ||
#' to add extra sections to a public R Shiny dashboard in DfE | ||
#' | ||
#' @param heading Optional - A single text string or a `shiny::tagList()` object | ||
#' for the heading of your paragraph | ||
#' @param body A single text string or a `shiny::tagList()` object | ||
#' for the body of your paragraph | ||
#' @param h_level Specify the level for your heading, if you choose to include | ||
#' one. Default is "h2". Available options are "h2","h3" or "h4". | ||
#' | ||
#' @return A list of HTML tags that contain a paragraph body and an optional heading. | ||
#' @seealso [support_panel()] | ||
#' @seealso [htmltools::tags] | ||
#' @seealso [htmltools::tagList()] | ||
#' @export | ||
#' | ||
#' @examples | ||
#' | ||
#' # Example for text heading and body | ||
#' section_tags( | ||
#' heading = "Heading test", | ||
#' body = "This is a body text test" | ||
#' ) | ||
#' | ||
#' # Example for using a different heading level | ||
#' section_tags( | ||
#' heading = "Heading test", | ||
#' body = "This is a body text test", | ||
#' h_level = "h3" | ||
#' ) | ||
#' | ||
#' | ||
#' # Example for text heading and text with other elements in the body | ||
#' | ||
#' | ||
#' section_tags( | ||
#' heading = "Heading test", | ||
#' body = shiny::tagList( | ||
#' "This is a body text test. Please contact us at", | ||
#' dfeshiny::external_link( | ||
#' href = paste0("mailto:", "team@@education.gov.uk"), | ||
#' link_text = "team@@education.gov.uk", | ||
#' add_warning = FALSE | ||
#' ) | ||
#' ) | ||
#' ) | ||
#' | ||
section_tags <- function(heading = NULL, | ||
body, | ||
h_level = "h2") { | ||
# check that a body has been provided | ||
|
||
if (missing(body)) { | ||
stop("Please provide a single text string or a `shiny::tagList()` object for the | ||
'body' argument") | ||
} | ||
|
||
# check that h_level is an accepted one | ||
|
||
if (!h_level %in% c("h2", "h3", "h4")) { | ||
stop("You used an unavailable h_level option. | ||
Please use one of the following levels: 'h2','h3'or 'h4'") | ||
} | ||
|
||
# check for combined vector wrapping | ||
# if a vector is provided and its length is >1 then it's a combined vector | ||
|
||
if (is.vector(heading) && length(heading) > 1) { | ||
stop("You provided a vector for the heading argument wrapped in c(). | ||
Please wrap it in shiny::tagList() instead.") | ||
} | ||
|
||
if (is.vector(body) && length(body) > 1) { | ||
stop("You provided a vector for the body argument wrapped in c(). | ||
Please wrap it in shiny::tagList() instead.") | ||
} | ||
|
||
# if headings are provided, do a check for h_level | ||
if (!is.null(heading)) { | ||
# if h_level = "h4" | ||
if (h_level == "h4") { | ||
result <- shiny::tagList( | ||
shiny::tags$h4( | ||
heading | ||
), | ||
shiny::tags$p( | ||
body | ||
) | ||
) | ||
# if h_level = "h4" | ||
} else if (h_level == "h3") { | ||
result <- shiny::tagList( | ||
shiny::tags$h3( | ||
heading | ||
), | ||
shiny::tags$p( | ||
body | ||
) | ||
) | ||
} else { | ||
# otherwise, use h2 | ||
result <- shiny::tagList( | ||
shiny::tags$h2( | ||
heading | ||
), | ||
shiny::tags$p( | ||
body | ||
) | ||
) | ||
} | ||
# if no heading is provided, just output the body | ||
} else { | ||
result <- shiny::tagList( | ||
shiny::tags$p( | ||
body | ||
) | ||
) | ||
} | ||
|
||
|
||
return(result) | ||
} |
Oops, something went wrong.