Class: UiBibz::Ui::Core::Lists::ListGroup

Inherits:
Component show all
Includes:
UiBibz::Ui::Concerns::HtmlConcern
Defined in:
lib/ui_bibz/ui/core/lists/list_group.rb

Overview

Create a list group

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

  • content - Content of element

  • options - Options of element

  • html_options - Html Options of element

Options

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

  • flush - Boolean

  • tag_type - Type of list (default: :li) (:a, :button, :li)

Signatures

UiBibz::Ui::Core::ListGroup.new.tap |lg|
  ...
  lg.list content = nil, options = nil, html_options = nil, &block
  ...
end

Examples

UiBibz::Ui::Core::ListGroup.new.tap do |d|
  d.list 'Test', status: :success
  d.list 'Test2', status: :primary
end.render

UiBibz::Ui::Core::ListGroup.new(tag_type: :li).tap do |d|
  d.list 'Test', status: :success, url: '#test'
  d.list(status: :primary) do
    'Test 2'
  end
  d.list(state: :active) do |l|
    l.header 'My title', nil, class: 'my-title'
    l.body do
      'My content'
    end
  end
end.render

Helper

list_group( options = {}, html_options = {}) do |l|
  l.list(content, options = {}, html_options = {})
  l.list(options = {}, html_options = {}) do
    content
  end
  l.list(options = {}, html_options = {}) do |li|
    li.header(content, options = {}, html_options = {})
    # or
    li.header(options = {}, html_options = {}) do
      content
    end

    li.body(content, options = {}, html_options = {})
    # or
    li.body(options = {}, html_options = {}) do
      content
    end
  end
end

Direct Known Subclasses

Boxes::Components::CardListGroup

Constant Summary

Constants inherited from Component

Component::BREAKPOINTS, Component::SIZES, Component::STATUSES

Instance Attribute Summary

Attributes inherited from Component

#content, #html_options, #options

Attributes inherited from Base

#output_buffer

Instance Method Summary collapse

Methods inherited from Component

#render, #tapped?

Methods included from PopoverExtension

#popover_data_html, #tooltip_data_html

Methods included from GlyphExtension

#generate_glyph, #glyph_and_content_html

Methods included from KlassExtension

#exclude_classes, #exclude_classes_in_html_options, #join_classes, #status

Methods inherited from Base

#generate_id, #i18n_set?, #inject_url

Constructor Details

#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ ListGroup

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



77
78
79
80
# File 'lib/ui_bibz/ui/core/lists/list_group.rb', line 77

def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @lists = []
end

Instance Method Details

#list(content = nil, options = {}, html_options = nil, &block) ⇒ Object

Add group list See UiBibz::Ui::Core::List



89
90
91
92
93
94
95
96
97
98
# File 'lib/ui_bibz/ui/core/lists/list_group.rb', line 89

def list(content = nil, options = {}, html_options = nil, &block)
  options = options.merge({ tag_type: @options[:tag_type] }) unless @options[:tag_type].nil?

  @lists << if tapped?(block)
              content = (content || {}).merge(options)
              UiBibz::Ui::Core::Lists::Components::List.new(content, options, html_options).tap(&block).render
            else
              UiBibz::Ui::Core::Lists::Components::List.new(content, options, html_options, &block).render
            end
end

#pre_renderObject

Render html tag



83
84
85
# File 'lib/ui_bibz/ui/core/lists/list_group.rb', line 83

def pre_render
   tag_type, @lists.join.html_safe, html_options
end