Class: Polaris::DataTableComponent
- Defined in:
- app/components/polaris/data_table_component.rb
Constant Summary collapse
- ALIGNMENT_DEFAULT =
:top- ALIGNMENT_OPTIONS =
[:top, :bottom, :middle, :baseline]
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
-
#initialize(data, hoverable: true, vertical_alignment: ALIGNMENT_DEFAULT, totals_in_header: false, totals_in_footer: false, **system_arguments) ⇒ DataTableComponent
constructor
A new instance of DataTableComponent.
- #render_cell(**arguments, &block) ⇒ Object
- #row_arguments(row) ⇒ Object
- #system_arguments ⇒ Object
Methods included from ViewHelper
#polaris_body_styles, #polaris_icon_source, #polaris_inversed_colors
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
Methods included from ClassNameHelper
Constructor Details
#initialize(data, hoverable: true, vertical_alignment: ALIGNMENT_DEFAULT, totals_in_header: false, totals_in_footer: false, **system_arguments) ⇒ DataTableComponent
Returns a new instance of DataTableComponent.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/polaris/data_table_component.rb', line 13 def initialize( data, hoverable: true, vertical_alignment: ALIGNMENT_DEFAULT, totals_in_header: false, totals_in_footer: false, **system_arguments ) @data = data @hoverable = hoverable @vertical_alignment = fetch_or_fallback(ALIGNMENT_OPTIONS, vertical_alignment, ALIGNMENT_DEFAULT) @totals_in_header = totals_in_header @totals_in_footer = @system_arguments = system_arguments end |
Instance Method Details
#render_cell(**arguments, &block) ⇒ Object
48 49 50 |
# File 'app/components/polaris/data_table_component.rb', line 48 def render_cell(**arguments, &block) render(DataTable::CellComponent.new(vertical_alignment: @vertical_alignment, **arguments), &block) end |
#row_arguments(row) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/components/polaris/data_table_component.rb', line 38 def row_arguments(row) {tag: "tr"}.tap do |args| args[:classes] = class_names( "Polaris-DataTable__TableRow", "Polaris-DataTable--hoverable": @hoverable ) args[:id] = dom_id(row) if row.respond_to?(:to_key) end end |
#system_arguments ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/components/polaris/data_table_component.rb', line 29 def system_arguments {tag: "div"}.deep_merge(@system_arguments).tap do |args| args[:classes] = class_names( args[:classes], "Polaris-DataTable" ) end end |