Class: CCS::Components::GovUK::SummaryList::Card::Title

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/govuk/summary_list/card/title.rb

Overview

GOV.UK Summary list card title

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the summary list card title

{ class: 'govuk-summary-card__title' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(text:, heading_level: '2', **options) ⇒ Title

Returns a new instance of Title.

Parameters:

  • text (String)

    the text for the title

  • heading_level (String) (defaults to: '2')

    heading level, from 1 to 6

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the summary list card title HTML



28
29
30
31
32
33
# File 'lib/ccs/components/govuk/summary_list/card/title.rb', line 28

def initialize(text:, heading_level: '2', **options)
  super(**options)

  @text = text
  @heading_level = heading_level
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Summary list card title

Returns:

  • (ActiveSupport::SafeBuffer)


39
40
41
# File 'lib/ccs/components/govuk/summary_list/card/title.rb', line 39

def render
  tag.send("h#{heading_level}", text, class: @options[:attributes][:class])
end