Class: Nav::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- Nav::Component
- Defined in:
- app/components/lookbook/nav/component.rb
Instance Method Summary collapse
-
#initialize(collection:, id: nil, collapse_singles: false, **attrs) ⇒ Component
constructor
A new instance of Component.
- #items ⇒ Object
Constructor Details
#initialize(collection:, id: nil, collapse_singles: false, **attrs) ⇒ Component
Returns a new instance of Component.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/components/lookbook/nav/component.rb', line 6 def initialize( collection:, id: nil, collapse_singles: false, **attrs ) @id = id.presence || "#{collection.id}-nav" @collection = collection.as_tree @item_args = { collapse_singles: collapse_singles } super(**attrs, id: id) end |
Instance Method Details
#items ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/components/lookbook/nav/component.rb', line 19 def items @collection.non_empty_items.map do |item| render Lookbook::Nav::Item::Component.new item, nav_id: @id, depth: 1, **@item_args end end |