R/bulma-container.R

Defines functions bulma_section bulma_container

Documented in bulma_container bulma_section

#' @title
#' Bulma Containers
#'
#' @description
#' Containers are elements that are designed to contain other elements.
#'
#' * [Container](https://bulma.io/documentation/layout/container/)
#' * [Section](https://bulma.io/documentation/layout/section/)
#'
#' @param ... (tags) content
#' @param tag (fn) container tag function
#'
#' @family Bulma Layouts
#' @name bulma_container
NULL

#' @describeIn bulma_container
#' simple container with horizontally centered content.
#'
#' @param fluid      (flag) always stretches to maximum width without padding
#' @param breakpoint (string) visibility rules:
#' * widescreen - full width until widescreen, then caps
#' * fullhd - full width until fullhd
#' * max-desktop - maximum at desktop
#' * max-widescreen - maximum at widescreen
#'
#' @export
bulma_container <- function(...,
                            fluid = FALSE,
                            breakpoint = c(
                              "widescreen",
                              "fullhd",
                              "max-desktop",
                              "max-widescreen"
                            ),
                            tag = tags$div) {

  breakpoint <- match_arg(breakpoint)

  tag(class = "container", ...) %>%
    when(fluid, bulma_is(., "fluid")) %>%
    bulma_is(breakpoint) %>%
    add_class("bulma_container")

}

#' @describeIn bulma_container
#' The section components are simple layout elements with responsive padding.
#' They are best used as direct children of body.
#'
#' @param spacing (string) medium or larger spacing
#'
#' @export
bulma_section <- function(...,
                          spacing = c("medium", "large"),
                          tag = tags$section) {

  assert_function(tag)
  spacing <- match_arg(spacing)

  tag(class = "section", ...) %>%
    bulma_is(spacing) %>%
    add_class("bulma_section")

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