@@ -16,17 +16,6 @@ options(
16
16
# shiny.autoreload.pattern = "_brand[.]yml|app[.]R|[.]s?css" ## TODO: Enable after fixing autoreload
17
17
)
18
18
19
- if (! file.exists(" Monda.ttf" )) {
20
- download.file(
21
- " https://github.com/google/fonts/raw/48db77e32954f6f5e65a7122ecbe8a2093c4f5d7/ofl/monda/Monda%5Bwght%5D.ttf" ,
22
- " Monda.ttf"
23
- )
24
- download.file(
25
- " https://github.com/google/fonts/raw/48db77e32954f6f5e65a7122ecbe8a2093c4f5d7/ofl/monda/OFL.txt" ,
26
- " Monda-OFL.txt"
27
- )
28
- }
29
-
30
19
theme_brand <- bs_theme(brand = TRUE )
31
20
32
21
brand <- attr(theme_brand , " brand" )
@@ -44,11 +33,37 @@ if (requireNamespace("thematic", quietly = TRUE)) {
44
33
}
45
34
}
46
35
36
+ use_download_button <- FALSE
37
+
38
+ # ---- For hosted demo, delete if local ----
47
39
is_app_hosted <-
48
40
Sys.getenv(" R_CONFIG_ACTIVE" ) %in%
49
41
c(" shinylive" , " shinyapps" , " rsconnect" , " rstudio_cloud" )
50
42
is_app_packaged <-
51
- getwd() != system.file(" examples-shiny/brand.yml" , package = " bslib" )
43
+ getwd() == system.file(" examples-shiny/brand.yml" , package = " bslib" )
44
+ use_download_button <- is_app_hosted || is_app_packaged
45
+
46
+ if (bslib ::: brand_has(brand , " typography" , " fonts" )) {
47
+ tryCatch(
48
+ {
49
+ if (brand $ typography $ fonts [[2 ]]$ files [[1 ]]$ path == " Monda.ttf" ) {
50
+ if (! file.exists(" Monda.ttf" )) {
51
+ download.file(
52
+ " https://github.com/google/fonts/raw/48db77e32954f6f5e65a7122ecbe8a2093c4f5d7/ofl/monda/Monda%5Bwght%5D.ttf" ,
53
+ " Monda.ttf"
54
+ )
55
+ download.file(
56
+ " https://github.com/google/fonts/raw/48db77e32954f6f5e65a7122ecbe8a2093c4f5d7/ofl/monda/OFL.txt" ,
57
+ " Monda-OFL.txt"
58
+ )
59
+ }
60
+ }
61
+ },
62
+ error = function (err ) {
63
+ }
64
+ )
65
+ }
66
+ # ---- For hosted demo, delete if local ----
52
67
53
68
ui <- page_navbar(
54
69
theme = bs_add_rules(theme_brand , sass :: sass_file(" _colors.scss" )),
@@ -147,7 +162,7 @@ initBrandEditor();
147
162
)
148
163
),
149
164
150
- if (is_app_hosted || is_app_packaged ) {
165
+ if (use_download_button ) {
151
166
shiny :: downloadButton(
152
167
" download" ,
153
168
label = span(" Download" , code(" _brand.yml" ), " file" ),
0 commit comments