Class: UI::KbdGroupComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
KbdGroupBehavior
Defined in:
app/view_components/ui/kbd_group_component.rb

Overview

GroupComponent - ViewComponent 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::GroupComponent.new do %>
  <%= render UI::KbdComponent.new { "Ctrl" } %>
  +
  <%= render UI::KbdComponent.new { "B" } %>
<% end %>

Instance Method Summary collapse

Methods included from KbdGroupBehavior

#kbd_group_classes, #kbd_group_html_attributes

Constructor Details

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

Returns a new instance of KbdGroupComponent.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



20
21
22
23
# File 'app/view_components/ui/kbd_group_component.rb', line 20

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

Instance Method Details

#callObject



25
26
27
28
29
30
31
# File 'app/view_components/ui/kbd_group_component.rb', line 25

def call
  attrs = kbd_group_html_attributes

   :kbd, **attrs.merge(@attributes) do
    content
  end
end