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
|
#' Obtain a list of all available bootswatch themes.
#'
#' @param version the major version of Bootswatch.
#' @param full_path whether to return a path to the installed theme.
#' @export
#' @return a character vector of Bootswatch themes.
bootswatch_themes <- function(version = version_default(), full_path = FALSE) {
list.dirs(bootswatch_dist(version), full.names = full_path, recursive = FALSE)
}
#' Obtain a theme's Bootswatch theme name
#'
#' @inheritParams bs_theme_update
#' @return the Bootswatch theme named used (if any) in the `theme`.
#' @export
theme_bootswatch <- function(theme) {
if (!is_bs_theme(theme)) return(NULL)
swatch <- grep("^bs_bootswatch_", class(theme), value = TRUE)
if (!length(swatch)) return(NULL)
sub("^bs_bootswatch_", "", swatch)
}
#' Obtain a theme's Bootstrap version
#'
#' @inheritParams bs_theme_update
#' @return the major version of Bootstrap used in the `theme`.
#' @export
theme_version <- function(theme) {
if (!is_bs_theme(theme)) return(NULL)
version <- grep("^bs_version_", class(theme), value = TRUE)
sub("^bs_version_", "", version)
}
bootswatch_dist <- function(version) {
switch_version(
version,
five = lib_file("bsw5", "dist"),
four = lib_file("bsw4", "dist"),
three = lib_file("bsw3")
)
}
|