class UiBibz::Ui::Core::Lists::ListGroup
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
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/lists/list_group.rb, line 77 def initialize(content = nil, options = nil, html_options = nil, &block) super @lists = [] end
Public Instance Methods
list(content = nil, options = {}, html_options = nil, &block)
click to toggle source
Add group list See UiBibz::Ui::Core::List
# 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_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/lists/list_group.rb, line 83 def pre_render content_tag tag_type, @lists.join.html_safe, html_options end
Private Instance Methods
component_html_classes()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Component#component_html_classes
# File lib/ui_bibz/ui/core/lists/list_group.rb, line 102 def component_html_classes super << ['list-group', flush] end
flush()
click to toggle source
# File lib/ui_bibz/ui/core/lists/list_group.rb, line 106 def flush 'list-group-flush' if options[:flush] end
tag_type()
click to toggle source
# File lib/ui_bibz/ui/core/lists/list_group.rb, line 110 def tag_type %i[a button].include?(options[:tag_type]) ? :div : :ul end