Class: Primer::Alpha::SegmentedControl::Item
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- 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
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
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
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from Primer::AttributesHelper
#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
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 |