Module: Ariadne::Behaviors::Tooltipable

Included in:
Form::Toggle::Component, UI::Badge::Component, UI::Button::Component, UI::Link::Component
Defined in:
app/components/ariadne/behaviors/tooltipable.rb

Instance Method Summary collapse

Instance Method Details

#with_tooltip(text:, **options) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'app/components/ariadne/behaviors/tooltipable.rb', line 6

def with_tooltip(text:, **options)
  @tooltip_id = ::Ariadne::ViewHelper.generate_id

  prepend_action(html_attrs, "aria-describedby" => @tooltip_id)

  # TODO: this should raise if component's tag isn't an ARIA-compatible tag
  # ('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])')
  Ariadne::Behaviors::Tooltip.new(id: @tooltip_id, text: text, component: self, **options)
end