Class: Nav::Entity::Component
- Inherits:
-
Item::Component
- Object
- Item::Component
- Nav::Entity::Component
- Defined in:
- app/components/lookbook/nav/entity/component.rb
Constant Summary collapse
- ICONS =
{ page: :file, preview: :layers, scenario: :eye, scenario_group: :eye }.freeze
Instance Method Summary collapse
- #children ⇒ Object
- #collapsed? ⇒ Boolean
- #href ⇒ Object
- #nav_icon ⇒ Object
- #search_terms ⇒ Object
- #type ⇒ Object
Instance Method Details
#children ⇒ Object
22 23 24 |
# File 'app/components/lookbook/nav/entity/component.rb', line 22 def children collapsed? ? [] : super end |
#collapsed? ⇒ Boolean
30 31 32 |
# File 'app/components/lookbook/nav/entity/component.rb', line 30 def collapsed? node.type == :preview && node.children.one? end |
#href ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/components/lookbook/nav/entity/component.rb', line 14 def href if collapsed? node.first.url_path elsif type != :preview node.url_path end end |
#nav_icon ⇒ Object
10 11 12 |
# File 'app/components/lookbook/nav/entity/component.rb', line 10 def nav_icon ICONS[collapsed? ? :preview : node.type] || :file end |
#search_terms ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/components/lookbook/nav/entity/component.rb', line 34 def search_terms matchers = if collapsed? node.first.search_terms else node.respond_to?(:search_terms) ? Array(node.search_terms) : [] end matchers.flatten.map { |m| m.gsub(/\s/, "").downcase } end |
#type ⇒ Object
26 27 28 |
# File 'app/components/lookbook/nav/entity/component.rb', line 26 def type collapsed? ? :scenario : node.type end |