Skip to content

Commit

Permalink
🆙 WIP(icon) : add icons
Browse files Browse the repository at this point in the history
add icons with solution 2 from RLesur/weasydoc#11 :

- works on windows with weasyprint
  • Loading branch information
BenjaminLouis committed Sep 25, 2018
1 parent 3f4c454 commit f3d88ae
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 1,748 deletions.
79 changes: 60 additions & 19 deletions template2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@ output:
css: "template_style.css"
fig_caption: false
params:
date: NA
doc: Facture
ndoc: N0001
nclient: C0001
info:
value:
date: NA
doc: "Facture"
ndoc: "N0001"
nclient: "C0001"
name: "Company name<br> Services"
config:
value:
address1: 1 rue fictive
postal_code: 01000
city: Testcity
mobile: +33(0)6 00 00 00 00
e_mail: contact@email.com
web: www.siteweb.com
siret: xxxxxxxxxxxxxxxxxx
address1: "1 rue fictive"
address2: "test"
postal_code: "01000"
city: "Testcity"
mobile: "+33(0)6 00 00 00 00"
e_mail: "contact@email.com"
web: "www.siteweb.com"
siret: "xxxxxxxxxxxxxxxxxx"
---

```{r setup, include=FALSE}
library(htmltools)
tagList(rmarkdown::html_dependency_font_awesome())
library(glue)
library(dplyr)
library(tidyr)
library(knitr)
library(kableExtra)
library(fontawesome)
#tagList(rmarkdown::html_dependency_font_awesome())
insert_fa <- function(x) {
fa_r <- fa(glue("{x}"))
fa_r_raw <- charToRaw(fa_r)
fa_r_enc <- paste0("data:image/svg+xml;charset=utf-8;base64,", base64enc::base64encode(fa_r_raw))
glue("<img alt=\"icon\" src=\"{fa_r_enc}\">")
}
remove_header <- function(x) { gsub("<thead>.*</thead>", "", x) }
```

---
Expand All @@ -42,12 +58,38 @@ tagList(rmarkdown::html_dependency_font_awesome())
<div class = "row">

<div class = "col-5">
![logo](name.png){width=40mm}
![logo](name.png){width=35mm}

:::{.big}
`r params$name`
`r if(params$name != "NA") params$name`
:::

<div class = "address">
```{r echo = FALSE}
lconfig <- params$config
lconfig[lconfig == "NA" | lconfig == ""] <- NA
lconfig$address3 <- paste(lconfig$postal_code, lconfig$city)
lconfig <- lconfig[c("address1", "address2", "address3", "mobile", "e_mail", "web", "siret")]
if (!is.na(lconfig$siret)) { lconfig$siret <- paste(":", lconfig$siret)}
lconfig <- lconfig[!is.na(lconfig)]
address = insert_fa("envelope")
mobile = insert_fa("mobile")
e_mail = insert_fa("at")
web = insert_fa("globe")
siret = "Siret"
lconfig <- as_tibble(lconfig) %>%
gather() %>%
mutate(key = gsub("address\\d", "address", key)) %>%
mutate(key = paste0("{", key, "}")) %>%
kable() %>%
column_spec(column = 1, width = "8mm", extra_css = "text-align:center;") %>%
collapse_rows(valign = "top") %>%
glue() %>%
remove_header() %>%
HTML()
lconfig
```
</div>

</div>

Expand All @@ -59,23 +101,23 @@ Date

***

`r ifelse(params$date == "NA", I(format(Sys.Date(), "%d/%m/%Y")), I(params$date))`
`r ifelse(params$info$date == "NA", I(format(Sys.Date(), "%d/%m/%Y")), I(params$info$date))`
:::

:::{.boxheader}
`r I(paste0("N° " , params$doc))`
`r I(paste0("N° " , params$info$doc))`

***

`r I(params$ndoc)`
`r I(params$info$ndoc)`
:::

:::{.boxheader}
N° Client

***

`r I(params$nclient)`
`r I(params$info$nclient)`
:::


Expand All @@ -90,7 +132,6 @@ N° Client
</div>



---
### Second row
---
Expand Down
1,750 changes: 38 additions & 1,712 deletions template2.html

Large diffs are not rendered by default.

Binary file modified template2.pdf
Binary file not shown.
23 changes: 18 additions & 5 deletions template_style.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@charset "UTF-8";
@page {
size: a4;
margin-top: 10mm;
margin-bottom: 15mm;
margin-top: 8mm;
margin-bottom: 13mm;
margin-left: 10mm;
margin-right: 10mm;
font-size: 12pt;
Expand Down Expand Up @@ -148,8 +148,10 @@
}

.big {
font-size: 16pt;
font-size: 13pt;
font-weight: bold;
margin: 0;
padding: 0;
}

.boxheader {
Expand All @@ -164,7 +166,7 @@
text-align: center;
}

.boxheader > p {
.boxheader p {
line-height: 0mm;
font-size: 10pt;
text-align: center;
Expand All @@ -179,6 +181,17 @@
margin: 0;
padding: 0;
font-size: 10pt;
line-height: 5px;
line-height: 15px;
}

.address table {
margin: 0;
padding: 0;
}

.address table table tr td {
vertical-align: top;
margin: 0;
padding: 0;
}

39 changes: 27 additions & 12 deletions template_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
@import 'variables';

@page {
size: a4;
margin-top: 10mm;
margin-bottom: 15mm;
size: a4;
margin-top: 8mm;
margin-bottom: 13mm;
margin-left: 10mm;
margin-right: 10mm;
font-size: 12pt;
Expand Down Expand Up @@ -63,8 +63,10 @@ size: a4;
}

.big {
font-size: 16pt;
font-size: 13pt;
font-weight: bold;
margin: 0;
padding: 0;
}

.boxheader {
Expand All @@ -77,13 +79,12 @@ size: a4;
margin-top: 10mm;
padding: 0;
text-align: center;
}

.boxheader > p {
line-height: 0mm;
font-size: 10pt;
text-align: center;
font-weight: bold;
p{
line-height: 0mm;
font-size: 10pt;
text-align: center;
font-weight: bold;
}
}

.centered {
Expand All @@ -94,9 +95,23 @@ size: a4;
margin: 0;
padding: 0;
font-size: 10pt;
line-height: 5px;
line-height: 15px;
table{
margin: 0;
padding: 0;
table{
tr{
td{
vertical-align: top;
margin: 0;
padding: 0;
}
}
}
}
}


.box {

}
Expand Down

0 comments on commit f3d88ae

Please sign in to comment.