Class: Polaris::VerticalStackComponent

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

Constant Summary collapse

AS_DEFAULT =
:div
AS_OPTIONS =
%i[div ul ol fieldset]
ALIGN_DEFAULT =
:default
ALIGN_MAPPINGS =
{
  default: "",
  start: "start",
  center: "center",
  end: "end",
  space_around: "space-around",
  space_between: "space-between",
  space_evenly: "space-evenly"
}
ALIGN_OPTIONS =
ALIGN_MAPPINGS.keys
INLINE_ALIGN_OPTIONS =
%i[start center end baseline stretch]

Constants included from ViewHelper

Polaris::ViewHelper::POLARIS_HELPERS, Polaris::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(as: AS_DEFAULT, align: ALIGN_DEFAULT, inline_align: nil, gap: nil, reverse_order: false, **system_arguments) ⇒ VerticalStackComponent

Returns a new instance of VerticalStackComponent.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/polaris/vertical_stack_component.rb', line 20

def initialize(
  as: AS_DEFAULT,
  align: ALIGN_DEFAULT,
  inline_align: nil,
  gap: nil,
  reverse_order: false,
  **system_arguments
)
  @system_arguments = system_arguments.tap do |args|
    args[:tag] = fetch_or_fallback(AS_OPTIONS, as, AS_DEFAULT)
    args[:classes] = class_names(
      args[:classes],
      "Polaris-VerticalStack",
      "Polaris-VerticalStack--listReset": as.in?(%i[ul ol]),
      "Polaris-VerticalStack--fieldsetReset": as == :fieldset
    )
    args[:style] = styles_list(
      args[:style],
      "--pc-vertical-stack-align": ALIGN_MAPPINGS[fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)],
      "--pc-vertical-stack-inline-align": fetch_or_fallback(INLINE_ALIGN_OPTIONS, inline_align, allow_nil: true),
      "--pc-vertical-stack-order": reverse_order ? "column-reverse" : "column",
      **gap_value(gap)
    )
  end
end

Instance Method Details

#callObject



46
47
48
# File 'app/components/polaris/vertical_stack_component.rb', line 46

def call
  render(Polaris::BaseComponent.new(**@system_arguments)) { content }
end