Sha256: be32c188a7b50822ff9cd04329b542f75c4e42c33adc707c43612db45af86272
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module Bootstrap module ViewHelpers module Components class Accordion < Component class Card < Bootstrap::ViewHelpers::Components::Card def header(_ = nil, _ = {}) content_tag(:div, class: "card-header p-0 #{options[:class]}", id: header_id) do title_tag(options[:title]) end end def body(_ = nil, &_block) content_tag(:div, collapse_options) do content_tag(:div, class: body_class(options)) { yield } end end protected attr_reader :id def title_tag(title) content_tag(:h5, class: header_options[:class]) do Button.new(view, { label: title, target: accordion_item_id, expanded: options[:expanded] }).to_html end end def header_id return @header_id if defined? @header_id random_id = "header_#{SecureRandom.urlsafe_base64}" @header_id = options[:header_id] || random_id end def accordion_item_id @id ||= options[:id] || "group_#{SecureRandom.urlsafe_base64}" end def collapse_options { class: "collapse #{'show' if options[:expanded]}", id: accordion_item_id, data: { parent: "##{options[:parent]}" }, aria: { labelled_by: header_id } } end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bootstrap-view_helpers-0.0.3 | lib/bootstrap/view_helpers/components/accordion/card.rb |
bootstrap-view_helpers-0.0.2 | lib/bootstrap/view_helpers/components/accordion/card.rb |