Class: RowComponent

Inherits:
Component show all
Defined in:
app/components/row_component.rb

Overview

Row — grid row with optional column count.

Usage:

Grid {
  Row(columns: 3) {
    Column { text "A" }
    Column { text "B" }
    Column { text "C" }
  }
}

Constant Summary collapse

NUMBERS =
%w[one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen].freeze

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/row_component.rb', line 24

def to_s
  col_word = columns && columns.between?(1, 16) ? NUMBERS[columns - 1] : nil

  classes = class_names(
    col_word && "#{col_word} column",
    only && "#{only} only",
    aligned && "#{aligned} aligned",
    { "centered" => centered,
      "stretched" => stretched,
      "equal width" => equal_width },
    "row"
  )

  tag.div(**merge_html_options(class: classes)) { @content }
end