R/bulma-notification.R

Defines functions bulma_notification

Documented in bulma_notification

#' @title
#' Bulma Notification
#'
#' @description
#' Bold notification blocks, to alert your users of something. The notification
#' is a simple colored block meant to draw the attention to the user about
#' something. As such, it can be used as a pinned notification in the corner
#' of the viewport. That's why it supports the use of the delete element.
#'
#' [Notification](https://bulma.io/documentation/elements/notification/)
#'
#' @family Bulma Elements
#' @name bulma_notification
NULL

#' @describeIn bulma_notification
#' main notification container
#'
#' @param ... (tags) content
#' @param color,light styling parameters
#' @param tag (fn) default HTML tag
#'
#' @export
bulma_notification <- function(...,
                               color = c("primary", "link", "info",
                                         "success", "warning", "danger",
                                         "white", "black", "light", "dark"),
                               light = FALSE,
                               tag = tags$div) {

  color <- match_arg(color)
  assert_function(tag)

  tag(class = "notification", ...) %>%
    bulma_color(color) %>%
    when(light, bulma_is(., "light")) %>%
    add_class("bulma_notification")

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