-
Notifications
You must be signed in to change notification settings - Fork 4
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
Propre #34
base: master
Are you sure you want to change the base?
Propre #34
Changes from 15 commits
293474c
ac32e2a
120728a
df89c78
3222cab
b261b7b
758c6fe
243c0e8
63f4ea0
5b663b7
9dcd862
5117988
cfc6503
af1c91f
73d65f0
5bc7a9a
a3242a3
10f7f66
865cec7
a457b71
47fca4c
840a145
eb61e92
a807b40
6c9fbc0
d0ddde7
f5a9c48
06da786
fa5d42b
dc307f1
6a7e635
3093957
450b206
e22cf84
294236b
871c16f
770f747
b2001e1
caa5ba4
42bea74
7ca4132
df084b8
ae85117
46eb92a
db72d80
01d4b1a
7d023a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#' gouvdown PDF brochure - PROPRE style | ||
#' | ||
#' @inheritParams html_gouv | ||
#' @param ... Additional arguments passed to \code{bookdown::\link{html_document2}()}. | ||
#' @param css A character vector of additionnal CSS file paths. | ||
#' @param width_main_column Width of the main text column (in %) | ||
#' | ||
#' @return An R Markdown output format object to be passed to | ||
#' \code{rmarkdown::\link{render}()}. | ||
#' @export | ||
propre_brochure <- function(extra_dependencies = list(), | ||
includes = NULL, | ||
..., | ||
logo = NULL, | ||
css = NULL, | ||
use_gouvdown_fonts = TRUE, | ||
width_main_column = 15) { | ||
# init variable | ||
logo_html_fragment <- NULL | ||
|
||
# create HTML fragment for logo | ||
if (!is.null(logo)) { | ||
if (xfun::file_ext(logo) == "") { | ||
logo_html_fragment <- create_header_html_gouv(logo = logo) | ||
} | ||
else { | ||
match.arg(xfun::file_ext(logo), c("png", "svg", "jpg", "gif")) | ||
logo_html_fragment <- create_header_html_gouv(file = logo) | ||
} | ||
} | ||
|
||
includes <- as.list(includes) | ||
includes$before_body <- | ||
c(includes$before_body, logo_html_fragment) | ||
|
||
# custom css | ||
book_css <- pkg_resource("css/propre", "book.css") | ||
|
||
# custom Pandoc template | ||
brochure_html <- pkg_resource("html", "propre_brochure.html") | ||
|
||
# fonts dependencies - taken from html_gouv | ||
extra_dependencies <- c(gouvdown_dependencies(use_gouvdown_fonts), | ||
extra_dependencies) | ||
|
||
# width of main column - write css | ||
width_css <- tempfile(fileext = ".css") | ||
|
||
writeLines(paste( | ||
paste0(":root {--main-column-width:", width_main_column , "%;}"), | ||
paste0(":root {--secondary-column-width:", 100 - width_main_column - 5, "%;}"), sep = "\n" | ||
), | ||
con = width_css) | ||
|
||
# render | ||
pagedown::html_paged( | ||
extra_dependencies = extra_dependencies, | ||
includes = includes, | ||
number_sections = FALSE, | ||
# self_contained = FALSE, | ||
toc = FALSE, | ||
css = c(css, book_css, width_css), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L'utilisation de l'argument There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ca me semble être le point principal ici. Faut que je regarde comment faire (pas trop à l'aise avec les There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je peux m'en occuper, je l'ai fait des dizaines de fois There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Si ça te dérange pas je veux bien. Comme ça la prochaine fois je saurai. Merci =) |
||
template = brochure_html, | ||
... | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* import your fonts if you have some in the src/fonts folder */ | ||
/* @import "modules/fonts.css"; */ | ||
|
||
/* theming of the book */ | ||
@import url('https://fonts.googleapis.com/css2?family=Caveat&display=swap'); | ||
jengelaere marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@import 'modules/reset.css'; | ||
/* @import "modules/fonts.css"; */ | ||
@import "modules/colors.css"; | ||
@import "modules/vars.css"; | ||
@import "modules/body.css"; | ||
@import "modules/header.css"; | ||
@import "modules/pictures.css"; | ||
@import "modules/list.css"; | ||
@import "modules/table.css"; | ||
@import "modules/numbering.css"; | ||
@import "modules/notes.css"; | ||
@import "modules/title.css"; | ||
/* @import "modules/page2.css"; | ||
@import "modules/page3.css"; | ||
@import "modules/page4.css"; */ | ||
/* @import "modules/title.css"; */ | ||
|
||
|
||
/* css for the layouts */ | ||
/* paged.js tool import */ | ||
|
||
/* paged js interface and screen view css */ | ||
@import "interface/interface.css"; | ||
|
||
/* baseline helper */ | ||
@import "interface/baseline.css"; | ||
|
||
/* the book */ | ||
@import "modules/layout.css"; | ||
|
||
/* hack for stuff not implemented yet */ | ||
@import "interface/hack.css"; | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* adding a visual helper for the baseline grid */ | ||
|
||
:root { | ||
/* you can change the line-height step for the grid here (as it may not be the same that the lineheight) */ | ||
--baseline: 18px; | ||
--baseline-color: red; | ||
} | ||
|
||
@media screen { | ||
|
||
.pagedjs_page { | ||
/* grid baseline */ | ||
background: | ||
repeating-linear-gradient( | ||
white 0, | ||
white calc(var(--baseline) - 1px), | ||
var(--baseline-color) calc(var(--baseline))); | ||
background-size: cover; | ||
background-repeat: repeat-y; | ||
background-position-y: -15px; | ||
} | ||
|
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* here come some simple hacks for features that are not yet in paged js */ | ||
julientaq marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* To define how the book look on the screen: */ | ||
|
||
@media screen { | ||
body { | ||
background-color: var(--color-background); | ||
} | ||
|
||
.pagedjs_pages { | ||
display: flex; | ||
width: calc(var(--pagedjs-pagebox-width) * 2); | ||
flex: 0; | ||
flex-wrap: wrap; | ||
margin: 0 auto; | ||
margin-bottom: 3em; | ||
} | ||
|
||
.pagedjs_page { | ||
background-color: var(--color-paper); | ||
box-shadow: 0 0 0 2px var(--color-pageBox); | ||
margin: 0; | ||
flex-shrink: 0; | ||
flex-grow: 0; | ||
margin-top: 10mm; | ||
} | ||
|
||
.pagedjs_first_page { | ||
margin-left: var(--pagedjs-pagebox-width); | ||
} | ||
|
||
.pagedjs_page > [class*="pagedjs_margin"] { | ||
box-shadow: 0 0 0 1px var(--color-marginBox); | ||
} | ||
|
||
[class*="pagedjs_margin"] { | ||
box-shadow: 0 0 0 1px inset orange; | ||
} | ||
|
||
/* uncomment for recto/verso book. | ||
--------------------------------------------------- */ | ||
/* .pagedjs_pages { | ||
flex-direction: column; | ||
width: 100%; | ||
} | ||
|
||
.pagedjs_first_page { | ||
margin-left: 0; | ||
} | ||
|
||
.pagedjs_page { | ||
margin: 0 auto; | ||
margin-top: 20mm; | ||
} */ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je pense qu'il manque cette documentation de fonction et le passage de
roxygen2::roxygenise()
pour que ce soit fonctionnel