Class: Yattho::Alpha::ActionList::Heading

Inherits:
Component
  • Object
show all
Defined in:
app/components/yattho/alpha/action_list/heading.rb

Overview

Heading used to describe each sub list within an action list.

Constant Summary collapse

DEFAULT_SCHEME =
:subtle
SCHEME_MAPPINGS =
{
  DEFAULT_SCHEME => nil,
  :filled => "ActionList-sectionDivider--filled"
}.freeze
SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys.freeze

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(list_id:, title:, tag: :h3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments) ⇒ Heading

Returns a new instance of Heading.

Parameters:

  • list_id (String)

    The unique identifier of the sub list the heading belongs to. Used internally.

  • title (String)

    Sub list title.

  • subtitle (String) (defaults to: nil)

    Optional sub list description.

  • scheme (Symbol) (defaults to: DEFAULT_SCHEME)

    Display a background color if scheme is ‘filled`.

  • tag (Symbol) (defaults to: :h3)

    Semantic tag for the heading.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/components/yattho/alpha/action_list/heading.rb', line 21

def initialize(list_id:, title:, tag: :h3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments)
  @tag = tag
  @system_arguments = system_arguments
  @list_id = list_id
  @title = title
  @subtitle = subtitle
  @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)
  @system_arguments[:tag] = :li
  @system_arguments[:classes] = class_names(
    "ActionList-sectionDivider",
    SCHEME_MAPPINGS[@scheme],
    @system_arguments[:classes]
  )
end