Class: CCS::Components::GovUK::TaskList
- Defined in:
- lib/ccs/components/govuk/task_list.rb,
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
This is used to generate the task list component from the GDS - Components - Task list
Defined Under Namespace
Classes: Item
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the task list
{ class: 'govuk-task-list' }.freeze
Instance Method Summary collapse
-
#initialize(task_list_items:, id_prefix: nil, **options) ⇒ TaskList
constructor
A new instance of TaskList.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK task list component.
Constructor Details
#initialize(task_list_items:, id_prefix: nil, **options) ⇒ TaskList
Returns a new instance of TaskList.
30 31 32 33 34 |
# File 'lib/ccs/components/govuk/task_list.rb', line 30 def initialize(task_list_items:, id_prefix: nil, **) super(**) @task_list_items = task_list_items.map.with_index(1) { |task_list_item, index| Item.new(context: @context, index: index, id_prefix: id_prefix || 'task-list', **task_list_item) if task_list_item.present? } end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK task list component
40 41 42 43 44 |
# File 'lib/ccs/components/govuk/task_list.rb', line 40 def render tag.ul(**[:attributes]) do task_list_items.each { |task_list_item| concat(task_list_item.render) if task_list_item } end end |