Class: UI::Menubar

Inherits:
Phlex::HTML
  • Object
show all
Includes:
MenubarBehavior
Defined in:
app/components/ui/menubar.rb

Overview

Menubar - Phlex implementation

Container for horizontal menu bar with Stimulus controller for interactivity. Uses MenubarBehavior concern for shared styling logic.

Examples:

Basic usage

render UI::Menubar.new do
  render UI::Menu.new do
    render UI::Trigger.new(first: true) { "File" }
    render UI::Content.new do
      render UI::Item.new { "New Tab" }
    end
  end
end

Instance Method Summary collapse

Methods included from MenubarBehavior

#menubar_classes, #menubar_data_attributes, #menubar_html_attributes

Constructor Details

#initialize(loop: false, aria_label: nil, classes: "", **attributes) ⇒ Menubar

Returns a new instance of Menubar.

Parameters:

  • loop (Boolean) (defaults to: false)

    Enable loop navigation

  • aria_label (String) (defaults to: nil)

    Accessible label for the menubar

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



24
25
26
27
28
29
# File 'app/components/ui/menubar.rb', line 24

def initialize(loop: false, aria_label: nil, classes: "", **attributes)
  @loop = loop
  @aria_label = aria_label
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



31
32
33
34
35
# File 'app/components/ui/menubar.rb', line 31

def view_template(&block)
  div(**menubar_html_attributes.deep_merge(@attributes)) do
    yield if block_given?
  end
end