Sha256: 92aa046f2190c83397a649819cf1c73e94919b81e2347c290f9204f5a453768d

Contents?: true

Size: 701 Bytes

Versions: 3

Compression:

Stored size: 701 Bytes

Contents

module Lookbook
  class Nav::Component < Lookbook::Component
    renders_one :filter, Lookbook::Filter::Component

    def initialize(
      collection:,
      label: nil,
      collapse_singles: false,
      **attrs
    )
      @collection = collection.as_tree
      @label = label
      @item_args = {
        collapse_singles: collapse_singles
      }
      super(**attrs)
    end

    def label
      @label || @collection.label
    end

    def items
      @collection.non_empty_items.map do |item|
        render Lookbook::Nav::Item::Component.new item,
          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.2 app/components/lookbook/nav/component.rb
lookbook-1.0.0.beta.1 app/components/lookbook/nav/component.rb
lookbook-1.0.0.beta.0 app/components/lookbook/nav/component.rb