Class: FoxTail::Accordion::ItemComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
Concerns::Identifiable
Defined in:
app/components/fox_tail/accordion/item_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id_or_title, title_or_attributes = {}, html_attributes = {}) ⇒ ItemComponent

Returns a new instance of ItemComponent.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/components/fox_tail/accordion/item_component.rb', line 64

def initialize(id_or_title, title_or_attributes = {}, html_attributes = {})
  if title_or_attributes.is_a? Hash
    html_attributes = title_or_attributes
    title_or_attributes = id_or_title
  else
    __id_argument_deprecated_warning
    html_attributes[:id] = id_or_title
  end

  @title = title_or_attributes
  super(html_attributes)
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'app/components/fox_tail/accordion/item_component.rb', line 6

def title
  @title
end

Instance Method Details

#before_renderObject



85
86
87
88
89
90
# File 'app/components/fox_tail/accordion/item_component.rb', line 85

def before_render
  super

  generate_unique_id
  html_attributes[:class] = classnames theme.apply(:root, self), html_class
end

#body_idObject



77
78
79
# File 'app/components/fox_tail/accordion/item_component.rb', line 77

def body_id
  :"#{id}_body"
end

#callObject



92
93
94
95
96
97
# File 'app/components/fox_tail/accordion/item_component.rb', line 92

def call
   :div, html_attributes do
    concat render_header
    concat render_body
  end
end

#trigger_idObject



81
82
83
# File 'app/components/fox_tail/accordion/item_component.rb', line 81

def trigger_id
  :"#{id}_trigger"
end