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 3 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
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
36 changes: 36 additions & 0 deletions R/header.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#' DfE header banner
#'
#' @description
#' This function uses `shinyGovstyle::header()` to create a header banner
#' using the DfE logo.
#'
#' @param secondary_text Secondary header to supplement the main text
#' @param secondary_link Add a link for clicking on secondary header
#' @return a header html shiny object
#'
#' @seealso [shinyGovstyle::header()]
#' @export
#' @examples
#'
#' if (interactive()) {
#' ui <- fluidPage(
#' dfeshiny::header(
#' secondary_text = "User Examples"
#' )
#' )
#'
#' server <- function(input, output, session) {}
#'
#' shinyApp(ui = ui, server = server)
#' }
header <- function(secondary_text,
mzayeddfe marked this conversation as resolved.
Show resolved Hide resolved
secondary_link = "#") {
shinyGovstyle::header(
rmbielby marked this conversation as resolved.
Show resolved Hide resolved
logo = "/dfeshiny/DfE_logo_landscape.png",
main_text = "",
secondary_text = secondary_text,
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.
37 changes: 37 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.

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(secondary_text = "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