Class: Forms::Row

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
lib/forms/row.rb

Overview

Side-by-side fields in a responsive grid: stacked on mobile, columns across from the sm breakpoint. The class strings are literals (not interpolated) so host Tailwind scanners pick them up.

f.row { f.field :first_name; f.field :last_name }
f.row(columns: 3) { ... }

Direct Known Subclasses

Plain::Row

Constant Summary collapse

COLUMN_CLASSES =
{
  2 => "sm:grid-cols-2",
  3 => "sm:grid-cols-3",
  4 => "sm:grid-cols-4"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(columns: 2, **options) ⇒ Row

Returns a new instance of Row.



17
18
19
20
21
# File 'lib/forms/row.rb', line 17

def initialize(columns: 2, **options)
  @columns = columns
  @options = options
  super()
end

Instance Method Details

#view_templateObject



23
24
25
# File 'lib/forms/row.rb', line 23

def view_template(&)
  div(class: row_classes, **@options.except(:class), &)
end