## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(shinyGovstyle)

## ----eval = FALSE-------------------------------------------------------------
# ui <- gov_page(
#   title = "My dashboard",
#   # header(), footer(), and the rest of your page go here
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_page(
#   width = "standard", # or "three-quarters", or a CSS length like "1400px"
#   # ...
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_page(
#   width = "three-quarters",
#   header(...),
#   gov_main_layout(...),
#   footer(..., width = "standard") # this one stays at the standard width
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_page(
#   width = "full",
#   gov_main_layout(
#     shiny::tags$div(
#       class = "govuk-!-width-two-thirds",
#       gov_text("Readable body text stays narrow, even on a wide page.")
#     ),
#     govTable(my_wide_data)
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# skip_to_main()

## ----eval = FALSE-------------------------------------------------------------
# shinyjs::useShinyjs()
# cookieBanner("My service name")

## ----eval = FALSE-------------------------------------------------------------
# header(
#   org_name = "Department for Education",
#   service_name = "My dashboard"
# )

## ----eval = FALSE-------------------------------------------------------------
# phase_banner(
#   inputId = "phase-banner",
#   type = "Beta",
#   feedback_url = "https://example.com/feedback"
# )

## ----eval = FALSE-------------------------------------------------------------
# phase_banner(
#   inputId = "phase-banner",
#   type = "Beta",
#   label = shiny::tagList(
#     "This is a new service \u2014 your ",
#     shiny::tags$a(class = "govuk-link", href = "#", "feedback"),
#     " will help us to improve it."
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# # Minimal footer
# footer()
# 
# # Footer with support links
# footer(
#   links = c(
#     `Accessibility statement` = "accessibility_footer_link",
#     `Cookies` = "cookies_footer_link"
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_main_layout(
#   # your content here
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_main_layout(
#   heading_text("Page title", size = "l"),
#   gov_text("Some introductory text."),
#   govTable(my_data)
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_page(
#   width = "standard",
#   gov_main_layout(
#     shiny::tags$div(
#       class = "govuk-!-width-two-thirds",
#       heading_text("Cookies", size = "l"),
#       gov_text("This page explains how we use cookies.")
#     )
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_main_layout(
#   gov_row(
#     # columns go here
#   ),
#   gov_row(
#     # another row
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# gov_main_layout(
#   gov_row(
#     gov_box(
#       size = "two-thirds",
#       heading_text("Main content", size = "l"),
#       # inputs, text, etc.
#     ),
#     gov_box(
#       size = "one-third",
#       heading_text("Sidebar", size = "m"),
#       # supporting content
#     )
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# service_navigation(
#   c(
#     "Summary" = "nav_summary",
#     "Detailed data" = "nav_detail",
#     "User guide" = "nav_guide"
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# # ui.R — shiny tabsetPanel
# shiny::tabsetPanel(
#   type = "hidden",
#   id = "main_panels",
#   shiny::tabPanel("Summary",       value = "summary",       "Content"),
#   shiny::tabPanel("Detailed data", value = "detailed_data", "Content"),
#   shiny::tabPanel("User guide",    value = "user_guide",    "Content")
# )
# 
# # server.R — auto-wire the nav links to the panels
# shinyGovstyle::service_navigation_server(
#   session,
#   tabset_id = "main_panels",
#   link_to_panel = c(
#     nav_summary  = "summary",
#     nav_detail   = "detailed_data",
#     nav_guide    = "user_guide"
#   )
# )

## ----eval = FALSE-------------------------------------------------------------
# # server.R — programmatic navigation in one call
# shiny::observeEvent(input$next_btn, {
#   shinyGovstyle::navigate_to(
#     session, "main_panels",
#     inputId = "nav_detail", panel = "detailed_data"
#   )
# })

## ----eval = FALSE-------------------------------------------------------------
# # ui.R — footer link, no entry in service_navigation()
# footer(
#   full = TRUE,
#   links = c(`Accessibility statement` = "accessibility_footer_link")
# )
# 
# # ui.R — tab panel exists in the hidden tabset but not in service_navigation()
# shiny::tabsetPanel(
#   type = "hidden",
#   id = "main_panels",
#   shiny::tabPanel("Summary", value = "nav_summary", "Content"),
#   shiny::tabPanel("Accessibility statement", value = "accessibility_panel",
#                   "Content")
# )
# 
# # server.R — navigate to the footer page (no update_service_navigation needed)
# shiny::observeEvent(input$accessibility_footer_link, {
#   shiny::updateTabsetPanel(session, "main_panels",
#                            selected = "accessibility_panel")
#   shinyGovstyle::update_page_title(
#     session,
#     page_title = "Accessibility statement",
#     service_name = "My dashboard"
#   )
# })

## ----eval = FALSE-------------------------------------------------------------
# library(shiny)
# library(shinyGovstyle)
# 
# ui <- gov_page(
#   title = "Summary | My dashboard",
#   skip_to_main(),
#   header(
#     org_name = "My department",
#     service_name = "My dashboard"
#   ),
#   service_navigation(
#     c(
#       "Summary"  = "nav_summary",
#       "About"    = "nav_about"
#     ),
#     page_title_suffix = "My dashboard"
#   ),
#   phase_banner(
#     inputId = "phase",
#     type = "Beta",
#     label = "This is a new service."
#   ),
# 
#   gov_main_layout(
#     shiny::tabsetPanel(
#       type = "hidden",
#       id = "main_panels",
# 
#       shiny::tabPanel(
#         "Summary", value = "nav_summary",
#         gov_row(
#           gov_box(
#             size = "two-thirds",
#             heading_text("Summary", size = "l"),
#             gov_text("Welcome to the summary page.")
#           ),
#           gov_box(
#             size = "one-third",
#             heading_text("Quick facts", size = "m"),
#             gov_text("Supporting information goes here.")
#           )
#         )
#       ),
# 
#       shiny::tabPanel(
#         "About", value = "nav_about",
#         # Text-only page: two-thirds keeps it readable even though the
#         # app itself uses gov_page(width = "full"). See "Content width
#         # vs page width" above.
#         shiny::tags$div(
#           class = "govuk-!-width-two-thirds",
#           heading_text("About this dashboard", size = "l"),
#           gov_text("This page describes the dashboard.")
#         )
#       ),
# 
#       shiny::tabPanel(
#         "Accessibility statement", value = "accessibility_panel",
#         shiny::tags$div(
#           class = "govuk-!-width-two-thirds",
#           heading_text("Accessibility statement", size = "l"),
#           gov_text("This page describes the accessibility of the dashboard.")
#         )
#       )
#     )
#   ),
# 
#   footer(
#     links = c(`Accessibility statement` = "accessibility_footer_link")
#   )
# )
# 
# server <- function(input, output, session) {
#   service_navigation_server(
#     session,
#     tabset_id = "main_panels",
#     link_to_panel = c("nav_summary", "nav_about")
#   )
# 
#   shiny::observeEvent(input$accessibility_footer_link, {
#     shiny::updateTabsetPanel(session, "main_panels",
#                              selected = "accessibility_panel")
#     update_page_title(
#       session,
#       page_title = "Accessibility statement",
#       service_name = "My dashboard"
#     )
#   })
# }
# 
# shiny::shinyApp(ui, server)

