Skip to content

Commit

Permalink
Install rstudio/bslib@main and build bundles (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Apr 26, 2023
1 parent 724f6eb commit f2ec365
Show file tree
Hide file tree
Showing 52 changed files with 346,146 additions and 37 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ recursive-exclude * *.py[co]
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif

recursive-include shinyswatch/bs5 *
recursive-include shinyswatch/bsw5 *
recursive-include shinyswatch/bsw5 *.min.css
49 changes: 38 additions & 11 deletions scripts/update_bootswatch.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/usr/bin/env Rscript

pak::pkg_install("rstudio/bslib")
# pak::pkg_install("cran::bslib")

library(bslib)
library(rlang)

bslib_info <- sessioninfo::package_info("bslib")
bslib_info_list <- bslib_info[bslib_info$package == "bslib", , drop = TRUE]
bslib_comment <- paste0("// {bslib} version: ", bslib_info_list$source)

# == Approach ================================================================
# We MUST use `{bslib}` themes as the original bootswatch themes
# have been modified to support Shiny markup. Ex: `.well`.
Expand Down Expand Up @@ -133,17 +140,37 @@ ignore <- Map(
)

# Write bundle to disk
sass::sass(
sass_bundle,
# Make a minimized output file
options = sass::sass_options_get(output_style = "compressed"),
output = file.path(out_dir, name, "bootswatch.min.css"),
cache = FALSE,
# Should be `TRUE` if font files are to be saved.
# However, we are not saving them as we are reverting the
# local font paths to the original CDN paths in the code above.
write_attachments = FALSE
)
for (info in list(
# In final package, we only need the minified CSS
list(output_style = "compressed", suffix = ".min.css"),
# Useful for comparing on updates / debugging
list(output_style = "expanded", suffix = ".css")
)) {
output_file <- file.path(out_dir, name, paste0("bootswatch", info$suffix))
sass::sass(
sass_bundle,
# Make a minimized output file
options = sass::sass_options_get(output_style = info$output_style),
output = output_file,
cache = FALSE,
# Should be `TRUE` if font files are to be saved.
# However, we are not saving them as we are reverting the
# local font paths to the original CDN paths in the code above.
write_attachments = FALSE
)
if (info$output_style == "expanded") {
# Add comments on where the file came from
writeLines(
c(
bslib_comment,
paste0("// bw: 5: ", ver),
paste0("// bsw5 theme: ", name),
readLines(output_file)
),
output_file
)
}
}
}
)

Expand Down
Loading

0 comments on commit f2ec365

Please sign in to comment.