Class: CCS::Components::GovUK::TaskList::Item
- Defined in:
- lib/ccs/components/govuk/task_list/item.rb,
lib/ccs/components/govuk/task_list/item/title.rb,
lib/ccs/components/govuk/task_list/item/status.rb
Overview
GOV.UK Task list item
The individual list item for the task list
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the task list item
{ class: 'govuk-task-list__item' }.freeze
Instance Method Summary collapse
-
#initialize(title:, status:, index:, id_prefix:, hint_text: nil, **options) ⇒ Item
constructor
A new instance of Item.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Task list item.
Constructor Details
#initialize(title:, status:, index:, id_prefix:, hint_text: nil, **options) ⇒ Item
Returns a new instance of Item.
42 43 44 45 46 47 48 49 50 |
# File 'lib/ccs/components/govuk/task_list/item.rb', line 42 def initialize(title:, status:, index:, id_prefix:, hint_text: nil, **) super(**) @options[:attributes][:class] << ' govuk-task-list__item--with-link' if title[:href] @id_prefix = "#{id_prefix}-#{index}" @title = Title.new(context: @context, id_prefix: @id_prefix, hint_text: hint_text, **title) @hint_text = hint_text @status = Status.new(context: @context, id_prefix: @id_prefix, **status) end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Task list item
58 59 60 61 62 63 64 65 66 |
# File 'lib/ccs/components/govuk/task_list/item.rb', line 58 def render tag.li(class: [:attributes][:class]) do concat(tag.div(class: 'govuk-task-list__name-and-hint') do concat(title.render) concat(tag.div(hint_text, class: 'govuk-task-list__hint', id: "#{id_prefix}-hint")) if hint_text end) concat(status.render) end end |