Class: UI::MenubarContent

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

Overview

Content - Phlex implementation

Container for menu items that appears when trigger is activated.

Examples:

Basic usage

render UI::Content.new do
  render UI::Item.new { "New Tab" }
  render UI::Separator.new
  render UI::Item.new { "Exit" }
end

Instance Method Summary collapse

Methods included from MenubarContentBehavior

#menubar_content_classes, #menubar_content_data_attributes, #menubar_content_html_attributes

Constructor Details

#initialize(align: "start", side: "bottom", classes: "", **attributes) ⇒ MenubarContent

Returns a new instance of MenubarContent.

Parameters:

  • align (String) (defaults to: "start")

    Alignment relative to trigger (start, center, end)

  • side (String) (defaults to: "bottom")

    Side relative to trigger (top, bottom, left, right)

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



20
21
22
23
24
25
# File 'app/components/ui/menubar_content.rb', line 20

def initialize(align: "start", side: "bottom", classes: "", **attributes)
  @align = align
  @side = side
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



27
28
29
30
31
# File 'app/components/ui/menubar_content.rb', line 27

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