This function creates a cookie banner. You need to have
shinyjs::useShinyjs() enabled for this to work. All the Ids are preset.
See example for how to structure.
Arguments
- service_name
Name for this service to add to banner
- width
Width of the component. One of
"standard"(the default, GOV.UK's usual 960px content width),"three-quarters"(three-quarters of the viewport, never narrower than standard),"full"(no max-width, so the container fills the viewport, with grid gutters also removed), or a CSS length (e.g."1400px","90vw") for a custom max-width.
See also
Other Govstyle page structure:
banner(),
footer(),
gov_layout(),
gov_page(),
header(),
layouts,
skip_to_main()
Examples
ui <- shinyGovstyle::gov_page(
shinyGovstyle::header(
org_name = "Example",
service_name = "User Examples",
logo="shinyGovstyle/images/moj_logo.png"),
#Needs shinyjs to work
shinyjs::useShinyjs(),
shinyGovstyle::cookieBanner("The best thing"),
shinyGovstyle::gov_layout(size = "two-thirds"),
shinyGovstyle::footer(full = TRUE)
)
server <- function(input, output, session) {
# Set of observeEvent to create a path through the cookie banner
observeEvent(input$cookieAccept, {
shinyjs::show(id = "cookieAcceptDiv")
shinyjs::hide(id = "cookieMain")
})
observeEvent(input$cookieReject, {
shinyjs::show(id = "cookieRejectDiv")
shinyjs::hide(id = "cookieMain")
})
observeEvent(input$hideAccept, {
shinyjs::toggle(id = "cookieDiv")
})
observeEvent(input$hideReject, {
shinyjs::toggle(id = "cookieDiv")
})
observeEvent(input$cookieLink, {
# Need to link here to where further info is located. You can use
# updateTabsetPanel to have a cookie page for instance
})
}
if (interactive()) shinyApp(ui = ui, server = server)
