Class: DsfrComponent::SideMenuComponent::ItemComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/dsfr_component/side_menu_component/item_component.rb

Constant Summary collapse

MAX_LEVEL =
3

Constants inherited from Base

Base::HEADING_LEVELS, Base::SIZES

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(title:, path:, current_page: false, expanded: false, level: 1, html_attributes: {}) ⇒ ItemComponent

Returns a new instance of ItemComponent.

Parameters:

  • title (String)

    title of the side menu item

  • path (String)

    path of the side menu item

  • current_page (Boolean) (defaults to: false)

    active current page style

  • expanded (Boolean) (defaults to: false)

    toggles sub menu folding

  • level (Integer) (defaults to: 1)

    nesting level (1-3), automatically set for sub_items

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/dsfr_component/side_menu_component/item_component.rb', line 13

def initialize(title:, path:, current_page: false, expanded: false, level: 1, html_attributes: {})
  raise ArgumentError, "Le menu latéral ne supporte pas plus de #{MAX_LEVEL} niveaux" if level > MAX_LEVEL

  @title = title
  @path = path
  @current_page = current_page
  @expanded = expanded
  @level = level

  super(html_attributes: html_attributes)
end