Sha256: d43c90099caa27427e2f036557c58619d26b33946b88796b83c310f677f352e6

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

module Lookbook
  class Nav::Component < Lookbook::BaseComponent
    renders_one :filter, Lookbook::Filter::Component
    renders_one :toolbar, Lookbook::Toolbar::Component

    def initialize(
      id: nil,
      collection:,
      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

    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

    protected

    def alpine_component
      "navComponent"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lookbook-1.0.0.beta.7 app/components/lookbook/nav/component.rb
lookbook-1.0.0.beta.6 app/components/lookbook/nav/component.rb
lookbook-1.0.0.beta.5 app/components/lookbook/nav/component.rb