class UiBibz::Ui::Core::Forms::Dropdowns::SplitDropdown

Create a button dropdown

This element is an extend of UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.

Attributes

Options

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

Signatures

UiBibz::Ui::Core::Forms::Dropdowns::SplitDropdown.new(options = nil, html_options = nil).tap do |d|
  d.list content = nil, options = nil, html_options = nil, &block
  d.list content = nil, options = nil, html_options = nil, &block
  d.list content = nil, options = nil, html_options = nil, &block
  ...
end

Examples

UiBibz::Ui::Core::Forms::Dropdowns::SplitDropdown.new(name, status: :success).tap do |d|
  d.list link_to('test', '#')
  d.list('---')
  d.list('Header 1', { type: :header })
  d.list link_to('test2', '#')
end.render

Helper

split_dropdown(name, options = {}, html_options = {}) do |b|
   d.list(content, options = {}, html_options = {})
   d.list(options = {}, html_options = {}) do
     content
   end
 end

Public Instance Methods

pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 61
def pre_render
  content_tag :div, html_options do
    concat button_html
    concat split_html
    concat ul_html
  end
end

Private Instance Methods

button_html() click to toggle source
# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 75
def button_html
  content_tag :button, button_content, (options[:html_button] || {}).merge(class: join_classes('btn', button_status, size, options[:html_button].try(:[], :class)))
end
component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 71
def component_html_classes
  ['btn-group', position, alignment, open, inline, keep_open]
end
split_classes() click to toggle source
# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 88
def split_classes
  join_classes('btn', button_status, size, 'dropdown-toggle', 'dropdown-toggle-split', options[:split_html].try(:[], :class))
end
split_content() click to toggle source
# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 84
def split_content
  src_only
end
split_html() click to toggle source
# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 79
def split_html
  content_tag :button, split_content, (options[:html_split] || {}).merge(class: split_classes, type: 'button',
                                                                         'data-bs-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false)
end
src_only() click to toggle source
# File lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb, line 92
def src_only
  content_tag :span, 'Toggle Dropdown', class: 'sr-only'
end