R/bulma-form-textarea.R

Defines functions bulma_form_textarea

Documented in bulma_form_textarea

#' @title
#' Bulma Form: TextArea
#'
#' @description
#' The multiline textarea and its variations.
#'
#' [Documentation](https://bulma.io/documentation/form/textarea/)
#'
#' @param name        (str) identifier needed when posting the data
#' @param rows        (int) number of rows of the textarea
#' @param placeholder (str) placeholder while no text is input
#' @param readonly    (flg) cannot be edited
#' @param disabled    (flg) grayed out and cannot be edited
#' @param fixed_size  (flg) cannot be vertically expanded
#' @param color,size,state styling parameters
#' @param ...         (tag) content
#' @param tag         (fun) default HTML content
#'
#' @family Bulma Form Components
#' @export
bulma_form_textarea <- function(name,
                                ...,
                                rows = NULL,
                                placeholder = NULL,
                                readonly    = FALSE,
                                disabled    = FALSE,
                                fixed_size  = FALSE,
                                color = c("primary", "link", "info",
                                          "success", "warning", "danger",
                                          "white", "black", "light", "dark"),
                                size  = c("small", "medium", "large", "normal"),
                                state = c("hovered", "focused", "active",
                                          "loading", "static"),
                                tag   = tags$textarea) {

  assert_function(tag)
  assert_string(name)
  assert_string(placeholder, null.ok = TRUE)
  assert_int(rows, null.ok = TRUE)
  color <- match_arg(color)
  size  <- match_arg(size)
  state <- match_arg(state)

  tag(class = "textarea",
      rows = rows,
      placeholder = placeholder,
      name = name,
      ...) %>%
    bulma_color(color) %>%
    bulma_size(size) %>%
    bulma_state(state) %>%
    when(readonly, bulma_readonly(.)) %>%
    when(disabled, bulma_disabled(.)) %>%
    when(fixed_size, bulma_has(., "fixed-size")) %>%
    add_class("bulma_form_textarea")

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