Class: UiBibz::Ui::Core::Forms::Dropdowns::Dropdown
- Includes:
- UiBibz::Ui::Concerns::HtmlConcern
- Defined in:
- lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb
Overview
Create a dropdown
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:
-
status- status of element with symbol value: (:primary,:secondary,:info,:warning,:danger) -
size -
open- Boolean (:xs,:sm,:lg) -
glyph- Add glyph with name or hash options-
name- String -
size- Integer -
type- Symbol
-
-
html_button- Hash -
theme- Symbol, defaut::dark -
position- Symbol (:up,:right,:down,:left) -
alignment- Symbol/Hash - eq. { direction: :start, size: :lg } (:left,:right,:start,:end)
Signatures
UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(options = nil, html_options = nil).tap do |d|
...
d.header content = nil, options = nil, html_options = nil, &block
d.divider
d.link content = nil, options = nil, html_options = nil, &block
...
end
Examples
UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(name, status: :success).tap do |d|
d.link 'test', { url: '#' }
d.divider
d.header 'Header 1'
d.link 'test2', { url: '#' }
end.render
Helper
dropdown(name, = {}, = {}) do |d|
d.link(content, = {}, = {})
d.link( = {}, = {}) do
content
end
d.divider
d.header(content, = {}, = {})
d.header( = {}, = {}) do
content
end
end
Direct Known Subclasses
Buttons::ButtonGroupDropdown, SplitDropdown, Surrounds::SurroundDropdown, Navigations::NavDropdown
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
-
#divider ⇒ Object
Add dropdown Separator See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDivider.
- #dropdown(name = nil, options = nil, html_options = nil) ⇒ Object
-
#header(content = nil, options = nil, html_options = nil) ⇒ Object
Add dropdown header See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownHeader.
- #id ⇒ Object
-
#initialize ⇒ Dropdown
constructor
A new instance of Dropdown.
-
#link(content = nil, options = nil, html_options = nil) ⇒ Object
Add dropdown link in list See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.
-
#pre_render ⇒ Object
Render html tag.
Methods inherited from Component
Methods included from GlyphExtension
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 ⇒ Dropdown
Returns a new instance of Dropdown.
74 75 76 77 78 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 74 def initialize(...) super @items = [] @status = @options.delete(:status) end |
Instance Method Details
#divider ⇒ Object
Add dropdown Separator See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDivider
96 97 98 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 96 def divider @items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDivider.new.render end |
#dropdown(name = nil, options = nil, html_options = nil) ⇒ Object
106 107 108 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 106 def dropdown(name = nil, = nil, = nil, &) @items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDropdown.new(name, , ).tap(&).render end |
#header(content = nil, options = nil, html_options = nil) ⇒ Object
Add dropdown header See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownHeader
90 91 92 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 90 def header(content = nil, = nil, = nil, &) @items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownHeader.new(content, , , &).render end |
#id ⇒ Object
110 111 112 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 110 def id @id ||= [:id] || generate_id('dropdown') end |
#link(content = nil, options = nil, html_options = nil) ⇒ Object
Add dropdown link in list See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink
102 103 104 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 102 def link(content = nil, = nil, = nil, &) @items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(content, , , &).render end |
#pre_render ⇒ Object
Render html tag
81 82 83 84 85 86 |
# File 'lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb', line 81 def pre_render content_tag :div, do concat concat ul_html end end |