R/eng-mod_img_header.R

Defines functions eng_mod_img_header_server mod_img_header_ui

#' img_header UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_img_header_ui <- function(id) {
  ns <- NS(id)
  imageOutput(ns("img"))
}

#' img_header Server Function
#'
#' @noRd
eng_mod_img_header_server <- function(id, img_name) {
  callModule(id = id, function(input, output, session) {
    ns <- session$ns

    output$img <- renderImage({
        list(
          src = app_sys(glue::glue("app/www/{img_name}")),
          contentType = "image/png",
          alt = stringr::str_remove(img_name, "\\.[^\\.]{3,}$")
        )
      }, deleteFile = FALSE)
  })
}

## To be copied in the UI
#> mod_img_header_ui("img_header_ui_1")

## To be copied in the server
#> callModule(mod_img_header_server, "img_header_ui_1")
UBESP-DCTV/covid19ita documentation built on May 15, 2024, 10:40 a.m.