class UiBibz::Ui::Core::Boxes::CardAccordion

Create a card accordion

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

Signatures

UiBibz::Ui::Core::Boxes::CardAccordion.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Boxes::CardAccordion.new(options = nil, html_options = nil) do |cg|
  cg.card content, options, html_options, &block
end

Examples

UiBibz::Ui::Core::Boxes::CardAccordion.new do |cg|
  cg.card 'Exemple 1'
  cg.card 'Exemple 2'
  cg.card 'Exemple 3'
end.render

Public Class Methods

new(content = nil, options = nil, html_options = nil, &block) click to toggle source

See UiBibz::Ui::Core::Component.initialize

Calls superclass method UiBibz::Ui::Core::Component::new
# File lib/ui_bibz/ui/core/boxes/card_accordion.rb, line 37
def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @items = []
end

Public Instance Methods

card(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/boxes/card_accordion.rb, line 47
def card(content = nil, options = nil, html_options = nil, &block)
  content = (content || {}).merge({ parent_collapse: id })
  @items << UiBibz::Ui::Core::Boxes::Card.new(content, options, html_options).tap(&block).render
end
pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/boxes/card_accordion.rb, line 43
def pre_render
  content_tag :div, @items.join.html_safe, html_options
end

Private Instance Methods

component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card_accordion.rb, line 58
def component_html_classes
  'accordion'
end
component_html_options() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card_accordion.rb, line 62
def component_html_options
  { id: id }
end
id() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card_accordion.rb, line 54
def id
  @id ||= generate_id('card-accordion-id')
end