Class: BulmaPhlex::NavigationBarDropdown

Inherits:
Base
  • Object
show all
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 |navbar|
  navbar.brand_item "My App", "/"

  navbar.right do |menu|
    menu.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

Instance Method Details

#dividerObject



37
38
39
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 37

def divider
  hr(class: "navbar-divider")
end

#header(label) ⇒ Object



29
30
31
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 29

def header(label)
  div(class: "navbar-item header has-text-weight-medium") { label }
end

#item(label, path) ⇒ Object



33
34
35
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 33

def item(label, path)
  a(class: "navbar-item", href: path) { label }
end

#view_templateObject



25
26
27
# File 'lib/bulma_phlex/navigation_bar_dropdown.rb', line 25

def view_template(&)
  div(class: "navbar-dropdown is-right", &)
end