Sha256: 06bbb7c5f74139609cd48e243112af59de6347c36c039b68c418b0b46a8478ba

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

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

    attr_reader :id, :tree

    def initialize(tree:, id: nil, **attrs)
      @id = id
      @tree = tree
      super(**attrs, id: id)
    end

    def items
      tree.map do |node|
        item_class = (node.type == :directory) ? Nav::Directory::Component : Nav::Entity::Component
        lookbook_render item_class.new node, nav_id: id
      end
    end

    protected

    def alpine_component
      "navComponent"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-1.4.1 app/components/lookbook/nav/component.rb
lookbook-1.4.0 app/components/lookbook/nav/component.rb