Class: Primer::Alpha::SegmentedControl::Item
- Inherits:
-
BaseComponent
- Object
- Component
- BaseComponent
- Primer::Alpha::SegmentedControl::Item
- Defined in:
- app/components/primer/alpha/segmented_control/item.rb
Overview
SegmentedControl::Item is a private component that is only used by SegmentedControl It wraps the Button and IconButton components to provide the correct styles
Constant Summary
Constants inherited from BaseComponent
BaseComponent::SELF_CLOSING_TAGS
Instance Method Summary collapse
-
#initialize(label:, selected: false, icon: nil, hide_labels: false, **system_arguments) ⇒ Item
constructor
A new instance of Item.
-
#with_trailing_visual_label(**system_arguments, &block) ⇒ Object
Optional trailing label.
Methods inherited from BaseComponent
Constructor Details
#initialize(label:, selected: false, icon: nil, hide_labels: false, **system_arguments) ⇒ Item
Returns a new instance of Item.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/primer/alpha/segmented_control/item.rb', line 16 def initialize( label:, selected: false, icon: nil, hide_labels: false, **system_arguments ) @selected = selected @system_arguments = system_arguments @system_arguments[:"data-action"] = "click:segmented-control#select" if system_arguments[:href].nil? @system_arguments[:"aria-current"] = selected @system_arguments[:scheme] = :invisible if hide_labels @button = Primer::Beta::IconButton.new( icon: icon, "aria-label": label, **@system_arguments ) else @button = Primer::Beta::Button.new(**@system_arguments) @button.with_leading_visual_icon(icon: icon) if icon @button.with_content(label) end end |
Instance Method Details
#with_trailing_visual_label(**system_arguments, &block) ⇒ Object
Optional trailing label.
52 53 54 |
# File 'app/components/primer/alpha/segmented_control/item.rb', line 52 def with_trailing_visual_label(**system_arguments, &block) @button.with_trailing_visual_label(**system_arguments, &block) end |