Class: Nav::Item::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- Nav::Item::Component
show all
- Defined in:
- app/components/lookbook/nav/item/component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(node, nav_id:, **html_attrs) ⇒ Component
Returns a new instance of Component.
7
8
9
10
11
|
# File 'app/components/lookbook/nav/item/component.rb', line 7
def initialize(node, nav_id:, **html_attrs)
@node = node
@nav_id = nav_id
super(**html_attrs)
end
|
Instance Attribute Details
#nav_id ⇒ Object
Returns the value of attribute nav_id.
5
6
7
|
# File 'app/components/lookbook/nav/item/component.rb', line 5
def nav_id
@nav_id
end
|
#node ⇒ Object
Returns the value of attribute node.
5
6
7
|
# File 'app/components/lookbook/nav/item/component.rb', line 5
def node
@node
end
|
Instance Method Details
#children ⇒ Object
21
22
23
|
# File 'app/components/lookbook/nav/item/component.rb', line 21
def children
@children ||= node.sort.map { |node| render_item(node) }
end
|
#children? ⇒ Boolean
29
30
31
|
# File 'app/components/lookbook/nav/item/component.rb', line 29
def children?
children.any?
end
|
#id ⇒ Object
13
14
15
|
# File 'app/components/lookbook/nav/item/component.rb', line 13
def id
"#{nav_id}-#{node.id}"
end
|
#left_pad ⇒ Object
17
18
19
|
# File 'app/components/lookbook/nav/item/component.rb', line 17
def left_pad
depth * 12
end
|
#nav_icon ⇒ Object
25
26
27
|
# File 'app/components/lookbook/nav/item/component.rb', line 25
def nav_icon
:folder
end
|
#render_item(node) ⇒ Object
33
34
35
36
|
# File 'app/components/lookbook/nav/item/component.rb', line 33
def render_item(node)
item_class = (node.type == :directory) ? Nav::Directory::Component : Nav::Entity::Component
lookbook_render item_class.new node, nav_id: nav_id
end
|