Class: DsfrComponent::HeaderComponent::DirectLinkDropdownComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/dsfr_component/header_component/direct_link_dropdown_component.rb

Constant Summary

Constants inherited from Base

Base::HEADING_LEVELS

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(title:, active: false, classes: [], html_attributes: {}) ⇒ DirectLinkDropdownComponent

Returns a new instance of DirectLinkDropdownComponent.



4
5
6
7
8
9
# File 'app/components/dsfr_component/header_component/direct_link_dropdown_component.rb', line 4

def initialize(title:, active: false, classes: [], html_attributes: {})
  @title = title
  @active = active

  super(classes: classes, html_attributes: html_attributes)
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
# File 'app/components/dsfr_component/header_component/direct_link_dropdown_component.rb', line 11

def call
  tag.button(title, **html_attributes) +
    tag.div(class: 'fr-collapse fr-menu', id: menu_id) do
      tag.ul(class: 'fr-menu__list') do
        links.map do |link|
          tag.li link.call
        end.join.html_safe
      end
    end
end