Class: CCS::Components::GovUK::TaskList::Item::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/govuk/task_list/item/status.rb

Overview

GOV.UK Task list item status

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the task list item status

{ class: 'govuk-task-list__status' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(id_prefix:, tag_options: nil, text: nil, **options) ⇒ Status

Returns a new instance of Status.

Parameters:

  • id_prefix (String)

    the id prefix for the task list item

  • tag_options (Hash) (defaults to: nil)

    paramters for the govuk tag (see Tag). options are:

    • text

    • colour

    • options

  • text (String) (defaults to: nil)

    the text for the status. If tag is nil then this is used

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the task list row status HTML



34
35
36
37
38
39
40
# File 'lib/ccs/components/govuk/task_list/item/status.rb', line 34

def initialize(id_prefix:, tag_options: nil, text: nil, **options)
  super(**options)
  @options[:attributes][:id] = "#{id_prefix}-status"

  @text = text
  @tag_component = Tag.new(context: @context, **tag_options) if tag_options
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Task list item status

Returns:

  • (ActiveSupport::SafeBuffer)


46
47
48
49
50
51
52
53
54
# File 'lib/ccs/components/govuk/task_list/item/status.rb', line 46

def render
  tag.div(class: @options[:attributes][:class], id: @options[:attributes][:id]) do
    if tag_component
      tag_component.render
    else
      text
    end
  end
end