Sha256: 05e4f1f7d4a427b4b9eedb1c220a07838a3a0739693050065d9e922ae4126863

Contents?: true

Size: 1.83 KB

Versions: 16

Compression:

Stored size: 1.83 KB

Contents

format :html do
  def accordion_group list, collapse_id=nil, args={}
    collapse_id ||= card.name.safe_key
    accordions = ""
    index = 1
    case list
    when Array then accordions = list.join
    when String then accordions = list
    else
      list.each_pair do |title, content|
        accordions << accordion(title, content, "#{collapse_id}-#{index}")
        index += 1
      end
    end
    add_class args, "act-accordion-group w-100"
    wrap_with :div, class: args[:class], id: "accordion-#{collapse_id}",
                    role: "tablist", "aria-multiselectable" => "true" do
      accordions
    end
  end

  def accordion title, content, collapse_id=card.name.safe_key
    accordion_content =
      case content
      when Hash  then accordion_group(content, collapse_id)
      when Array then content.present? && list_group(content)
      when String then content
      end
    <<-HTML.html_safe
      <div class="card">
        #{accordion_panel(title, accordion_content, collapse_id)}
      </div>
    HTML
  end

  def accordion_panel title, body, collapse_id, _panel_heading_link=false
    if body
      <<-HTML
        <div class="card-header" role="tab" id="heading-#{collapse_id}">
          <h5 class="mb-0">
            <a data-toggle="collapse" data-parent="#accordion-#{collapse_id}" \
               href="##{collapse_id}" aria-expanded="true" \
               aria-controls="#{collapse_id}">
              #{title}
            </a>
          </h5>
        </div>
        <div id="#{collapse_id}" class="collapse" \
               role="tabpanel" aria-labelledby="heading-#{collapse_id}">
          <div class="card-body">
            #{body}
          </div>
        </div>
      HTML
    else
      <<-HTML
        <li class="list-group-item">
          <h4 class="card-header">#{title}</h4>
        </li>
      HTML
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
card-1.94.1 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.94.0 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.13 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.12 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.11 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.10 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.9 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.8 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.7 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.6 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.5 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.4 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.3 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.2 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.1 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.93.0 mod/bootstrap/set/all/bootstrap/accordion.rb