Class: GovukComponent::TaskListComponent::ItemComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::TaskListComponent::ItemComponent
- Defined in:
- app/components/govuk_component/task_list_component/item_component.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
writeonly
Sets the attribute count.
-
#hint ⇒ Object
readonly
Returns the value of attribute hint.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#raw_status ⇒ Object
readonly
Returns the value of attribute raw_status.
-
#raw_title ⇒ Object
readonly
Returns the value of attribute raw_title.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(title: nil, href: nil, hint: nil, count: nil, id_prefix: nil, status: {}, classes: [], html_attributes: {}) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
Methods inherited from Base
Constructor Details
#initialize(title: nil, href: nil, hint: nil, count: nil, id_prefix: nil, status: {}, classes: [], html_attributes: {}) ⇒ ItemComponent
Returns a new instance of ItemComponent.
31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 31 def initialize(title: nil, href: nil, hint: nil, count: nil, id_prefix: nil, status: {}, classes: [], html_attributes: {}) @raw_title = title @href = href @hint = hint @raw_status = status @id_prefix = id_prefix @count = count super(classes:, html_attributes:) end |
Instance Attribute Details
#count=(value) ⇒ Object (writeonly)
Sets the attribute count
29 30 31 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 29 def count=(value) @count = value end |
#hint ⇒ Object (readonly)
Returns the value of attribute hint.
28 29 30 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 28 def hint @hint end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
28 29 30 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 28 def href @href end |
#raw_status ⇒ Object (readonly)
Returns the value of attribute raw_status.
28 29 30 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 28 def raw_status @raw_status end |
#raw_title ⇒ Object (readonly)
Returns the value of attribute raw_title.
28 29 30 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 28 def raw_title @raw_title end |
Instance Method Details
#call ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/govuk_component/task_list_component/item_component.rb', line 42 def call if href.presence && status_content.cannot_start_yet fail(ArgumentError, "item cannot have a href with status where cannot_start_yet: true") end adjusted_html_attributes = if href.present? || title&.href.present? html_attributes_with_link_class else html_attributes end tag.li(safe_join([title_content, status_content].compact), **adjusted_html_attributes) end |