R/design-background.R

Defines functions background_color background.yonder_switch background.yonder_radiobar background.yonder_radio background.yonder_menu background.yonder_list_group background.yonder_dropdown background.yonder_checkbar background.yonder_checkbox background.yonder_button_group background.yonder_button background.yonder_badge background.yonder_alert background.default background.shiny.tag background.rlang_box_splice background.yonder_style_pronoun background

Documented in background

#' Backgrounds
#'
#' Use `background()` to modify the background color of a tag element.
#'
#' @inheritParams affix
#'
#' @eval param_color("background")
#'
#' @includeRmd man/roxygen/background.Rmd
#'
#' @family design utilities
#' @export
background <- function(x, color) {
  assert_possible(color, theme_colors)

  UseMethod("background", x)
}

#' @export
background.yonder_style_pronoun <- function(x, color) {
  style_class_add(x, background_color("bg", color))
}

#' @export
background.rlang_box_splice <- function(x, color) {
  background(unbox(x), color)
}

#' @export
background.shiny.tag <- function(x, color) {
  tag_class_add(x, background_color("bg", color))
}

#' @export
background.default <- function(x, color) {
  tag_class_add(x, background_color("bg", color))
}

#' @export
background.yonder_alert <- function(x, color) {
  tag_class_add(x, background_color("alert", color))
}

#' @export
background.yonder_badge <- function(x, color) {
  tag_class_add(x, background_color("badge", color))
}

#' @export
background.yonder_button <- function(x, color) {
  tag_class_add(x, background_color("btn", color))
}

#' @export
background.yonder_button_group <- function(x, color) {
  tag_class_add(x, background_color("btn-group", color))
}

#' @export
background.yonder_checkbox <- function(x, color) {
  tag_class_add(x, background_color("custom-control-group", color))
}

#' @export
background.yonder_checkbar <- function(x, color) {
  tag_class_add(x, background_color("btn-group", color))
}

#' @export
background.yonder_dropdown <- function(x, color) {
  tag_class_add(x, background_color("btn-group", color))
}

#' @export
background.yonder_list_group <- function(x, color) {
  tag_class_add(x, background_color("list-group", color))
}

#' @export
background.yonder_menu <- function(x, color) {
  tag_class_add(x, background_color("btn-group", color))
}

#' @export
background.yonder_radio <- function(x, color) {
  tag_class_add(x, background_color("custom-control-group", color))
}

#' @export
background.yonder_radiobar <- function(x, color) {
  tag_class_add(x, background_color("btn-group", color))
}

#' @export
background.yonder_switch <- function(x, color) {
  tag_class_add(x, background_color("custom-control-group", color))
}

background_color <- function(prefix, color) {
  sprintf("%s-%s", prefix, color)
}
nteetor/dull documentation built on June 10, 2022, 11:30 a.m.