R/html_dependency.R

Defines functions html_dependency_filter_crosstalk html_dependency_plotly html_dependency_react_plotly

html_dependency_react_plotly <- function(offline = TRUE) {
  version <- "1.0.2"
  hd <- htmltools::htmlDependency(
    name = "react-plotly",
    version = version,
    src = system.file("js", package = "forestly"),
    script = c("create-plotly-component.js"),
    all_files = FALSE
  )

  if (!offline) {
    hd$src <- list(href = "https://unpkg.com")
    hd$script <- c("react-plotly.js@1.0.2/dist/create-plotly-component.js")
  }

  hd
}

html_dependency_plotly <- function(offline = TRUE) {
  version <- "1.58.5"
  hd <- htmltools::htmlDependency(
    name = "plotly",
    version = version,
    src = system.file("js", package = "forestly"),
    script = c("plotly-min.js"),
    all_files = FALSE
  )

  if (!offline) {
    hd$src <- list(href = "https://cdn.plot.ly")
    hd$script <- c("plotly-1.58.5.min.js")
  }

  hd
}

html_dependency_filter_crosstalk <- function() {
  version <- "0.1.0"
  htmltools::htmlDependency(
    name = "filter-crosstalk",
    version = version,
    src = tempdir(),
    script = c("filter-crosstalk.js"),
    all_files = FALSE
  )
}
elong0527/forestly documentation built on July 4, 2023, 6:54 p.m.