Sha256: 30800a3efc121b7f50d82eeb7e618c71cfa77fc1a82afde5106a323448987653

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

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

module CCS
  module Components
    module GovUK
      class Table < Base
        class Header
          # = GOV.UK Table Header head cell
          #
          # The individual table header 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 [String] :format specify format of a 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][:class] += " govuk-table__header--#{@options[:format]}" if @options[:format]
              @options[:attributes][:scope] = 'col'

              @text = text
            end

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

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

            # The default attributes for the table header head cell

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ccs-frontend_helpers-2.1.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-2.0.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-1.2.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-1.1.2 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-1.1.1 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-1.1.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-1.1.0.beta0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-1.0.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.5.0.beta1 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.5.0.beta0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.3.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.2.0 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/table/header/head_cell.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/table/header/head_cell.rb