R/bulma-visibility.R

Defines functions bulma_invisible bulma_hidden bulma_display

Documented in bulma_display bulma_hidden bulma_invisible

#' @title
#' Bulma
#'
#' @description
#' Show/hide content depending on the width of the viewport.
#'
#' [Visibility](https://bulma.io/documentation/helpers/visibility-helpers/)
#'
#' @param tag (tag) to be modified
#'
#' @family Bulma Modifiers
#' @name bulma_visibility
NULL

#' @describeIn bulma_visibility Modifies the display class
#' @param display (string) display class
#' @param breakpoint (string) If has only then applicable, otherwise
#'                            that breakpoint and larger.
#' @export
bulma_display <- function(tag,
                          display = c("block", "flex", "inline", "hidden",
                                      "inline-block", "inline-flex"),
                          breakpoint = c("mobile", "tablet-only",
                                         "desktop-only",
                                         "widescreen-only", "touch", "tablet",
                                         "desktop", "widescreen", "fullhd")) {

  display <- match_arg(display)
  breakpoint <- match_arg(breakpoint)

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

}

#' @describeIn bulma_visibility Hides element
#' @export
bulma_hidden <- function(tag,
                         breakpoint = c("mobile", "tablet-only", "desktop-only",
                                        "widescreen-only", "touch", "tablet",
                                        "desktop", "widescreen", "fullhd")) {

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

}

#' @describeIn bulma_visibility Adds visibility hidden
#' @export
bulma_invisible <- function(tag) {

  bulma_is(tag, "invisible")

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