-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdeps.R
52 lines (44 loc) · 1.41 KB
/
deps.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Add an html dependency, without overwriting existing ones
appendDependencies <- function(x, value) {
if (inherits(value, "html_dependency"))
value <- list(value)
old <- attr(x, "html_dependencies", TRUE)
htmltools::htmlDependencies(x) <- c(old, value)
x
}
# Add dashboard dependencies to a tag object
addDeps <- function(x) {
# put all necessary ressources here
tablerDash_js <- "dashboard.js"
tablerDash_css <- "dashboard.css"
init_js <- "init.js"
require_js <- "require.min.js"
core_js <- "core.js"
bootstrap_js <- "bootstrap.bundle.min.js"
fontawesome_css <- "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/"
dashboardDeps <- list(
# fontawesome
htmltools::htmlDependency(
name = "fontawesome",
version = as.character(utils::packageVersion("tablerDash")),
src = c(href = fontawesome_css),
stylesheet = "font-awesome.min.css"
),
# bootstrap deps
htmltools::htmlDependency(
name = "bootstrap",
version = "4.0.0",
src = c(file = system.file("bootstrap-4.0.0", package = "tablerDash")),
script = bootstrap_js
),
#tablerDash
htmltools::htmlDependency(
name = "tablerDash",
version = "0.1.0",
src = c(file = system.file("tablerDash-0.1.0", package = "tablerDash")),
script = c(init_js, tablerDash_js, core_js),
stylesheet = tablerDash_css
)
)
appendDependencies(x, dashboardDeps)
}