Class: LightningUiKit::Table::ColumnComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::Table::ColumnComponent
- Defined in:
- app/components/lightning_ui_kit/table/column_component.rb
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#sort_key ⇒ Object
readonly
Returns the value of attribute sort_key.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #alignment_classes ⇒ Object
- #call(row) ⇒ Object
-
#initialize(title, sort_key: nil, align: :left, &block) ⇒ ColumnComponent
constructor
A new instance of ColumnComponent.
- #sortable? ⇒ Boolean
Constructor Details
#initialize(title, sort_key: nil, align: :left, &block) ⇒ ColumnComponent
Returns a new instance of ColumnComponent.
4 5 6 7 8 9 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 4 def initialize(title, sort_key: nil, align: :left, &block) @title = title @sort_key = sort_key @align = align @block = block end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
2 3 4 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 2 def align @align end |
#sort_key ⇒ Object (readonly)
Returns the value of attribute sort_key.
2 3 4 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 2 def sort_key @sort_key end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 2 def title @title end |
Instance Method Details
#alignment_classes ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 15 def alignment_classes case @align when :right "lui:text-right" when :center "lui:text-center" else "lui:text-left" end end |
#call(row) ⇒ Object
26 27 28 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 26 def call(row) @block.call(row) end |
#sortable? ⇒ Boolean
11 12 13 |
# File 'app/components/lightning_ui_kit/table/column_component.rb', line 11 def sortable? !@sort_key.nil? end |