R/wa_relative_time.R

Defines functions wa_relative_time

Documented in wa_relative_time

# Generated by tools/generate_components.R. Do not edit by hand.
# nolint start: object_usage_linter.

#' Create a `wa-relative-time` component
#'
#' Generated wrapper for the Web Awesome `wa-relative-time` component.
#' Generated from Web Awesome metadata.
#'
#' @param ... Child content for the component's default slot.
#' @param id Optional DOM id attribute for HTML, CSS, and JS targeting.
#' @param class Optional CSS class string.
#' @param style Optional inline CSS style string.
#' @param date Default: `new Date()`. The date from which to calculate
#' time from. If not set, the current date and time will be used. When
#' passing a string, it's strongly recommended to use the ISO 8601 format
#' to ensure timezones are handled correctly. To convert a date to this
#' format in JavaScript, use `date.toISOString()`.
#' @param dir String. Optional Web Awesome attribute.
#' @param format Enumerated string. Allowed values: `long`, `narrow`,
#' `short`. Default: `long`. The formatting style to use.
#' @param lang String. Optional Web Awesome attribute.
#' @param numeric Enumerated string. Allowed values: `always`, `auto`.
#' Default: `auto`. When `auto`, values such as "yesterday" and "tomorrow"
#' will be shown when possible. When `always`, values such as "1 day ago"
#' and "in 1 day" will be shown.
#' @param sync Boolean. Default: `FALSE`. Keep the displayed value up to
#' date as time passes.
#'
#' @section Shiny Bindings:
#' None.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_relative_time <- function(
  ...,
  id = NULL,
  class = NULL,
  style = NULL,
  date = NULL,
  dir = NULL,
  format = NULL,
  lang = NULL,
  numeric = NULL,
  sync = NULL
) {
  children <- list(...)

  if (!is.null(format)) {
    format <- .wa_match_arg(
      format,
      "format",
      c(
        "long",
        "narrow",
        "short"
      )
    )
  }

  if (!is.null(numeric)) {
    numeric <- .wa_match_arg(
      numeric,
      "numeric",
      c(
        "always",
        "auto"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = id,
      "class" = class,
      "style" = style,
      "date" = date,
      "dir" = dir,
      "format" = format,
      "lang" = lang,
      "numeric" = numeric,
      "sync" = sync
    ),
    boolean_names = c("sync"),
    boolean_arg_names = c("sync" = "sync")
  )

  do.call(
    .wa_component,
    c(
      list("wa-relative-time", .attrs = attrs),
      children
    )
  )
}
# nolint end

Try the shiny.webawesome package in your browser

Any scripts or data that you put into this service are public.

shiny.webawesome documentation built on April 22, 2026, 1:09 a.m.