Class: Railsboot::Dropdown::ActionComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/dropdown/action_component.rb

Overview

ViewComponent: renders the action block.

Constant Summary collapse

TYPES =

Types.

%w[button link].freeze
DEFAULT_TYPE =

Default type.

"button".freeze

Instance Method Summary collapse

Constructor Details

#initialize(text: "", type: DEFAULT_TYPE, variant: Railsboot::ButtonComponent::DEFAULT_VARIANT, **html_attributes) ⇒ ActionComponent

Returns a new instance of ActionComponent.



9
10
11
12
13
14
15
16
17
18
19
# File 'app/components/railsboot/dropdown/action_component.rb', line 9

def initialize(text: "", type: DEFAULT_TYPE, variant: Railsboot::ButtonComponent::DEFAULT_VARIANT, **html_attributes)
  @text = text
  @variant = variant
  @type = fetch_or_raise(type, TYPES)
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "dropdown-toggle",
    html_attributes.delete(:class)
  )
end

Instance Method Details

#button?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/railsboot/dropdown/action_component.rb', line 21

def button?
  @type == "button"
end

#link?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/components/railsboot/dropdown/action_component.rb', line 25

def link?
  @type == "link"
end