Skip to content
Snippets Groups Projects

fixed sidebar

Merged arsenij.ustjanzew requested to merge sidebar into master
1 unresolved thread
2 files
+ 15
13
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 10
8
@@ -65,7 +65,7 @@ setMethod("add_component",
component <- switch(mode,
"function" = eval_function(dashboard, ...),
"text" = render_text(component, ...),
"image" = render_image(component, width = image_width, height = image_height, image_alt_text = image_alt_text, description = image_description, ...))
"image" = render_image(component, width = image_width, height = image_height, image_alt_text = image_alt_text, ...))
if(is.list(component)) {
assertive.sets::is_subset(c("appendix", "component", "sidebar"), names(component))
@@ -114,19 +114,21 @@ render_text <- function(file, title = NULL, raw = FALSE) {
#' @param image_alt_text The alt text of the image.
#' @param title The components title.
#' @param raw Whether or not to emit solely the markdown image code.
#' @param width The width of the image.
#' @param height The height of the image
#' @param description An image description below the image.
#' @param width Width defined with CSS in the HTML img-tag.
#' @param height Height defined with CSS in the HTML img-tag.
#'
#' @return A character string containing the evaluated component
render_image <- function(image, image_alt_text = NULL, title = NULL, raw = FALSE, width = "100%", height = "auto", description = NULL) {
if(is.null(image_alt_text)) {
image_alt_text <- image
}
if(is.numeric(width)) width <- paste0(width,"px")
if(is.numeric(height)) height <- paste0(height,"px")
content <- paste0("<img src='",image,"' alt='",image_alt_text,"' style='width:",width,"; height:",height,"'/></br>\n")
if(!is.null(description)) content <- paste0(content,"*",description,"*\n\n")
content <- glue::glue(as.character(
htmltools::img(
src = image,
alt = image_alt_text,
style = paste0('height:', height, ';width:', width)
)),as.character(htmltools::br()))
if(raw) return(content)
knitr::knit_expand(file = system.file("templates", "component.Rmd", package = "i2dash"),
Loading