# 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") )