Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dfeshiny header #62

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dfeshiny
Title: DfE R Shiny Standards
Version: 0.5.1
Version: 0.5.1.9000
Authors@R: c(
person("Rich", "Bielby", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9070-9969")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(cookies_panel_ui)
export(custom_disconnect_message)
export(dfe_cookies_script)
export(external_link)
export(header)
export(init_analytics)
export(init_cookies)
export(section_tags)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# dfeshiny (development version)

* Added `dfeshiny::header()` function which uses `shinyGovstyle::header()` but it
automatically uses the DfE logo.

# dfeshiny 0.5.1

* Refresh of disconnect dialogue message and styling
Expand Down
34 changes: 34 additions & 0 deletions R/header.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' DfE header banner
#'
#' @description
#' This function uses `shinyGovstyle::header()` to create a header banner
#' using the DfE logo.
#'
#' @param header Text to use for the header of the dashboard
#' @return a header html shiny object
#'
#' @seealso [shinyGovstyle::header()]
#' @export
#' @examples
#'
#' if (interactive()) {
#' ui <- fluidPage(
#' dfeshiny::header(
#' header = "User Examples"
#' )
#' )
#'
#' server <- function(input, output, session) {}
#'
#' shinyApp(ui = ui, server = server)
#' }
header <- function(header) {
shinyGovstyle::header(
rmbielby marked this conversation as resolved.
Show resolved Hide resolved
logo = "/dfeshiny/DfE_logo_landscape.png",
main_text = "",
secondary_text = header,
main_link = "https://www.gov.uk/government/organisations/department-for-education",
logo_width = 132.98,
logo_height = 32
)
}
2 changes: 1 addition & 1 deletion R/support_panel.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' @return a HTML div, containing standard support content for a public R Shiny
#' dashboard in DfE
#' @seealso [section_tags()]
#' @seealso [htmltool::tagList()]
#' @seealso [htmltools::tagList()]
#' @export
#'
#' @examples
Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ reference:
contents:
- support_panel
- section_tags
- title: Header
desc: A wrapper for shinyGovstyle::header() that automatically uses the DfE logo.
contents:
- header
Binary file added inst/www/DfE_logo_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions man/header.Rd

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

4 changes: 2 additions & 2 deletions man/section_tags.Rd

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

2 changes: 2 additions & 0 deletions man/support_panel.Rd

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

4 changes: 4 additions & 0 deletions tests/test_dashboard/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ ui <- function(input, output, session) {
shiny::fluidPage(
shinyjs::useShinyjs(),

# header function ---------------------------------------------------------

dfeshiny::header("Header Example"),

# Custom disconnect =======================================================
custom_disconnect_message(
refresh = "Refresh page",
Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-header.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# create output for testing

output <- dfeshiny::header(header = "hello")


test_that("outputs are as expected", {
expect_equal(
paste(
output$children[[2]]$children[[2]]$children[[1]]$children[[1]]
),
"hello"
)

expect_equal(
paste(
output[["children"]][[2]][["children"]][[1]][["children"]][[1]]
[["children"]][[1]][["children"]][[1]][["attribs"]][["src"]]
),
"/dfeshiny/DfE_logo_landscape.png"
)
})
Loading