Skip to content

Commit

Permalink
PR response
Browse files Browse the repository at this point in the history
  • Loading branch information
cjrace committed Jul 23, 2024
1 parent f3505d9 commit d6fcc1e
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 205 deletions.
83 changes: 42 additions & 41 deletions R/cookies.R
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
#' dfe_cookie_script
#'
#' Calls in JavaScript dependencies to the shiny app. Function should be placed
#' in the ui.R script.
#' Calls in JavaScript dependencies to the shiny app used to set and unset the
#' cookies. Function should be placed in the ui.R script.
#'
#' @name cookies
#' @return shiny::tags$head()
#' @export
#'
#' @family cookies
#' @examples
#' # This example shows how to use the full family of cookie functions together
#' # This will be in your global.R script =====================================
#' if (interactive()) {
#' # This example shows how to use the full family of cookie functions together
#' # This will be in your global.R script =====================================
#'
#' library(shiny)
#' library(shinyjs)
#' library(dfeshiny)
#' ga_key <- "ABCDE12345"
#' library(shiny)
#' library(shinyjs)
#' library(dfeshiny)
#' ga_key <- "ABCDE12345"
#'
#' # This will be what is in your ui.R script =================================
#' # This will be what is in your ui.R script =================================
#'
#' ui <- fluidPage(
#' # Place these lines above your header ------------------------------------
#' dfe_cookie_script(),
#' useShinyjs(),
#' cookie_banner_ui(name = "My DfE R-Shiny data dashboard"),
#' ui <- fluidPage(
#' # Place these lines above your header ------------------------------------
#' dfe_cookie_script(),
#' useShinyjs(),
#' cookie_banner_ui(name = "My DfE R-Shiny data dashboard"),
#'
#' # Place the cookies panel under the header but in the main content -------
#' cookies_panel_ui(google_analytics_key = ga_key)
#' )
#' # Place the cookies panel under the header but in the main content -------
#' cookies_panel_ui(google_analytics_key = ga_key)
#' )
#'
#' # This will be in your server.R file =======================================
#' # This will be in your server.R file =======================================
#'
#' server <- function(input, output, session) {
#' # Server logic for the pop up banner, can be placed anywhere in server.R -
#' output$cookie_status <- dfeshiny::cookie_banner_server(
#' input_cookies = reactive(input$cookies),
#' google_analytics_key = ga_key
#' )
#' server <- function(input, output, session) {
#' # Server logic for the pop up banner, can be placed anywhere in server.R -
#' output$cookie_status <- dfeshiny::cookie_banner_server(
#' input_cookies = reactive(input$cookies),
#' google_analytics_key = ga_key
#' )
#'
#' # Server logic for the panel, can be placed anywhere in server.R ---------
#' cookies_panel_server(
#' input_cookies = reactive(input$cookies),
#' google_analytics_key = ga_key
#' )
#' }
#' # Server logic for the panel, can be placed anywhere in server.R ---------
#' cookies_panel_server(
#' input_cookies = reactive(input$cookies),
#' google_analytics_key = ga_key
#' )
#' }
#'
#' # How to run the minimal app give in this example ==========================
#' if (interactive()) {
#' # How to run the minimal app given in this example =========================
#' shinyApp(ui, server)
#' }
#'
dfe_cookie_script <- function() {
shiny::tags$head(
shiny::tags$script(
Expand All @@ -71,7 +70,8 @@ dfe_cookie_script <- function() {
#' functionality is provided by cookie_banner_server(), whilst users will also
#' need to include the dfe_cookie_script() function in their ui.R file.
#'
#' @param id Shiny tag shared with cookie_banner_server()
#' @param id Shiny tag shared with cookie_banner_server(), can be any string set
#' by the user as long as it matches the id in the cookie_banner_server()
#' @param name Name of the dashboard on which the cookie authorisation is being
#' applied
#'
Expand Down Expand Up @@ -138,10 +138,10 @@ cookie_banner_ui <- function(id = "cookies_banner", name = "DfE R-Shiny dashboar
#' reject cookie consent for the provision of Google Analytics tracking on DfE
#' R-Shiny dashboards.
#'
#' @param id Shiny tag shared with cookie_banner_ui()
#' @param id Shiny tag shared with cookie_banner_ui(), can be any string set by
#' the user as long as it matches the id in the cookie_banner_ui()
#' @param input_cookies The cookie input passed from cookies.js (should always
#' be reactive(input$cookies))
#' Should always be set to reactive(input$cookie_consent_clear).
#' be `reactive(input$cookies)`)
#' @param parent_session This should be the R Shiny app session
#' @param google_analytics_key Provide the GA 10 digit key of the form
#' "ABCDE12345"
Expand Down Expand Up @@ -285,11 +285,11 @@ init_cookies <- function() {
#' Create the standard DfE R-Shiny cookies dashboard panel in the ui. The server
#' side functionality is provided by cookies_panel_server()
#'
#' @param id ID shared with cookies_panel_server()
#' @param id Shiny tag shared with cookies_panel_server(), can be any string set by
#' the user as long as it matches the id in the cookies_panel_server()
#' @param google_analytics_key Provide the GA 10 digit key of the form
#' "ABCDE12345"
#'
#'
#' @return a standardised panel for a public R Shiny dashboard in DfE
#' @export
#' @inherit cookies examples
Expand Down Expand Up @@ -399,9 +399,10 @@ cookies_panel_ui <- function(id = "cookies_panel", google_analytics_key = NULL)
#' Create the server module of DfE R-Shiny cookies dashboard panel to be used
#' alongside cookies_panel_ui().
#'
#' @param id ID shared with cookies_panel_ui()
#' @param id Shiny tag shared with cookies_panel_ui(), can be any string set by
#' the user as long as it matches the id in the cookies_panel_ui()
#' @param input_cookies The cookie input passed from cookies.js (should always
#' be reactive(input$cookies))
#' be `reactive(input$cookies))`
#' @param google_analytics_key Provide the GA 10 digit key of the form
#' "ABCDE12345"
#'
Expand Down
67 changes: 33 additions & 34 deletions man/cookie_banner_server.Rd

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

64 changes: 32 additions & 32 deletions man/cookie_banner_ui.Rd

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

Loading

0 comments on commit d6fcc1e

Please sign in to comment.