Class: Ariadne::UI::Button::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponentContrib::Base
- BaseComponent
- Ariadne::UI::Button::Component
- Includes:
- Behaviors::Tooltipable
- Defined in:
- app/components/ariadne/ui/button/component.rb
Overview
Used to initiate actions on a page or form.
You can call ‘as_icon` to render a button with only an icon.
Constant Summary collapse
- DEFAULT_SCHEME =
:primary- SCHEME_OPTIONS =
[DEFAULT_SCHEME, :outline, :secondary, :nude, :danger, :none].freeze
- DEFAULT_SIZE =
:md
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
Methods included from Behaviors::Tooltipable
Methods inherited from BaseComponent
audited_at, #class_for, #component, component_id, #component_id, component_name, generate_id, #html_attributes, i18n_scope, #merge_data_attributes, #merge_tailwind_classes, #options, stimulus_name, translate, #validate_aria_label!
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
Instance Attribute Details
#icon_only ⇒ Object (readonly)
Returns the value of attribute icon_only.
15 16 17 |
# File 'app/components/ariadne/ui/button/component.rb', line 15 def icon_only @icon_only end |
Instance Method Details
#as_icon(**options) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/components/ariadne/ui/button/component.rb', line 77 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
95 96 97 98 99 |
# File 'app/components/ariadne/ui/button/component.rb', line 95 def icon_or_svg return @svg if @svg render(@icon) end |