Class: UI::InputGroupInputComponent

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

Overview

InputGroupInputComponent - ViewComponent implementation

An input element styled for use within input groups. Uses InputGroupInputBehavior concern for shared styling logic.

Examples:

Basic input

<%= render UI::InputGroupInputComponent.new(
  placeholder: "Enter text",
  name: "username"
) %>

With type

<%= render UI::InputGroupInputComponent.new(
  type: "email",
  placeholder: "[email protected]"
) %>

Instance Method Summary collapse

Methods included from InputGroupInputBehavior

#input_group_input_attributes, #input_group_input_classes, #input_group_input_html_attributes

Constructor Details

#initialize(type: "text", placeholder: nil, value: nil, name: nil, id: nil, classes: "", **attributes) ⇒ InputGroupInputComponent

Returns a new instance of InputGroupInputComponent.

Parameters:

  • type (String) (defaults to: "text")

    Input type (default: “text”)

  • placeholder (String) (defaults to: nil)

    Placeholder text

  • value (String) (defaults to: nil)

    Input value

  • name (String) (defaults to: nil)

    Input name attribute

  • id (String) (defaults to: nil)

    Input id attribute

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



29
30
31
32
33
34
35
36
37
# File 'app/view_components/ui/input_group_input_component.rb', line 29

def initialize(type: "text", placeholder: nil, value: nil, name: nil, id: nil, classes: "", **attributes)
  @type = type
  @placeholder = placeholder
  @value = value
  @name = name
  @id = id
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



39
40
41
# File 'app/view_components/ui/input_group_input_component.rb', line 39

def call
  render partial: "ui/input", locals: input_group_input_attributes
end