Class: Polaris::ButtonGroupComponent
- Inherits:
-
Component
- Object
- Component
- Polaris::ButtonGroupComponent
- Defined in:
- app/components/polaris/button_group_component.rb
Defined Under Namespace
Classes: ButtonGroupItemButtonComponent, ButtonGroupItemComponent
Constant Summary collapse
- SPACING_DEFAULT =
:default- SPACING_MAPPINGS =
{ SPACING_DEFAULT => "", :extra_tight => "Polaris-ButtonGroup--extraTight", :tight => "Polaris-ButtonGroup--tight", :loose => "Polaris-ButtonGroup--loose" }
- SPACING_OPTIONS =
SPACING_MAPPINGS.keys
Instance Method Summary collapse
- #all_items ⇒ Object
-
#initialize(connected_top: false, full_width: false, segmented: false, spacing: SPACING_DEFAULT, nowrap: false, **system_arguments) ⇒ ButtonGroupComponent
constructor
A new instance of ButtonGroupComponent.
- #ordered_items ⇒ Object
- #render? ⇒ Boolean
Constructor Details
#initialize(connected_top: false, full_width: false, segmented: false, spacing: SPACING_DEFAULT, nowrap: false, **system_arguments) ⇒ ButtonGroupComponent
Returns a new instance of ButtonGroupComponent.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/polaris/button_group_component.rb', line 26 def initialize( connected_top: false, full_width: false, segmented: false, spacing: SPACING_DEFAULT, nowrap: false, **system_arguments ) @counter = 0 @system_arguments = system_arguments if connected_top @system_arguments["data-buttongroup-connected-top"] = true end if full_width @system_arguments["data-buttongroup-full-width"] = true end if segmented @system_arguments["data-buttongroup-segmented"] = true end @system_arguments[:classes] = class_names( @system_arguments[:classes], "Polaris-ButtonGroup", SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)], "Polaris-ButtonGroup--fullWidth": full_width, "Polaris-ButtonGroup--segmented": segmented, "Polaris-ButtonGroup--noWrap": nowrap ) end |
Instance Method Details
#all_items ⇒ Object
60 61 62 |
# File 'app/components/polaris/button_group_component.rb', line 60 def all_items @all_items ||= + items end |
#ordered_items ⇒ Object
64 65 66 |
# File 'app/components/polaris/button_group_component.rb', line 64 def ordered_items all_items.sort_by(&:position) end |
#render? ⇒ Boolean
56 57 58 |
# File 'app/components/polaris/button_group_component.rb', line 56 def render? all_items.any? end |