Class: UI::MenubarLabel

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

Overview

Label - Phlex implementation

Non-interactive label/header for menu sections.

Examples:

Basic usage

render UI::Label.new { "Account" }

With inset

render UI::Label.new(inset: true) { "Settings" }

Instance Method Summary collapse

Methods included from MenubarLabelBehavior

#menubar_label_classes, #menubar_label_data_attributes, #menubar_label_html_attributes

Constructor Details

#initialize(inset: false, classes: "", **attributes) ⇒ MenubarLabel

Returns a new instance of MenubarLabel.

Parameters:

  • inset (Boolean) (defaults to: false)

    Add left padding to align with checkbox/radio items

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



18
19
20
21
22
# File 'app/components/ui/menubar_label.rb', line 18

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

Instance Method Details

#view_template(&block) ⇒ Object



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

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