Class: Ariadne::UI::Button::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponentContrib::Base
- BaseComponent
- Ariadne::UI::Button::Component
- Includes:
- Behaviors::Captionable, Behaviors::Tooltipable
- Defined in:
- app/components/ariadne/ui/button/component.rb
Direct Known Subclasses
Constant Summary
Constants inherited from BaseComponent
BaseComponent::ACCEPT_ANYTHING
Constants included from ViewHelper
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Attribute Summary collapse
-
#icon_only ⇒ Object
readonly
Returns the value of attribute icon_only.
Instance Method Summary collapse
- #as_icon(**options) ⇒ Object
- #icon_or_svg ⇒ Object
-
#initialize(**options) ⇒ Component
constructor
A new instance of Component.
Methods included from Behaviors::Tooltipable
Methods included from Behaviors::Captionable
Methods inherited from BaseComponent
#class_for, #component, component_id, #component_id, component_name, #html_attributes, i18n_scope, #in_turbo_frame, #in_turbo_stream, #options, stimulus_name, #styles, translate, #validate_aria_label!
Methods included from ViewHelper
Methods included from AttributesHelper
#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes, #prepend_action, #prepend_controller, #prepend_data_attribute
Methods included from ViewComponent::StyleVariants
Constructor Details
#initialize(**options) ⇒ Component
Returns a new instance of Component.
60 61 62 |
# File 'app/components/ariadne/ui/button/component.rb', line 60 def initialize(**) super end |
Instance Attribute Details
#icon_only ⇒ Object (readonly)
Returns the value of attribute icon_only.
8 9 10 |
# File 'app/components/ariadne/ui/button/component.rb', line 8 def icon_only @icon_only end |
Instance Method Details
#as_icon(**options) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/components/ariadne/ui/button/component.rb', line 64 def as_icon(**) validate_aria_label!(html_attrs) @icon_only = true @aria_label = aria(html_attrs, "label") @aria_description = aria(html_attrs, "description") [:size] = @size if [:svg] @svg = [:svg] else @icon = Ariadne::UI::Heroicon::Component.new(**) end self end |
#icon_or_svg ⇒ Object
82 83 84 85 86 |
# File 'app/components/ariadne/ui/button/component.rb', line 82 def icon_or_svg return @svg if @svg render(@icon) end |