Class: Tramway::Table::RowComponent
Overview
Component for rendering a row in a table
Constant Summary
collapse
- DESKTOP_ROW_CLASSES =
%w[
div-table-row grid grid-cols-1 gap-4 border-b border-zinc-800 bg-zinc-950 last:border-b-0
].freeze
Helpers::ViewsHelper::FORM_SIZES
Instance Method Summary
collapse
#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_chat, #tramway_container, #tramway_flash, #tramway_form_for, #tramway_header, #tramway_main_container, #tramway_row, #tramway_table, #tramway_title
#component
#tramway_decorate
Instance Method Details
#around_render ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'app/components/tramway/table/row_component.rb', line 46
def around_render
ensure_view_context_accessor
previous_flag = view_context.tramway_inside_cell
view_context.tramway_inside_cell = href.present?
yield
ensure
view_context.tramway_inside_cell = previous_flag
end
|
#cell_classes ⇒ Object
42
43
44
|
# File 'app/components/tramway/table/row_component.rb', line 42
def cell_classes
'div-table-cell px-6 py-4 text-xs font-medium text-zinc-100 sm:text-base'
end
|
#default_attributes ⇒ Object
18
19
20
|
# File 'app/components/tramway/table/row_component.rb', line 18
def default_attributes
{ role: :row }
end
|
#desktop_row_classes(cells_count) ⇒ Object
34
35
36
|
# File 'app/components/tramway/table/row_component.rb', line 34
def desktop_row_classes(cells_count)
(DESKTOP_ROW_CLASSES + ["md:grid-cols-#{cells_count}"]).join(' ')
end
|
#link_row_classes ⇒ Object
38
39
40
|
# File 'app/components/tramway/table/row_component.rb', line 38
def link_row_classes
'cursor-pointer hover:bg-zinc-900'
end
|
#row_tag(**options) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/components/tramway/table/row_component.rb', line 22
def row_tag(**options, &)
if href.present?
link_to(href, options.merge(class: "#{options[:class] || ''} #{link_row_classes}", **default_attributes)) do
yield if block_given?
end
else
tag.div(**options, **default_attributes) do
yield if block_given?
end
end
end
|