Class: Polaris::ListComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/list_component.rb

Defined Under Namespace

Classes: ListItemComponent

Constant Summary collapse

TYPE_DEFAULT =
:bullet
TYPE_TAG_MAPPINGS =
{
  bullet: :ul,
  number: :ol
}
TYPE_CLASS_MAPPINGS =
{
  bullet: "",
  number: "Polaris-List--typeNumber"
}
TYPE_OPTIONS =
TYPE_TAG_MAPPINGS.keys
SPACING_DEFAULT =
:loose
SPACING_MAPPINGS =
{
  extra_tight: "Polaris-List--spacingExtraTight",
  loose: "Polaris-List--spacingLoose"
}
SPACING_OPTIONS =
SPACING_MAPPINGS.keys

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from ViewHelper

#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source

Methods included from StylesListHelper

#styles_list

Methods included from OptionHelper

#append_option, #prepend_option

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(type: TYPE_DEFAULT, spacing: SPACING_DEFAULT, **system_arguments) ⇒ ListComponent

Returns a new instance of ListComponent.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/polaris/list_component.rb', line 25

def initialize(
  type: TYPE_DEFAULT,
  spacing: SPACING_DEFAULT,
  **system_arguments
)
  @system_arguments = system_arguments
  @system_arguments[:tag] = TYPE_TAG_MAPPINGS[fetch_or_fallback(TYPE_OPTIONS, type, :ul)]
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-List",
    TYPE_CLASS_MAPPINGS[fetch_or_fallback(TYPE_OPTIONS, type, "")],
    SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)]
  )
end