Class: Ariadne::UI::Button::Component

Inherits:
BaseComponent
  • Object
show all
Includes:
Behaviors::Captionable, Behaviors::Tooltipable
Defined in:
app/components/ariadne/ui/button/component.rb

Direct Known Subclasses

ClipboardCopy::Component

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ACCEPT_ANYTHING

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Behaviors::Tooltipable

#with_tooltip

Methods included from Behaviors::Captionable

#with_caption

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

generate_id

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

#merged_styles

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(**options)
  super
end

Instance Attribute Details

#icon_onlyObject (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(**options)
  validate_aria_label!(html_attrs)

  @icon_only = true
  @aria_label = aria(html_attrs, "label")
  @aria_description = aria(html_attrs, "description")

  options[:size] = @size

  if options[:svg]
    @svg = options[:svg]
  else
    @icon = Ariadne::UI::Heroicon::Component.new(**options)
  end

  self
end

#icon_or_svgObject



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