Class: BulmaPhlex::NavigationBarDropdown
- Defined in:
- lib/bulma_phlex/navigation_bar_dropdown.rb
Overview
Renders a dropdown menu for the [Bulma navbar](bulma.io/documentation/components/navbar/#dropdown-menu).
Provides structured content for a navbar dropdown, including headers, links, and dividers. Intended to be used inside a NavigationBar block.
## Example
render BulmaPhlex::NavigationBar.new do ||
.brand_item "My App", "/"
.right do ||
.dropdown "Account" do |dropdown|
dropdown.header "User"
dropdown.item "Profile", "/profile"
dropdown.item "Settings", "/settings"
dropdown.divider
dropdown.item "Sign Out", "/logout"
end
end
end
Instance Method Summary collapse
- #divider ⇒ Object
-
#header(label, divider: false) ⇒ Object
Adds a non-clickable header item to the dropdown menu.
- #item(label, path) ⇒ Object
- #view_template ⇒ Object
Instance Method Details
#divider ⇒ Object
40 41 42 |
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 40 def divider hr(class: "navbar-divider") end |
#header(label, divider: false) ⇒ Object
Adds a non-clickable header item to the dropdown menu. Optionally add a divider before the header with the ‘divder: true` parameter.
31 32 33 34 |
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 31 def header(label, divider: false) self.divider if divider div(class: "navbar-item has-text-weight-semibold") { label } end |
#item(label, path) ⇒ Object
36 37 38 |
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 36 def item(label, path) a(class: "navbar-item", href: path) { label } end |
#view_template ⇒ Object
25 26 27 |
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 25 def view_template(&) div(class: "navbar-dropdown is-right", &) end |