Class: Polaris::HorizontalStackComponent
- Inherits:
-
Component
- Object
- Component
- 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]
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.
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 |