R/bulma-text.R

Defines functions bulma_text_size bulma_text_family bulma_text_weight bulma_text_transform

Documented in bulma_text_family bulma_text_size bulma_text_transform bulma_text_weight

#' @title
#' Bulma Text Modifiers
#'
#' @description
#' These classes modify the text inside the elements.
#'
#' [Typography Helpers](
#' https://bulma.io/documentation/helpers/typography-helpers/)
#'
#' @param tag (tag) tag to be modified
#'
#' @name bulma_text
#' @family Bulma Modifiers
NULL

#' @describeIn bulma_text case transformations
#'
#' @param transform (string) text transformation
#'
#' @export
bulma_text_transform <- function(tag,
                                 transform = c("capitalized",
                                               "lowercase", "uppercase",
                                               "italic", "underlined")) {

  transform <- match_arg(transform)
  bulma_is(tag, transform)

}

#' @describeIn bulma_text font weight
#'
#' @param weight (string) font weight
#'
#' @export
bulma_text_weight <- function(tag,
                              weight = c("light", "normal", "medium",
                                         "semibold", "bold")) {

  weight <- match_arg(weight)
  bulma_has_text(tag, glue("weight-{weight}"))

}

#' @describeIn bulma_text font family
#'
#' @param family (string) font family used
#'
#' @export
bulma_text_family <- function(tag,
                              family = c("sans-serif", "monospace",
                                         "primary", "secondary", "code")) {

  family <- match_arg(family)
  bulma_is(tag, glue("family-{family}"))

}

#' @describeIn bulma_text text size
#'
#' @param size       (int) largest (1) to smallest (7).
#' @param breakpoint (str) breakpoint applicable
#'
#' @export
bulma_text_size <- function(tag,
                            size = 1:7,
                            breakpoint = c("mobile", "touch", "tablet",
                                           "desktop", "widescreen", "fullhd")) {

  size <- match_arg(size)
  assert_int(size)
  breakpoint <- match_arg(breakpoint)

  if (!is.null(breakpoint)) {
    bulma_is(tag, glue("size-{size}-{breakpoint}"))
  } else {
    bulma_is(tag, glue("size-{size}"))
  }

}
tjpalanca/bulma.R documentation built on Dec. 23, 2021, 10:58 a.m.