Class: Spark::Nav::Tree
- Inherits:
-
Component::Base
- Object
- ActionView::Component::Base
- Component::Base
- Spark::Nav::Tree
- Defined in:
- app/components/spark/nav/tree.rb,
app/components/spark/nav/tree/group.rb
Defined Under Namespace
Classes: Group
Instance Method Summary collapse
- #active_item ⇒ Object
- #group_expanded?(node) ⇒ Boolean
-
#initialize ⇒ Tree
constructor
A new instance of Tree.
Methods inherited from Component::Base
Constructor Details
#initialize ⇒ Tree
Returns a new instance of Tree.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/spark/nav/tree.rb', line 22 def initialize(*) super classname.base = "nav-tree" data.add(tree: @id) aria.add(label: @label) tag_attrs.add(role: :tree) # Group icon should inherit default size set_element_attribute_default(:item, icon_size: @icon_size) set_element_attribute_default(:group, icon_size: @group_icon_size || @icon_size) end |
Instance Method Details
#active_item ⇒ Object
45 46 47 48 49 50 |
# File 'app/components/spark/nav/tree.rb', line 45 def active_item item = items.find(&:active?) # If the item is a group check return its active_item item = item.active_item if item.respond_to?(:active_item) item end |
#group_expanded?(node) ⇒ Boolean
35 36 37 38 39 40 41 42 43 |
# File 'app/components/spark/nav/tree.rb', line 35 def (node) @_cookie ||= begin view_context.( @id ) rescue nil end @_cookie && !!@_cookie[ node ] end |