Class: Primer::Alpha::HiddenTextExpander
- Defined in:
- app/components/primer/alpha/hidden_text_expander.rb
Overview
Use ‘HiddenTextExpander` to indicate and toggle hidden text.
Constant Summary
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
- #call ⇒ Object
-
#initialize(inline: false, button_arguments: {}, **system_arguments) ⇒ HiddenTextExpander
constructor
A new instance of HiddenTextExpander.
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, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(inline: false, button_arguments: {}, **system_arguments) ⇒ HiddenTextExpander
Returns a new instance of HiddenTextExpander.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/primer/alpha/hidden_text_expander.rb', line 18 def initialize(inline: false, button_arguments: {}, **system_arguments) @system_arguments = deny_tag_argument(**system_arguments) @button_arguments = @system_arguments[:tag] = :span @system_arguments[:classes] = class_names( "hidden-text-expander", @system_arguments[:classes], "inline" => inline ) aria_label = system_arguments[:"aria-label"] || system_arguments.dig(:aria, :label) || @aria_label if aria_label.present? @button_arguments[:"aria-label"] = aria_label @system_arguments[:aria]&.delete(:label) end @button_arguments[:classes] = class_names( "ellipsis-expander", [:classes] ) end |
Instance Method Details
#call ⇒ Object
41 42 43 44 45 |
# File 'app/components/primer/alpha/hidden_text_expander.rb', line 41 def call render(Primer::BaseComponent.new(**@system_arguments)) do render(Primer::Alpha::HellipButton.new(**@button_arguments)) end end |