Class: PhlexKit::InputGroupAddon

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/input_group/input_group_addon.rb

Overview

Addon inside an InputGroup — icons, text or small buttons. align: places it: :start / :end inline beside the control (shadcn's inline-start/-end), :block_start / :block_end as full-width header/footer rows (the group stacks into a column). See input_group.rb.

Constant Summary collapse

ALIGNS =
{
  start: "start",
  end: "end",
  block_start: "block-start",
  block_end: "block-end"
}.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(align: :start, **attrs) ⇒ InputGroupAddon

Returns a new instance of InputGroupAddon.



14
15
16
17
# File 'app/components/phlex_kit/input_group/input_group_addon.rb', line 14

def initialize(align: :start, **attrs)
  @align = align.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



19
20
21
# File 'app/components/phlex_kit/input_group/input_group_addon.rb', line 19

def view_template(&)
  div(**mix({ class: "pk-input-group-addon #{fetch_option(ALIGNS, @align, :align)}", role: "group" }, @attrs), &)
end