Class: Tailwinds::Table::RowComponent

Inherits:
Tramway::BaseComponent show all
Defined in:
app/components/tailwinds/table/row_component.rb

Overview

Component for rendering a row in a table

Instance Method Summary collapse

Methods included from Tramway::Helpers::ViewsHelper

#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_container, #tramway_flash, #tramway_form_for, #tramway_header, #tramway_row, #tramway_table, #tramway_title

Methods included from Tramway::Helpers::ComponentHelper

#component

Methods included from Tramway::Helpers::DecorateHelper

#tramway_decorate

Instance Method Details

#desktop_row_classes(cells_count) ⇒ Object



25
26
27
28
29
30
# File 'app/components/tailwinds/table/row_component.rb', line 25

def desktop_row_classes(cells_count)
  [
    'div-table-row', 'grid', 'gap-4', 'bg-white', 'border-b', 'last:border-b-0', 'dark:bg-gray-800',
    'dark:border-gray-700', "md:grid-cols-#{cells_count}", 'grid-cols-1'
  ].join(' ')
end


32
33
34
# File 'app/components/tailwinds/table/row_component.rb', line 32

def link_row_classes
  'cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700'
end

#row_tag(**options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/tailwinds/table/row_component.rb', line 11

def row_tag(**options, &)
  default_attributes = { role: :row }

  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