Class: PhlexKit::TabsTrigger

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/tabs/tabs_trigger.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(value:, as: :button, **attrs) ⇒ TabsTrigger

Returns a new instance of TabsTrigger.



3
4
5
6
7
# File 'app/components/phlex_kit/tabs/tabs_trigger.rb', line 3

def initialize(value:, as: :button, **attrs)
  @value = value
  @as = as.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
# File 'app/components/phlex_kit/tabs/tabs_trigger.rb', line 8

def view_template(&)
  base = { class: "pk-tabs-trigger", role: "tab", data: { phlex_kit__tabs_target: "trigger", action: "click->phlex-kit--tabs#show", value: @value } }
  if @as == :a
    a(**mix(base, @attrs), &)
  else
    button(**mix(base.merge(type: :button), @attrs), &)
  end
end