#' @title
#' Bulma Color Helpers
#'
#' @description
#' Bulma provides utilities to change the color of particular elements according
#' to the predefined `Sass` variables in [`bulma_assets()`].
#'
#' @param tag (tag) tag to be modified
#'
#' [Color Helpers](https://bulma.io/documentation/helpers/color-helpers/)
#'
#' @family Bulma Modifiers
#' @name bulma_color
NULL
#' @describeIn bulma_color add the color class
#' @param color the color class. `ghost` and `text` only apply to
#' `bulma_button()`s
#' @export
bulma_color <- function(tag,
color = c("primary", "link", "info",
"success", "warning", "danger",
"white", "black", "light", "dark",
"ghost", "text", "black-bis", "black-ter",
"grey-darker",
"grey-dark", "grey-light", "grey-lighter",
"white-ter", "white-bis")) {
color <- match_arg(color)
# Ghost and text only apply to buttons
if (!is.null(color) && color %in% c("ghost", "text")) {
assert_class(tag, "bulma_button")
}
bulma_is(tag, color)
}
#' @describeIn bulma_color Apply a foreground or text color
#' @param shade (str) if light, then applies the light color.
#' @export
bulma_text_color <- function(tag,
color = c("primary", "link", "info",
"success", "warning", "danger",
"white", "black", "light", "dark",
"black-bis", "black-ter", "grey-darker",
"grey-dark", "grey-light",
"grey-lighter",
"white-ter", "white-bis"),
shade = c("dark", "light")) {
shade <- match_arg(shade)
color <- match_arg(color)
if (is.null(color)) {
tag
} else {
if (is.null(shade)) {
bulma_has_text(tag, color)
} else {
bulma_has_text(tag, glue("{color}-{shade}"))
}
}
}
#' @describeIn bulma_color Apply a background color
#' @export
bulma_background_color <- function(tag,
color = c("primary", "link", "info",
"success", "warning", "danger",
"white", "black", "light", "dark",
"black-bis", "black-ter", "grey-darker",
"grey-dark", "grey-light",
"grey-lighter",
"white-ter", "white-bis"),
shade = c("dark", "light")) {
shade <- match_arg(shade)
color <- match_arg(color)
if (is.null(color)) {
tag
} else {
if (is.null(shade)) {
bulma_has_background(tag, color)
} else {
bulma_has_background(tag, glue("{color}-{shade}"))
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.