Class: UiBibz::Ui::Core::Forms::Buttons::ButtonGroup
- Includes:
- UiBibz::Ui::Concerns::HtmlConcern
- Defined in:
- lib/ui_bibz/ui/core/forms/buttons/button_group.rb
Overview
Create a button 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:
-
state
(:active
,:disabled
) -
status
- status of element withsymbol
value: (:primary
,:secondary
,:info
,:warning
,:danger
) -
size
- Size of element withsymbol
value: (:xs
,:sm
,:lg
) -
position
- Position vertical or horizontal withsymbol
value: (:vertical
,:horizontal
)
Signatures
UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(options = nil, html_options = nil) do |bg|
...
end
Examples
UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(position: :vertical, size: :xs) do |bg|
bg. 'test'
bg. 'test2'
end.render
Helper
( = {}, = {}) do |bg|
bg. 'content'
bg. 'Link', url: '#'
end
Direct Known Subclasses
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
Instance Method Summary collapse
- #button(content = nil, options = nil, html_options = nil, &block) ⇒ Object
- #button_link(content = nil, options = nil, html_options = nil, &block) ⇒ Object
- #choice_group(content = nil, options = nil, html_options = nil, &block) ⇒ Object
- #dropdown(content, options = {}, html_options = nil, &block) ⇒ Object
- #html(content = nil, options = nil, html_options = nil, &block) ⇒ Object
-
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ ButtonGroup
constructor
See UiBibz::Ui::Core::Component.initialize.
- #input(attribute_name, options = {}, &block) ⇒ Object
-
#pre_render ⇒ Object
Render html tag.
- #split_dropdown(content, options = {}, html_options = nil, &block) ⇒ Object
Methods inherited from Component
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) ⇒ ButtonGroup
See UiBibz::Ui::Core::Component.initialize
53 54 55 56 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 53 def initialize(content = nil, = nil, = nil, &block) super @items = [] end |
Instance Method Details
#button(content = nil, options = nil, html_options = nil, &block) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 63 def (content = nil, = nil, = nil, &block) if block.nil? = @options.merge( || {}) else content = @options.merge(content || {}) end @items << Button.new(content, , , &block) end |
#button_link(content = nil, options = nil, html_options = nil, &block) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 73 def (content = nil, = nil, = nil, &block) if block.nil? = @options.merge( || {}) else content = @options.merge(content || {}) end @items << ButtonLink.new(content, , , &block) end |
#choice_group(content = nil, options = nil, html_options = nil, &block) ⇒ Object
103 104 105 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 103 def choice_group(content = nil, = nil, = nil, &block) @items << UiBibz::Ui::Core::Forms::Choices::ChoiceGroup.new(content, , ).tap(&block) end |
#dropdown(content, options = {}, html_options = nil, &block) ⇒ Object
83 84 85 86 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 83 def dropdown(content, = {}, = nil, &block) = @options.merge() @items << ButtonGroupDropdown.new(content, , ).tap(&block) end |
#html(content = nil, options = nil, html_options = nil, &block) ⇒ Object
99 100 101 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 99 def html(content = nil, = nil, = nil, &block) @items << UiBibz::Ui::Core::Component.new(content, , , &block) end |
#input(attribute_name, options = {}, &block) ⇒ Object
93 94 95 96 97 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 93 def input(attribute_name, = {}, &block) = @options.merge() @items << @options[:form].input(attribute_name, .merge({ label: false, wrapper: false }), &block) end |
#pre_render ⇒ Object
Render html tag
59 60 61 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 59 def pre_render content_tag :div, @items.map { |item| item.respond_to?(:render) ? item.try(:render) : item }.join.html_safe, end |
#split_dropdown(content, options = {}, html_options = nil, &block) ⇒ Object
88 89 90 91 |
# File 'lib/ui_bibz/ui/core/forms/buttons/button_group.rb', line 88 def split_dropdown(content, = {}, = nil, &block) = @options.merge() @items << ButtonGroupSplitDropdown.new(content, , ).tap(&block) end |