Class: UI::NavigationMenuContent

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

Overview

Content - Phlex implementation

Container for navigation menu content that appears when trigger is activated. Supports animated transitions based on motion direction.

Examples:

Basic usage

render UI::Content.new do
  ul(class: "grid gap-2 md:w-[400px]") do
    li do
      render UI::Link.new(href: "/docs") { "Documentation" }
    end
  end
end

Instance Method Summary collapse

Methods included from NavigationMenuContentBehavior

#navigation_menu_content_classes, #navigation_menu_content_data_attributes, #navigation_menu_content_html_attributes

Constructor Details

#initialize(viewport: true, classes: "", **attributes) ⇒ NavigationMenuContent

Returns a new instance of NavigationMenuContent.

Parameters:

  • viewport (Boolean) (defaults to: true)

    Whether content should be rendered in viewport (inherited from parent)

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



22
23
24
25
26
# File 'app/components/ui/navigation_menu_content.rb', line 22

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

Instance Method Details

#view_template(&block) ⇒ Object



28
29
30
31
32
# File 'app/components/ui/navigation_menu_content.rb', line 28

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