From 4e2c422c5c9851236aab5d95fe9267510be36874 Mon Sep 17 00:00:00 2001 From: Juliette Engelaere-Lefebvre Date: Wed, 19 Jul 2023 21:00:59 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Amelioration=20header=5Fdfr=20:=20possibili?= =?UTF-8?q?t=C3=A9=20d'avoir=20l'intitul=C3=A9=20sur=203=20ligne=20avec=20?= =?UTF-8?q?un=20vecteur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dsl bcp de modifs juste liée à fusen:inflate 0 errors ✔ | 0 warnings ✔ | 4 notes ✖ --- .gitignore | 1 + R/app_ui.R | 2 +- R/column_dsfr.R | 2 +- R/convert_file_to_dsfr.R | 14 ++++++----- R/fluidpage_dsfr.R | 2 +- R/fluidpage_dsfr_template.R | 2 +- R/fluidrow_dsfr.R | 2 +- R/get_dsfr_version.R | 2 +- R/header_dsfr.R | 14 +++++++---- R/header_dsfr_template.R | 2 +- R/layout_dsfr_template.R | 2 +- dev/flat_composants/flat_header.Rmd | 25 +++++++++++++------ dev/tools/flat_convert_to_dsfr.Rmd | 2 +- man/header_dsfr.Rd | 10 +++++--- tests/testthat/test-column_dsfr.R | 2 +- tests/testthat/test-convert_file_to_dsfr.R | 14 +++++------ tests/testthat/test-convert_to_dsfr.R | 9 +++---- tests/testthat/test-fluidpage_dsfr.R | 2 +- tests/testthat/test-fluidpage_dsfr_template.R | 2 +- tests/testthat/test-fluidrow_dsfr.R | 2 +- tests/testthat/test-header_dsfr.R | 9 +++++-- tests/testthat/test-header_dsfr_template.R | 6 ++--- tests/testthat/test-layout_dsfr_template.R | 2 +- 23 files changed, 75 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index f5b67292..08e1f000 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ docs inst/doc rsconnect deliverables +zz_rsconnect* diff --git a/R/app_ui.R b/R/app_ui.R index 0d9a6b5f..dcd48c8a 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -13,7 +13,7 @@ app_ui <- function(request) { title = "shinygouv", id = "nav", header = header_dsfr( - intitule = span("D\u00e9mo", br(), "de", br(), "{shinygouv}"), + intitule = c("D\u00e9mo", "de", "{shinygouv}"), nom_site_service = "Bienvenue sur l\'application de d\u00e9monstration de {shinygouv}", baseline = "https://github.com/spyrales/shinygouv" ), diff --git a/R/column_dsfr.R b/R/column_dsfr.R index ee38204f..c3cdba2d 100644 --- a/R/column_dsfr.R +++ b/R/column_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand #' column_dsfr #' diff --git a/R/convert_file_to_dsfr.R b/R/convert_file_to_dsfr.R index c36a8cba..8c4003a5 100644 --- a/R/convert_file_to_dsfr.R +++ b/R/convert_file_to_dsfr.R @@ -14,26 +14,28 @@ #' @return un fichier #' @noRd convert_file_to_dsfr <- function(file, tab_corresp) { + # verifie que c'est bien un fichier et non un dossier if (isTRUE(file_test("-f", file))) { + message(glue::glue("scan {file}")) file_read <- readLines(file) - + if (isTRUE(grep("tabPanel", file_read) > 0)) { - message(glue::glue("Attention le {file} contient un 'tabPanel': \n - Si celui ci \u00e9tait dans un navbarPage alors le remplacer par un navbarPanel_dsfr. \n - Si celui ci \u00e9tait dans un 'tabsetPanel', alors le remplacer par un 'tabPanel_dsfr'")) + message(glue::glue("Attention le {file} contient un 'tabPanel': \n - Si celui ci \u00e9tait dans un navbarPage alors le remplacer par un navbarPanel_dsfr. \n - Si celui ci \u00e9tait dans un 'tabsetPanel', alors le remplacer par un 'tabPanel_dsfr'")) } if (isTRUE(grep("navbarPage", file_read) > 0)) { - message(glue::glue("Attention le {file} contient un 'navbarPage()', la version dsfr n\u00e9cessite un header, voir \\?navbarPage_dsfr")) + message(glue::glue("Attention le {file} contient un 'navbarPage()', la version dsfr n\u00e9cessite un header, voir \\?navbarPage_dsfr")) } - + file_convert <- purrr::reduce2( paste0(tab_corresp$composant_shiny, "\\("), paste0(tab_corresp$composant_dsfr, "\\("), .init = file_read, - stringr::str_replace_all - ) + stringr::str_replace_all) writeLines(file_convert, con = file) + } return(NULL) } diff --git a/R/fluidpage_dsfr.R b/R/fluidpage_dsfr.R index e67446df..b7c55b27 100644 --- a/R/fluidpage_dsfr.R +++ b/R/fluidpage_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand #' fluidPage_dsfr #' diff --git a/R/fluidpage_dsfr_template.R b/R/fluidpage_dsfr_template.R index ebd378c1..a7855054 100644 --- a/R/fluidpage_dsfr_template.R +++ b/R/fluidpage_dsfr_template.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand #' fluidPage_dsfr_template #' @param header entete de la page diff --git a/R/fluidrow_dsfr.R b/R/fluidrow_dsfr.R index 3f50702f..4c2f271e 100644 --- a/R/fluidrow_dsfr.R +++ b/R/fluidrow_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand #' fluidRow_dsfr #' diff --git a/R/get_dsfr_version.R b/R/get_dsfr_version.R index 1b4bb24e..6a86f746 100644 --- a/R/get_dsfr_version.R +++ b/R/get_dsfr_version.R @@ -10,7 +10,7 @@ #' get_dsfr_version() #' get_dsfr_version(with_v = TRUE) get_dsfr_version <- function(with_v = FALSE) { - res <- utils::packageDescription(pkg = "shinygouv")[["VersionDsfr"]] + res <- utils::packageDescription(pkg = 'shinygouv')[["VersionDsfr"]] if (isTRUE(with_v)) { res <- paste0("v", res) } diff --git a/R/header_dsfr.R b/R/header_dsfr.R index cae2b70f..d245ec94 100644 --- a/R/header_dsfr.R +++ b/R/header_dsfr.R @@ -1,8 +1,8 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_header.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_header.Rmd: do not edit by hand #' header_dsfr -#' -#' @param intitule la partie "intitule" du bloc marque +#' Vous pouvez ajouter le header officiel dans votre application avec `header_dsfr()`. +#' @param intitule la partie "intitule" du bloc marque. Utiliser un `shiny::tags$span()`pour mettre l'intitulé sur plusieurs lignes ou un vecteur. #' @param url l url de redirection - optionnel #' @param titre le texte de description de l url - optionnel #' @param nom_site_service le nom du site ou du service - optionnel @@ -15,11 +15,11 @@ #' if(interactive()) { #' library(shiny) #' header_dsfr( -#' intitule = span("Prefet", br(), "de", br(), "Bretagne") +#' intitule = c("Pr\u00e9fet", "de", "Bretagne") #' ) #' } header_dsfr <- function( - intitule, + intitule = c("intitul\u00e9", "du", 'bloc-marque'), url = "/", titre = NULL, nom_site_service = NULL, @@ -29,6 +29,10 @@ header_dsfr <- function( # check les params # assertthat::assert_that(is.character(intitule)) # TODO verifier que l url est valide + + if(is.vector(intitule) & length(intitule) > 1){ + intitule <- span(HTML(paste0(intitule, collapse = "
"))) + } res <- header_dsfr_template( class = class, diff --git a/R/header_dsfr_template.R b/R/header_dsfr_template.R index 368d8048..ee3f0f56 100644 --- a/R/header_dsfr_template.R +++ b/R/header_dsfr_template.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_header.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_header.Rmd: do not edit by hand #' header_dsfr_template #' @param intitule la partie "intitule" du bloc marque. Utiliser un `shiny::tags$span()`pour mettre l'intitulé sur plusieurs lignes diff --git a/R/layout_dsfr_template.R b/R/layout_dsfr_template.R index 5b83a0c6..e6b884a2 100644 --- a/R/layout_dsfr_template.R +++ b/R/layout_dsfr_template.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand #' layout_dsfr_template #' diff --git a/dev/flat_composants/flat_header.Rmd b/dev/flat_composants/flat_header.Rmd index 84ed7c67..bcc2fbad 100644 --- a/dev/flat_composants/flat_header.Rmd +++ b/dev/flat_composants/flat_header.Rmd @@ -20,7 +20,7 @@ Vous pouvez ajouter le header officiel dans votre application avec `header_dsfr( ```{r, eval=FALSE} fluidPage_dsfr( header = header_dsfr( - intitule = span("Intitulé", br(), "sur 3", br(), "lignes"), + intitule = c("Intitul\u00e9", "sur 3", "lignes"), nom_site_service = "Nom du site / service", baseline = "baseline - precisions sur l organisation", class = "fr-m-1w" @@ -103,7 +103,7 @@ test_that("header_dsfr_template works", { class = "class", intitule = "Prefet de Bretagne", url = "https://www.prefectures-regions.gouv.fr/bretagne", - titre = "Accueil - Préfecture de Bretagne", + titre = "Accueil - Pr\u00e9fecture de Bretagne", nom_site_service = "DREAL Bretagne", baseline = "description" ) @@ -119,7 +119,7 @@ test_that("header_dsfr_template works", { class = "class", intitule = "Prefet de Bretagne", url = "https://www.prefectures-regions.gouv.fr/bretagne", - titre = "Accueil - Préfecture de Bretagne", + titre = "Accueil - Pr\u00e9fecture de Bretagne", nom_site_service = "DREAL Bretagne", baseline = "description" ), @@ -138,8 +138,8 @@ test_that("header_dsfr_template works", { ```{r function-header_dsfr} #' header_dsfr -#' -#' @param intitule la partie "intitule" du bloc marque +#' Vous pouvez ajouter le header officiel dans votre application avec `header_dsfr()`. +#' @param intitule la partie "intitule" du bloc marque. Utiliser un `shiny::tags$span()`pour mettre l'intitulé sur plusieurs lignes ou un vecteur. #' @param url l url de redirection - optionnel #' @param titre le texte de description de l url - optionnel #' @param nom_site_service le nom du site ou du service - optionnel @@ -150,7 +150,7 @@ test_that("header_dsfr_template works", { #' #' @examples header_dsfr <- function( - intitule, + intitule = c("intitul\u00e9", "du", 'bloc-marque'), url = "/", titre = NULL, nom_site_service = NULL, @@ -160,6 +160,10 @@ header_dsfr <- function( # check les params # assertthat::assert_that(is.character(intitule)) # TODO verifier que l url est valide + + if(is.vector(intitule) & length(intitule) > 1){ + intitule <- span(HTML(paste0(intitule, collapse = "
"))) + } res <- header_dsfr_template( class = class, @@ -179,7 +183,7 @@ header_dsfr <- function( if(interactive()) { library(shiny) header_dsfr( - intitule = span("Prefet", br(), "de", br(), "Bretagne") + intitule = c("Pr\u00e9fet", "de", "Bretagne") ) } ``` @@ -187,11 +191,14 @@ if(interactive()) { ```{r tests-header_dsfr} test_that("header_dsfr works", { test_html <- header_dsfr( + intitule = c("Prefet", "de", "Bretagne") + ) + test_html2 <- header_dsfr( intitule = shiny::tags$span("Prefet", br(), "de", br(), "Bretagne") ) #' @description tester si shiny.tag expect_s3_class(test_html, "shiny.tag") - + expect_s3_class(test_html2, "shiny.tag") ## lecture snapshot snapshot_html <- readRDS( file = file.path( @@ -205,6 +212,8 @@ test_that("header_dsfr works", { # Pour eviter les problèmes inter-OS expect_equal(gsub("\\s|\\n", "", test_html), gsub("\\s|\\n", "", snapshot_html)) + expect_equal(gsub("\\s|\\n", "", test_html2), + gsub("\\s|\\n", "", snapshot_html)) # Si erreur au précedent test deux cas possible : # diff --git a/dev/tools/flat_convert_to_dsfr.Rmd b/dev/tools/flat_convert_to_dsfr.Rmd index 14bbcd23..e2fa5669 100644 --- a/dev/tools/flat_convert_to_dsfr.Rmd +++ b/dev/tools/flat_convert_to_dsfr.Rmd @@ -238,7 +238,7 @@ test_that("convert_to_dsfr works", { expect_error(convert_to_dsfr(path = file.path(mydir, "R"), version = NULL)) #' @description Retourne une erreur si le tableau de correspondance n'existe pas pour la version specifiee - expect_error(convert_to_dsfr(path = file.path(mydir, "R"), version = "A.A.A.A"), msg = "Le dossier 'vA.A.A.A' n'existe pas") + expect_error(convert_to_dsfr(path = file.path(mydir, "R"), version = "A.A.A.A"), "Le dossier 'vA.A.A.A' n existe pas") expect_error(convert_to_dsfr(path = file.path(mydir, "R")), regexp = NA) app_ui <- readLines(file.path(mydir, "R", "app_ui.R")) diff --git a/man/header_dsfr.Rd b/man/header_dsfr.Rd index 0a851b17..d921294a 100644 --- a/man/header_dsfr.Rd +++ b/man/header_dsfr.Rd @@ -2,10 +2,11 @@ % Please edit documentation in R/header_dsfr.R \name{header_dsfr} \alias{header_dsfr} -\title{header_dsfr} +\title{header_dsfr +Vous pouvez ajouter le header officiel dans votre application avec \code{header_dsfr()}.} \usage{ header_dsfr( - intitule, + intitule = c("intitulé", "du", "bloc-marque"), url = "/", titre = NULL, nom_site_service = NULL, @@ -14,7 +15,7 @@ header_dsfr( ) } \arguments{ -\item{intitule}{la partie "intitule" du bloc marque} +\item{intitule}{la partie "intitule" du bloc marque. Utiliser un \code{shiny::tags$span()}pour mettre l'intitulé sur plusieurs lignes ou un vecteur.} \item{url}{l url de redirection - optionnel} @@ -31,12 +32,13 @@ html } \description{ header_dsfr +Vous pouvez ajouter le header officiel dans votre application avec \code{header_dsfr()}. } \examples{ if(interactive()) { library(shiny) header_dsfr( - intitule = span("Prefet", br(), "de", br(), "Bretagne") + intitule = c("Pr\u00e9fet", "de", "Bretagne") ) } } diff --git a/tests/testthat/test-column_dsfr.R b/tests/testthat/test-column_dsfr.R index 90fa73cb..57367d71 100644 --- a/tests/testthat/test-column_dsfr.R +++ b/tests/testthat/test-column_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand test_that("column_dsfr works", { expect_true(inherits(column_dsfr, "function")) diff --git a/tests/testthat/test-convert_file_to_dsfr.R b/tests/testthat/test-convert_file_to_dsfr.R index 12661771..c56ee221 100644 --- a/tests/testthat/test-convert_file_to_dsfr.R +++ b/tests/testthat/test-convert_file_to_dsfr.R @@ -1,6 +1,7 @@ # WARNING - Generated by {fusen} from /dev/tools/flat_convert_to_dsfr.Rmd: do not edit by hand test_that("convert_file_to_dsfr works", { + skip_on_ci() library(tibble) @@ -16,10 +17,8 @@ test_that("convert_file_to_dsfr works", { open = FALSE ) - table_passage <- tibble( - composant_shiny = c("actionButton", "fluidPage"), - composant_dsfr = c("actionButton_dsfr", "fluidPage_dsfr") - ) + table_passage <- tibble(composant_shiny = c("actionButton", "fluidPage"), + composant_dsfr = c("actionButton_dsfr", "fluidPage_dsfr")) fichier <- file.path(mydir, "R", "app_ui.R") convert_file_to_dsfr(file = fichier, table_passage) @@ -30,10 +29,8 @@ test_that("convert_file_to_dsfr works", { expect_false(any(stringr::str_detect(fichier_transform, pattern = "fluidPage\\("))) - table_passage <- tibble( - composant_shiny = c("actionButton", "fluidPage", NA), - composant_dsfr = c("actionButton_dsfr", "fluidPage_dsfr", "header_dsfr") - ) + table_passage <- tibble(composant_shiny = c("actionButton", "fluidPage", NA), + composant_dsfr = c("actionButton_dsfr", "fluidPage_dsfr", "header_dsfr")) fichier <- file.path(mydir, "R", "app_ui.R") convert_file_to_dsfr(file = fichier, table_passage) @@ -42,4 +39,5 @@ test_that("convert_file_to_dsfr works", { #' @description les composants dsfr n ayant pas d equivalent en shiny ne sont pas remplaces expect_false(any(stringr::str_detect(fichier_transform, pattern = "header_dsfr\\("))) + }) diff --git a/tests/testthat/test-convert_to_dsfr.R b/tests/testthat/test-convert_to_dsfr.R index d171c050..c6727cea 100644 --- a/tests/testthat/test-convert_to_dsfr.R +++ b/tests/testthat/test-convert_to_dsfr.R @@ -13,16 +13,14 @@ test_that("convert_to_dsfr works", { open = FALSE ) - file.copy( - from = file.path(mydir, "R", "app_ui.R"), - to = file.path(mydir, "R", "module_ui.R") - ) + file.copy(from = file.path(mydir, "R", "app_ui.R"), + to = file.path(mydir, "R", "module_ui.R")) #' @description Retourne une erreur si le numero de version est NULL expect_error(convert_to_dsfr(path = file.path(mydir, "R"), version = NULL)) #' @description Retourne une erreur si le tableau de correspondance n'existe pas pour la version specifiee - expect_error(convert_to_dsfr(path = file.path(mydir, "R"), version = "A.A.A.A"), msg = "Le dossier 'vA.A.A.A' n'existe pas") + expect_error(convert_to_dsfr(path = file.path(mydir, "R"), version = "A.A.A.A"), "Le dossier 'vA.A.A.A' n existe pas") expect_error(convert_to_dsfr(path = file.path(mydir, "R")), regexp = NA) app_ui <- readLines(file.path(mydir, "R", "app_ui.R")) @@ -34,4 +32,5 @@ test_that("convert_to_dsfr works", { #' @description les composants dsfr n ayant pas d equivalent en shiny ne sont pas remplaces, par exemple header_dsfr expect_false(any(stringr::str_detect(app_ui, pattern = "header_dsfr\\("))) + }) diff --git a/tests/testthat/test-fluidpage_dsfr.R b/tests/testthat/test-fluidpage_dsfr.R index 639eda09..063921e8 100644 --- a/tests/testthat/test-fluidpage_dsfr.R +++ b/tests/testthat/test-fluidpage_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand test_that("fluidPage_dsfr works", { test_html <- fluidPage_dsfr( diff --git a/tests/testthat/test-fluidpage_dsfr_template.R b/tests/testthat/test-fluidpage_dsfr_template.R index ef743905..031c1f10 100644 --- a/tests/testthat/test-fluidpage_dsfr_template.R +++ b/tests/testthat/test-fluidpage_dsfr_template.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand test_that("fluidPage_dsfr_template works", { expect_true(inherits(fluidPage_dsfr_template, "function")) diff --git a/tests/testthat/test-fluidrow_dsfr.R b/tests/testthat/test-fluidrow_dsfr.R index 6a455522..77c968ca 100644 --- a/tests/testthat/test-fluidrow_dsfr.R +++ b/tests/testthat/test-fluidrow_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand test_that("fluidRow_dsfr works", { expect_true(inherits(fluidRow_dsfr, "function")) diff --git a/tests/testthat/test-header_dsfr.R b/tests/testthat/test-header_dsfr.R index 9bc1a72d..405b7417 100644 --- a/tests/testthat/test-header_dsfr.R +++ b/tests/testthat/test-header_dsfr.R @@ -1,12 +1,15 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_header.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_header.Rmd: do not edit by hand test_that("header_dsfr works", { test_html <- header_dsfr( + intitule = c("Prefet", "de", "Bretagne") + ) + test_html2 <- header_dsfr( intitule = shiny::tags$span("Prefet", br(), "de", br(), "Bretagne") ) #' @description tester si shiny.tag expect_s3_class(test_html, "shiny.tag") - + expect_s3_class(test_html2, "shiny.tag") ## lecture snapshot snapshot_html <- readRDS( file = file.path( @@ -20,6 +23,8 @@ test_that("header_dsfr works", { # Pour eviter les problèmes inter-OS expect_equal(gsub("\\s|\\n", "", test_html), gsub("\\s|\\n", "", snapshot_html)) + expect_equal(gsub("\\s|\\n", "", test_html2), + gsub("\\s|\\n", "", snapshot_html)) # Si erreur au précedent test deux cas possible : # diff --git a/tests/testthat/test-header_dsfr_template.R b/tests/testthat/test-header_dsfr_template.R index 4ead1b01..1e0bde37 100644 --- a/tests/testthat/test-header_dsfr_template.R +++ b/tests/testthat/test-header_dsfr_template.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_header.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_header.Rmd: do not edit by hand test_that("header_dsfr_template works", { expect_true(inherits(header_dsfr_template, "function")) @@ -37,7 +37,7 @@ test_that("header_dsfr_template works", { class = "class", intitule = "Prefet de Bretagne", url = "https://www.prefectures-regions.gouv.fr/bretagne", - titre = "Accueil - Préfecture de Bretagne", + titre = "Accueil - Pr\u00e9fecture de Bretagne", nom_site_service = "DREAL Bretagne", baseline = "description" ) @@ -53,7 +53,7 @@ test_that("header_dsfr_template works", { class = "class", intitule = "Prefet de Bretagne", url = "https://www.prefectures-regions.gouv.fr/bretagne", - titre = "Accueil - Préfecture de Bretagne", + titre = "Accueil - Pr\u00e9fecture de Bretagne", nom_site_service = "DREAL Bretagne", baseline = "description" ), diff --git a/tests/testthat/test-layout_dsfr_template.R b/tests/testthat/test-layout_dsfr_template.R index bf11e631..367668ba 100644 --- a/tests/testthat/test-layout_dsfr_template.R +++ b/tests/testthat/test-layout_dsfr_template.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from /dev/flat_composants/flat_fluidpage.Rmd: do not edit by hand test_that("layout_dsfr_template works", { expect_true(inherits(layout_dsfr_template, "function")) From 328ad1e0164fabce495796d309ab98ac756748db Mon Sep 17 00:00:00 2001 From: Juliette Engelaere-Lefebvre Date: Wed, 23 Aug 2023 15:52:11 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Intitul=C3=A9=20sur=20plusieurs=20lignes=20?= =?UTF-8?q?grace=20=C3=A0=20un=20vecteur=20dans=20le=20footer=20=C3=A9gale?= =?UTF-8?q?ment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DESCRIPTION | 3 +- R/footer_dsfr.R | 63 ++++++++++----- dev/config_fusen.yaml | 115 ++++++++++++++++------------ dev/flat_composants/flat_footer.Rmd | 48 ++++++------ man/footer_dsfr.Rd | 13 +++- 5 files changed, 146 insertions(+), 96 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8c6e4775..a54ead74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,6 +36,7 @@ Imports: XML (>= 3.99.0.10) Suggests: desc (>= 1.4.1), + dplyr, DT (>= 0.23), knitr (>= 1.39), readxl (>= 1.4.0), @@ -46,7 +47,7 @@ Suggests: withr (>= 2.5.0) VignetteBuilder: knitr -Config/fusen/version: 0.5.0.9001 +Config/fusen/version: 0.5.1 Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true diff --git a/R/footer_dsfr.R b/R/footer_dsfr.R index 5882e779..05190538 100644 --- a/R/footer_dsfr.R +++ b/R/footer_dsfr.R @@ -1,4 +1,4 @@ -# WARNING - Generated by {fusen} from /dev/flat_composants/flat_footer.Rmd: do not edit by hand +# WARNING - Generated by {fusen} from dev/flat_composants/flat_footer.Rmd: do not edit by hand #' footer_dsfr @@ -11,7 +11,7 @@ #' #' Il est possible d'ajouter des url supplémentaires dans le corps et le bas du pied de page. #' -#' @param intitule la partie "intitule" du bloc marque +#' @param intitule la partie "intitule" du bloc marque. Utiliser un `shiny::tags$span()`pour mettre l'intitulé sur plusieurs lignes ou un vecteur. #' @param description un texte de présentation - optionnel #' @param accessibilite le type d'accessibilité (non/partiellement/totalement conforme) #' @param lien_accessibilite lien url vers l'accessibilite @@ -30,7 +30,7 @@ #' shinyApp( #' ui = fluidPage_dsfr( #' footer = footer_dsfr( -#' intitule = "Territoire", +#' intitule = c("Territoire", "Service"), #' description = "une description", #' accessibilite = "non", #' add_extra_url_body = footer_extra_url_body_dsfr( @@ -46,7 +46,7 @@ #' ) #' ), #' add_extra_url_bottom = footer_extra_url_bottom_dsfr( -#' +#' #' footer_li_dsfr( #' href = "https://siteinternet.fr", #' titre = "siteinternet.fr.fr - nouvelle fenêtre", @@ -81,8 +81,8 @@ #' ) #' } footer_dsfr <- function( - intitule = NULL , - description = NULL , + intitule = NULL, + description = NULL, accessibilite = "non", lien_accessibilite = "#", lien_mentions_legales = "#", @@ -92,27 +92,30 @@ footer_dsfr <- function( add_extra_url_bottom = NULL) { - if ( isFALSE(accessibilite %in% c("non", "partiellement", "totalement conforme"))){ - stop("l accessibilite doit etre 'non', 'partiellement' ou 'totalement conforme'") - } - - assertthat::assert_that(is.character(lien_accessibilite)) - assertthat::assert_that(is.character(lien_mentions_legales)) - assertthat::assert_that(is.character(lien_donnees_personnelles)) - assertthat::assert_that(is.character(lien_gestion_cookies)) - - + if ( isFALSE(accessibilite %in% c("non", "partiellement", "totalement conforme"))){ + stop("l accessibilite doit etre 'non', 'partiellement' ou 'totalement conforme'") + } + + assertthat::assert_that(is.character(lien_accessibilite)) + assertthat::assert_that(is.character(lien_mentions_legales)) + assertthat::assert_that(is.character(lien_donnees_personnelles)) + assertthat::assert_that(is.character(lien_gestion_cookies)) + + if(is.vector(intitule) & length(intitule) > 1){ + intitule <- span(HTML(paste0(intitule, collapse = "
"))) + } + footer_dsfr_template( intitule = intitule, description = description, footer_body = add_extra_url_body, footer_bottom = add_extra_url_bottom, - accessibilite = accessibilite, - lien_accessibilite = lien_accessibilite, - lien_mentions_legales = lien_mentions_legales, - lien_donnees_personnelles = lien_donnees_personnelles, - lien_gestion_cookies = lien_gestion_cookies + accessibilite = accessibilite, + lien_accessibilite = lien_accessibilite, + lien_mentions_legales = lien_mentions_legales, + lien_donnees_personnelles = lien_donnees_personnelles, + lien_gestion_cookies = lien_gestion_cookies ) } @@ -137,6 +140,24 @@ footer_extra_url_body_dsfr <- function(...) { +#' footer_extra_url_bottom_dsfr +#' +#' Permet d'ajouter des liends/url dans le bas du pied de page +#' +#' @param ... d'autre liens de références (voir `footer_li_dsfr()`) +#' +#' @return html +#' @rdname footer_dsfr +#' @export +#' @examples +#' footer_extra_url_bottom_dsfr(footer_li_dsfr(href = "http://siteinternet.fr", texte = "siteinternet.fr")) +footer_extra_url_bottom_dsfr <- + function(...) { + tagList(...) + + } + + #' footer_li_dsfr #' #' Permet de créer la balise html pour ajouter un lien en fonction de sa destination (body/bottom) diff --git a/dev/config_fusen.yaml b/dev/config_fusen.yaml index 62f586e5..f1eaeab9 100644 --- a/dev/config_fusen.yaml +++ b/dev/config_fusen.yaml @@ -11,9 +11,9 @@ flat_actionButton.Rmd: inflate: flat_file: dev/flat_composants/flat_actionButton.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_checkBoxInput.Rmd: path: dev/flat_composants/flat_checkBoxInput.Rmd @@ -38,9 +38,9 @@ flat_checkBoxInput.Rmd: inflate: flat_file: dev/flat_composants/flat_checkBoxInput.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_convert_to_dsfr.Rmd: path: dev/tools/flat_convert_to_dsfr.Rmd @@ -57,9 +57,9 @@ flat_convert_to_dsfr.Rmd: inflate: flat_file: dev/tools/flat_convert_to_dsfr.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_fluidpage.Rmd: path: dev/flat_composants/flat_fluidpage.Rmd @@ -81,9 +81,26 @@ flat_fluidpage.Rmd: pkg: shinygouv flat_file: dev/flat_composants/flat_fluidpage.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true + overwrite: ask +flat_footer.Rmd: + path: dev/flat_composants/flat_footer.Rmd + state: active + R: + - R/footer_dsfr.R + - R/footer_dsfr_template.R + tests: + - tests/testthat/test-footer_dsfr.R + - tests/testthat/test-footer_dsfr_template.R + vignettes: [] + inflate: + flat_file: dev/flat_composants/flat_footer.Rmd + vignette_name: .na + open_vignette: false + check: false + document: true overwrite: ask flat_header.Rmd: path: dev/flat_composants/flat_header.Rmd @@ -98,9 +115,9 @@ flat_header.Rmd: inflate: flat_file: dev/flat_composants/flat_header.Rmd vignette_name: .na - open_vignette: no - check: no - document: yes + open_vignette: false + check: false + document: true overwrite: ask flat_modal.Rmd: path: dev/flat_composants/flat_modal.Rmd @@ -115,9 +132,9 @@ flat_modal.Rmd: inflate: flat_file: dev/flat_composants/flat_modal.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_navbarPage.Rmd: path: dev/flat_composants/flat_navbarPage.Rmd @@ -129,9 +146,9 @@ flat_navbarPage.Rmd: pkg: shinygouv flat_file: dev/flat_composants/flat_navbarPage.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_numericInput.Rmd: path: dev/flat_composants/flat_numericInput.Rmd @@ -148,9 +165,9 @@ flat_numericInput.Rmd: inflate: flat_file: dev/flat_composants/flat_numericInput.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_panels.Rmd: path: dev/flat_composants/flat_panels.Rmd @@ -167,9 +184,9 @@ flat_panels.Rmd: inflate: flat_file: dev/flat_composants/flat_panels.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_radioButtons.Rmd: path: dev/flat_composants/flat_radioButtons.Rmd @@ -188,9 +205,9 @@ flat_radioButtons.Rmd: inflate: flat_file: dev/flat_composants/flat_radioButtons.Rmd vignette_name: .na - open_vignette: no - check: no - document: yes + open_vignette: false + check: false + document: true overwrite: 'yes' flat_radioGroupButtons.Rmd: path: dev/flat_composants/flat_radioGroupButtons.Rmd @@ -209,9 +226,9 @@ flat_radioGroupButtons.Rmd: inflate: flat_file: dev/flat_composants/flat_radioGroupButtons.Rmd vignette_name: .na - open_vignette: no - check: no - document: yes + open_vignette: false + check: false + document: true overwrite: 'yes' flat_selectInput.Rmd: path: dev/flat_composants/flat_selectInput.Rmd @@ -230,9 +247,9 @@ flat_selectInput.Rmd: inflate: flat_file: dev/flat_composants/flat_selectInput.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_slider.Rmd: path: dev/flat_composants/flat_slider.Rmd @@ -244,9 +261,9 @@ flat_slider.Rmd: pkg: shinygouv flat_file: dev/flat_composants/flat_slider.Rmd vignette_name: .na - open_vignette: yes - check: yes - document: yes + open_vignette: true + check: true + document: true overwrite: ask flat_toggleswitch.Rmd: path: dev/flat_composants/flat_toggleswitch.Rmd @@ -262,9 +279,9 @@ flat_toggleswitch.Rmd: inflate: flat_file: dev/flat_composants/flat_toggleswitch.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: ask flat_tools.Rmd: path: dev/tools/flat_tools.Rmd @@ -282,20 +299,20 @@ flat_tools.Rmd: inflate: flat_file: dev/tools/flat_tools.Rmd vignette_name: .na - open_vignette: yes - check: no - document: yes + open_vignette: true + check: false + document: true overwrite: 'yes' flat_withSpinner.Rmd: path: dev/flat_composants/flat_withSpinner.Rmd state: active R: R/withspinner_dsfr.R tests: tests/testthat/test-withspinner_dsfr.R - vignettes: [] + vignettes: [] inflate: flat_file: dev/flat_composants/flat_withSpinner.Rmd vignette_name: .na - open_vignette: no - check: no - document: yes + open_vignette: false + check: false + document: true overwrite: 'yes' diff --git a/dev/flat_composants/flat_footer.Rmd b/dev/flat_composants/flat_footer.Rmd index 31ad411d..dfe7dba6 100644 --- a/dev/flat_composants/flat_footer.Rmd +++ b/dev/flat_composants/flat_footer.Rmd @@ -1,5 +1,5 @@ --- -title: "flat_new_one.Rmd empty" +title: "flat_footer.Rmd" output: html_document editor_options: chunk_output_type: console @@ -20,13 +20,14 @@ Vous pouvez ajouter le footer officiel dans votre application avec `footer_dsfr( ```{r, eval=FALSE} fluidPage_dsfr( header = header_dsfr( - intitule = span("Intitulé", br(), "sur 3", br(), "lignes"), + intitule = c("Intitulé", "sur 3", "lignes"), nom_site_service = "Nom du site / service", baseline = "baseline - precisions sur l organisation", class = "fr-m-1w" ), footer = footer_dsfr( - ), + intitule = "intitule court" + ), title = "Exemple shiny dsfr", h1("Exemple d'utilisation de {shinygouv}"), ) @@ -320,7 +321,7 @@ test_that("footer_dsfr_template works", { #' #' Il est possible d'ajouter des url supplémentaires dans le corps et le bas du pied de page. #' -#' @param intitule la partie "intitule" du bloc marque +#' @param intitule la partie "intitule" du bloc marque. Utiliser un `shiny::tags$span()`pour mettre l'intitulé sur plusieurs lignes ou un vecteur. #' @param description un texte de présentation - optionnel #' @param accessibilite le type d'accessibilité (non/partiellement/totalement conforme) #' @param lien_accessibilite lien url vers l'accessibilite @@ -335,8 +336,8 @@ test_that("footer_dsfr_template works", { #' @rdname footer_dsfr #' @examples footer_dsfr <- function( - intitule = NULL , - description = NULL , + intitule = NULL, + description = NULL, accessibilite = "non", lien_accessibilite = "#", lien_mentions_legales = "#", @@ -346,27 +347,30 @@ footer_dsfr <- function( add_extra_url_bottom = NULL) { - if ( isFALSE(accessibilite %in% c("non", "partiellement", "totalement conforme"))){ - stop("l accessibilite doit etre 'non', 'partiellement' ou 'totalement conforme'") - } - - assertthat::assert_that(is.character(lien_accessibilite)) - assertthat::assert_that(is.character(lien_mentions_legales)) - assertthat::assert_that(is.character(lien_donnees_personnelles)) - assertthat::assert_that(is.character(lien_gestion_cookies)) - - + if ( isFALSE(accessibilite %in% c("non", "partiellement", "totalement conforme"))){ + stop("l accessibilite doit etre 'non', 'partiellement' ou 'totalement conforme'") + } + + assertthat::assert_that(is.character(lien_accessibilite)) + assertthat::assert_that(is.character(lien_mentions_legales)) + assertthat::assert_that(is.character(lien_donnees_personnelles)) + assertthat::assert_that(is.character(lien_gestion_cookies)) + + if(is.vector(intitule) & length(intitule) > 1){ + intitule <- span(HTML(paste0(intitule, collapse = "
"))) + } + footer_dsfr_template( intitule = intitule, description = description, footer_body = add_extra_url_body, footer_bottom = add_extra_url_bottom, - accessibilite = accessibilite, - lien_accessibilite = lien_accessibilite, - lien_mentions_legales = lien_mentions_legales, - lien_donnees_personnelles = lien_donnees_personnelles, - lien_gestion_cookies = lien_gestion_cookies + accessibilite = accessibilite, + lien_accessibilite = lien_accessibilite, + lien_mentions_legales = lien_mentions_legales, + lien_donnees_personnelles = lien_donnees_personnelles, + lien_gestion_cookies = lien_gestion_cookies ) } @@ -379,7 +383,7 @@ if (interactive()) { shinyApp( ui = fluidPage_dsfr( footer = footer_dsfr( - intitule = "Territoire", + intitule = c("Territoire", "Service"), description = "une description", accessibilite = "non", add_extra_url_body = footer_extra_url_body_dsfr( diff --git a/man/footer_dsfr.Rd b/man/footer_dsfr.Rd index 349b9129..fe9a9096 100644 --- a/man/footer_dsfr.Rd +++ b/man/footer_dsfr.Rd @@ -5,8 +5,8 @@ \alias{footer_bottom_dsfr} \alias{footer_dsfr} \alias{footer_extra_url_body_dsfr} -\alias{footer_li_dsfr} \alias{footer_extra_url_bottom_dsfr} +\alias{footer_li_dsfr} \title{footer_bottom_dsfr} \usage{ footer_bottom_dsfr( @@ -32,6 +32,8 @@ footer_dsfr( footer_extra_url_body_dsfr(...) +footer_extra_url_bottom_dsfr(...) + footer_li_dsfr(id = NULL, href, titre = NULL, texte, type = "body") footer_extra_url_bottom_dsfr(...) @@ -49,7 +51,7 @@ footer_extra_url_bottom_dsfr(...) \item{lien_gestion_cookies}{lien url vers la gestion des cookies} -\item{intitule}{la partie "intitule" du bloc marque} +\item{intitule}{la partie "intitule" du bloc marque. Utiliser un \code{shiny::tags$span()}pour mettre l'intitulé sur plusieurs lignes ou un vecteur.} \item{description}{un texte de présentation - optionnel} @@ -76,6 +78,8 @@ html html +html + html } \description{ @@ -89,6 +93,8 @@ Il est possible d'ajouter des url supplémentaires dans le corps et le bas du pi Permet d'ajouter des liends/url dans le corps du pied de page +Permet d'ajouter des liends/url dans le bas du pied de page + Permet de créer la balise html pour ajouter un lien en fonction de sa destination (body/bottom) Permet d'ajouter des liends/url dans le bas du pied de page @@ -99,7 +105,7 @@ if (interactive()) { shinyApp( ui = fluidPage_dsfr( footer = footer_dsfr( - intitule = "Territoire", + intitule = c("Territoire", "Service"), description = "une description", accessibilite = "non", add_extra_url_body = footer_extra_url_body_dsfr( @@ -152,6 +158,7 @@ if (interactive()) { footer_extra_url_body_dsfr( footer_li_dsfr(href = "http://siteinternet.fr", texte = "siteinternet.fr", type = "body"), footer_li_dsfr(href = "http://siteinternet.fr", texte = "siteinternet.fr", type = "body")) +footer_extra_url_bottom_dsfr(footer_li_dsfr(href = "http://siteinternet.fr", texte = "siteinternet.fr")) footer_li_dsfr(href = "http://siteinternet.fr", texte = "siteinternet.fr", type = "body") footer_li_dsfr(href = "http://siteinternet.fr", texte = "siteinternet.fr", type = "bottom") }