Class: UI::MenubarSub

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

Overview

Sub - Phlex implementation

Container for submenu within the menubar menu.

Examples:

Basic usage

render UI::Sub.new do
  render UI::SubTrigger.new { "Share" }
  render UI::SubContent.new do
    render UI::Item.new { "Email" }
    render UI::Item.new { "Message" }
  end
end

Instance Method Summary collapse

Methods included from MenubarSubBehavior

#menubar_sub_classes, #menubar_sub_data_attributes, #menubar_sub_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ MenubarSub

Returns a new instance of MenubarSub.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



20
21
22
23
# File 'app/components/ui/menubar_sub.rb', line 20

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



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

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