Class: Polaris::HorizontalStackComponent
- Defined in:
- app/components/polaris/horizontal_stack_component.rb
Constant Summary collapse
- 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
- BLOCK_ALIGN_OPTIONS =
%i[start center end baseline stretch]
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(align: ALIGN_DEFAULT, block_align: nil, gap: nil, wrap: true, **system_arguments) ⇒ HorizontalStackComponent
constructor
A new instance of HorizontalStackComponent.
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
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
Constructor Details
#initialize(align: ALIGN_DEFAULT, block_align: nil, gap: nil, wrap: true, **system_arguments) ⇒ HorizontalStackComponent
Returns a new instance of HorizontalStackComponent.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/components/polaris/horizontal_stack_component.rb', line 17 def initialize( align: ALIGN_DEFAULT, block_align: nil, gap: nil, wrap: true, **system_arguments ) @system_arguments = system_arguments.tap do |args| args[:tag] = "div" args[:classes] = class_names( args[:classes], "Polaris-HorizontalStack" ) args[:style] = styles_list( args[:style], "--pc-horizontal-stack-align": ALIGN_MAPPINGS[fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)], "--pc-horizontal-stack-block-align": fetch_or_fallback(BLOCK_ALIGN_OPTIONS, block_align, allow_nil: true), "--pc-horizontal-stack-wrap": wrap ? "wrap" : "nowrap", **gap_value(gap) ) end end |
Instance Method Details
#call ⇒ Object
40 41 42 |
# File 'app/components/polaris/horizontal_stack_component.rb', line 40 def call render(Polaris::BaseComponent.new(**@system_arguments)) { content } end |