Class: Ariadne::SubheaderComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/ariadne/subheader_component.rb

Overview

A component to render a subheader with optional description below it and optional action components on the right side

Constant Summary collapse

DEFAULT_TAGS =
{
  wrapper: :div,
  actions: :div,
  header: :h2,
  description: :span,
}
DEFAULT_CLASSES =
{
  wrapper: "ariadne-border-b-2 ariadne-border-solid ariadne-border-black ariadne-border-opacity-20",
  header: "",
  actions: "",
  description: "ariadne-text-black/50",
}
DEFAULT_ATTRIBUTES =
{
  wrapper: {},
  header: {},
  description: {},
  actions: {},
}

Constants inherited from Component

Component::BASE_HIDDEN_CLASS, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS

Constants included from ActionViewExtensions::FormHelper

ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES

Constants included from Ariadne::Status::Dsl

Ariadne::Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Instance Method Summary collapse

Methods included from ActionViewExtensions::FormHelper

#ariadne_form_with

Methods included from ClassNameHelper

#merge_class_names

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods included from FetchOrFallbackHelper

#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Constructor Details

#initialize(tag: DEFAULT_TAGS[:wrapper], classes: "", id: "subheader-#{SecureRandom.uuid}", attributes: {}) ⇒ SubheaderComponent

Returns a new instance of SubheaderComponent.

Examples:

Default


<%= render(Ariadne::SubheaderComponent.new) { "Example" } %>

Parameters:

  • tag (Symbol, String) (defaults to: DEFAULT_TAGS[:wrapper])

    The rendered tag name.

  • classes (String) (defaults to: "")

    <%= link_to_classes_docs %>

  • attributes (Hash) (defaults to: {})

    <%= link_to_attributes_docs %>



55
56
57
58
59
60
61
62
63
# File 'app/components/ariadne/subheader_component.rb', line 55

def initialize(tag: DEFAULT_TAGS[:wrapper], classes: "", id: "subheader-#{SecureRandom.uuid}", attributes: {})
  @tag = check_incoming_tag(DEFAULT_TAGS[:wrapper], tag)
  @header_id = id
  @attributes = DEFAULT_ATTRIBUTES[:wrapper].merge(attributes)
  @classes = merge_class_names(
    DEFAULT_CLASSES[:wrapper],
    classes,
  )
end