Sha256: 26e14021d095cd9330d2f39fffdbb84a2ae3f603c76d6968fc62673dc2d85dc6

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    class HeaderRowComponent < ViewComponent::Base # :nodoc:
      include Katalyst::HtmlAttributes
      include Header::TypedColumns

      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, **, &)
        with_column(@table.header_cell_component.new(@table, attribute, link: @link_attributes, **), &)
      end

      def header?
        true
      end

      def body?
        false
      end

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

      # Backwards compatibility with tables 1.0
      alias_method :options, :html_attributes=
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katalyst-tables-3.0.0.beta1 app/components/katalyst/tables/header_row_component.rb