Class: Tailwinds::Table::RowComponent

Inherits:
Tramway::Component::Base 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::ComponentHelper

#component

Instance Method Details

#desktop_row_classes(cells_count) ⇒ Object

:reek:UtilityFunction { enabled: false }



28
29
30
31
32
33
# File 'app/components/tailwinds/table/row_component.rb', line 28

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', "grid-cols-#{cells_count}"
  ].join(' ')
end

:reek:UtilityFunction { enabled: true }



36
37
38
# File 'app/components/tailwinds/table/row_component.rb', line 36

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
24
25
# File 'app/components/tailwinds/table/row_component.rb', line 11

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

  if href.present?
    klass = "#{options[:class] || ''} #{link_row_classes}"

    link_to(href, options.merge(class: klass, **default_attributes)) do
      yield if block_given?
    end
  else
    tag.div(**options.merge(default_attributes)) do
      yield if block_given?
    end
  end
end