Class: UI::TabsTrigger

Inherits:
Phlex::HTML
  • Object
show all
Includes:
TabsTriggerBehavior
Defined in:
app/components/ui/tabs_trigger.rb

Overview

TabsTrigger component (Phlex) Button that activates associated content panel

Examples:

Basic usage

render UI::Trigger.new(value: "account") { "Account" }

Disabled trigger

render UI::Trigger.new(value: "disabled", disabled: true) { "Disabled" }

Instance Method Summary collapse

Methods included from TabsTriggerBehavior

#trigger_html_attributes, #trigger_state

Constructor Details

#initialize(value: "", default_value: "", orientation: "horizontal", disabled: false, classes: "", attributes: {}) ⇒ TabsTrigger

Returns a new instance of TabsTrigger.

Parameters:

  • value (String) (defaults to: "")

    unique identifier for this trigger

  • default_value (String) (defaults to: "")

    currently active tab value

  • orientation (String) (defaults to: "horizontal")

    “horizontal” or “vertical”

  • disabled (Boolean) (defaults to: false)

    whether trigger is disabled

  • classes (String) (defaults to: "")

    additional CSS classes

  • attributes (Hash) (defaults to: {})

    additional HTML attributes



20
21
22
23
24
25
26
27
28
# File 'app/components/ui/tabs_trigger.rb', line 20

def initialize(value: "", default_value: "", orientation: "horizontal", disabled: false, classes: "", attributes: {}, **)
  @value = value
  @default_value = default_value
  @orientation = orientation
  @disabled = disabled
  @classes = classes
  @attributes = attributes
  super()
end

Instance Method Details

#view_template(&block) ⇒ Object



30
31
32
# File 'app/components/ui/tabs_trigger.rb', line 30

def view_template(&block)
  button(**trigger_html_attributes, &block)
end