Class: UI::KbdGroup

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

Overview

Group - Phlex implementation

Groups multiple keyboard keys together with consistent spacing. Useful for representing keyboard combinations like "Ctrl + B". Uses KbdGroupBehavior concern for shared styling logic.

Examples:

Basic usage

render UI::Group.new do
  render UI::Kbd.new { "Ctrl" }
  plain "+"
  render UI::Kbd.new { "B" }
end

Instance Method Summary collapse

Methods included from KbdGroupBehavior

#kbd_group_classes, #kbd_group_html_attributes

Constructor Details

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

Returns a new instance of KbdGroup.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash) —

    Additional HTML attributes



20
21
22
23
# File 'app/components/ui/kbd_group.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/kbd_group.rb', line 25

def view_template(&block)
  kbd(**kbd_group_html_attributes) do
    yield if block_given?
  end
end