library(dplyr)
library(purrr)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

In order to use a standardised set of box colours, we defined the following box types:

bs2site:::get_box_colours() %>%
  select(name, description) %>%
  knitr::kable()

Colour preview

Default boxes

To generate the above described box colours, just add the class: ### Header {.box-4 .intro}

draw_box <- function(colour, outline = FALSE) {
  htmltools::h3("Header") %>% htmltools::div(class = glue::glue("box {colour} {if_else(outline, 'outline', '')}"),
                                             "Some text using", htmltools::br(),
                                             htmltools::code(paste0(colour, if_else(outline, ' outline', '')))
                                             )
}
colours <- pull(bs2site:::get_box_colours(), name)

purrr::map(colours, draw_box) %>%
  htmltools::div(class = "box-container") %>%
  htmltools::doRenderTags()

Outline boxes

Outline boxes exhibit a white background and only use the header/border colour. Just add the .outline class to your box (e.g. ### Header {.box-4 .intro .outline})

purrr::map(colours, draw_box, outline = TRUE) %>%
  htmltools::div(class = "box-container") %>%
  htmltools::doRenderTags()

Include or update the colours in your site

The colours are defined in a css file. I you're using a site configured as expected by the bs2site package, simply run the use_box_colours() function to create (or update) the file. A link to the css file is automatically added to the lectures/_output.yml file.



koncina/bs2site documentation built on Sept. 23, 2019, 6:54 p.m.