Files
shiny/tools/updateSpinnerTypes.R
Carson Sievert 3d66940402 Add busy indication (#4040)
* First pass at a proper state machine for managing output progress state

* `yarn build` (GitHub Actions)

* Add useBusyIndicators(), spinnerOptions(), and pulseOptions()

* Bring in new spinner defaults

* Use an actual div instead of a pseudo-element since chromium can't be trusted to show them when animated

* Revert "Use an actual div instead of a pseudo-element since chromium can't be trusted to show them when animated"

This reverts commit 6167c1dfd7.

* Embed animation inside svg (to avoid Chromium bug). Consolidate options into a singular busyIndicatorOptions()

* Add to pkgdown reference

* `devtools::document()` (GitHub Actions)

* `yarn build` (GitHub Actions)

* Bump version

* `yarn build` (GitHub Actions)

* Sync package version (GitHub Actions)

* Apply suggestions from code review

Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>

* Update snapshots

* `devtools::document()` (GitHub Actions)

* Address feedback

* Bring in more spinner type options

* fix use of fs

* Code review

* `devtools::document()` (GitHub Actions)

* Sync package version (GitHub Actions)

* Update snapshots

* Fix comments

* Make snapshot consistent cross-platform

* Fix namespace issue

* Reduce specificity of position relative

* Skip snapshot on windows; update news

* Whoops

* Scope spinner customizations to parent element by default

* Update snapshots

* Reorder spinner types

* Set a private random seed in tests

* Better id naming

---------

Co-authored-by: cpsievert <cpsievert@users.noreply.github.com>
Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
2024-05-10 14:58:43 -05:00

54 lines
1.6 KiB
R

# Downloads a subset of spinner types from https://github.com/n3r4zzurr0/svg-spinners
library(rprojroot)
url_root <- "https://raw.githubusercontent.com/n3r4zzurr0/svg-spinners/main/"
pkg_root <- find_package_root_file()
dest_dir <- file.path(pkg_root, "inst/www/shared/busy-indicators/spinners")
unlink(dest_dir, recursive = TRUE)
dir.create(dest_dir)
# Choose a subset of spinner types
# The key is the "original" name, the value is the new name
spinner_types <- list(
"ring-resize.svg" = "ring.svg",
"90-ring-with-bg.svg" = "ring2.svg",
"180-ring.svg" = "ring3.svg",
"bars-scale-fade.svg" = "bars.svg",
"bars-scale.svg" = "bars2.svg",
"bars-rotate-fade.svg" = "bars3.svg",
"pulse-2.svg" = "pulse.svg",
"pulse-rings-2.svg" = "pulse2.svg",
"pulse-rings-multiple.svg" = "pulse3.svg",
"3-dots-scale.svg" = "dots.svg",
"6-dots-rotate.svg" = "dots2.svg",
"6-dots-scale.svg" = "dots3.svg"
)
# Download and remove width/height attributes
lapply(names(spinner_types), function(x) {
dest_file <- file.path(dest_dir, spinner_types[[x]])
download.file(file.path(url_root, "svg-css", x), dest_file)
svg <- readLines(dest_file, warn = FALSE)
svg <- sub('width="\\d+" height="\\d+" ', "", svg)
writeLines(svg, dest_file)
})
download.file(
"https://raw.githubusercontent.com/n3r4zzurr0/svg-spinners/main/LICENSE",
file.path(dest_dir, "LICENSE")
)
types <- sub("\\.svg$", "", as.character(spinner_types))
writeLines(
c(
"# Generated by tools/updateSpinnerTypes.R: do not edit by hand",
".busySpinnerTypes <-",
paste(" ", deparse(types))
),
here::here("R/busy-indicators-spinners.R")
)