Class: Avo::Sidebar::BaseItemComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/avo/sidebar/base_item_component.rb

Direct Known Subclasses

GroupComponent, SectionComponent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item: nil) ⇒ BaseItemComponent

Returns a new instance of BaseItemComponent.



6
7
8
# File 'app/components/avo/sidebar/base_item_component.rb', line 6

def initialize(item: nil)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



4
5
6
# File 'app/components/avo/sidebar/base_item_component.rb', line 4

def item
  @item
end

Instance Method Details

#collapsableObject



24
25
26
# File 'app/components/avo/sidebar/base_item_component.rb', line 24

def collapsable
  item.collapsable
end

#collapsedObject



28
29
30
# File 'app/components/avo/sidebar/base_item_component.rb', line 28

def collapsed
  item.collapsed
end

#itemsObject



10
11
12
# File 'app/components/avo/sidebar/base_item_component.rb', line 10

def items
  item.items
end

#keyObject



14
15
16
17
18
19
20
21
22
# File 'app/components/avo/sidebar/base_item_component.rb', line 14

def key
  result = "avo.#{request.host}.main_menu.#{item.name.to_s.underscore}"

  if item.icon.present?
    result += ".#{item.icon.parameterize.underscore}"
  end

  result
end

#section_collapse_data_animationObject



32
33
34
35
36
37
38
39
40
41
# File 'app/components/avo/sidebar/base_item_component.rb', line 32

def section_collapse_data_animation
  {
    transition_enter: "transition ease-out duration-100",
    transition_enter_start: "transform opacity-0 -translate-y-4",
    transition_enter_end: "transform opacity-100 translate-y-0",
    transition_leave: "transition ease-in duration-75",
    transition_leave_start: "transform opacity-100 translate-y-0",
    transition_leave_end: "transform opacity-0 -translate-y-4",
  }
end