Module: Ariadne::Behaviors::Tooltipable

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

Instance Method Summary collapse

Instance Method Details

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



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

def with_tooltip(text:, placement: :top, **options)
  @tooltip_id = Ariadne::BaseComponent.generate_id(base_name: "ariadne-behaviors-tooltip")

  html_attrs[:aria] ||= {}
  html_attrs[: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, placement: placement, component: self, **options)
end