Sha256: 1e0d985a7a47f484ce140df186388e4aecad9869e16ad7807e28b164cef51fbc

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require_relative '../../../base'

module CCS::Components
  module GovUK
    class Table < Base
      class Body
        # = GOV.UK Table Body head cell
        #
        # The individual table body head cell
        #
        # @!attribute [r] text
        #   @return [String] Text for the cell

        class HeadCell < Base
          private

          attr_reader :text

          public

          # @param text [String] the text of the cell
          # @param options [Hash] options that will be used in customising the HTML
          #
          # @option options [String] :classes additional CSS classes for the cell
          # @option options [Hash] :attributes ({}) any additional attributes that will be added as part of the cell

          def initialize(text:, **options)
            super(**options)

            @options[:attributes][:scope] = 'row'

            @text = text
          end

          # Generates the HTML for the GOV.UK Table Body head cell
          #
          # @return [ActiveSupport::SafeBuffer]

          def render
            tag.th(text, **options[:attributes])
          end

          # The default attributes for the table body head cell

          DEFAULT_ATTRIBUTES = { class: 'govuk-table__header' }.freeze
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.1.0.rc.2 lib/ccs/components/govuk/table/body/head_cell.rb