Class: Railsboot::Dropdown::LinkComponent

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

Overview

ViewComponent: renders the link block.

Instance Method Summary collapse

Constructor Details

#initialize(text: "", href: "", active: false, disabled: false, **html_attributes) ⇒ LinkComponent

Returns a new instance of LinkComponent.

Parameters:

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

    link text

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

    link target URL

  • active (Boolean) (defaults to: false)

    whether the item is marked active

  • disabled (Boolean) (defaults to: false)

    whether the item is marked disabled

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/railsboot/dropdown/link_component.rb', line 10

def initialize(text: "", href: "", active: false, disabled: false, **html_attributes)
  @text = text
  @href = href
  @active = active
  @disabled = disabled
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "dropdown-item",
    { "active" => @active },
    { "disabled" => @disabled },
    html_attributes.delete(:class)
  )
end