Sha256: a6bd911044b0ede1d99f31ece01f9c98a908f56ed6051c9e55b0fce626355057

Contents?: true

Size: 933 Bytes

Versions: 11

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    class HeaderRowComponent < ViewComponent::Base # :nodoc:
      include HasHtmlAttributes

      renders_many :columns, ->(component) { component }

      def initialize(table, link: {})
        super()

        @table           = table
        @link_attributes = link
      end

      def call
        content # generate content before rendering

        tag.tr(**html_attributes) do
          columns.each do |column|
            concat(column.to_s)
          end
        end
      end

      def cell(attribute, **options, &block)
        with_column(@table.header_cell_component.new(@table, attribute, link: @link_attributes, **options), &block)
      end

      def header?
        true
      end

      def body?
        false
      end

      def inspect
        "#<#{self.class.name} link_attributes: #{@link_attributes.inspect}>"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
katalyst-tables-2.2.10 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.9 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.8 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.7 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.6 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.5 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.4 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.3 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.2 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.1 app/components/katalyst/tables/header_row_component.rb
katalyst-tables-2.2.0 app/components/katalyst/tables/header_row_component.rb