Class: GovukComponent::Accordion::Section
- Defined in:
- app/components/govuk_component/accordion.rb
Instance Attribute Summary collapse
-
#expanded ⇒ Object
(also: #expanded?)
Returns the value of attribute expanded.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes included from Traits::CustomHtmlAttributes
Instance Method Summary collapse
- #classes ⇒ Object
- #id(suffix: nil) ⇒ Object
-
#initialize(title:, summary: nil, expanded: false, classes: [], html_attributes: {}) ⇒ Section
constructor
A new instance of Section.
Constructor Details
#initialize(title:, summary: nil, expanded: false, classes: [], html_attributes: {}) ⇒ Section
Returns a new instance of Section.
26 27 28 29 30 31 32 |
# File 'app/components/govuk_component/accordion.rb', line 26 def initialize(title:, summary: nil, expanded: false, classes: [], html_attributes: {}) super(classes: classes, html_attributes: html_attributes) self.title = title self.summary = summary self. = end |
Instance Attribute Details
#expanded ⇒ Object Also known as: expanded?
Returns the value of attribute expanded.
22 23 24 |
# File 'app/components/govuk_component/accordion.rb', line 22 def @expanded end |
#summary ⇒ Object
Returns the value of attribute summary.
22 23 24 |
# File 'app/components/govuk_component/accordion.rb', line 22 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
22 23 24 |
# File 'app/components/govuk_component/accordion.rb', line 22 def title @title end |
Instance Method Details
#classes ⇒ Object
38 39 40 |
# File 'app/components/govuk_component/accordion.rb', line 38 def classes super + ( ? %w(govuk-accordion__section--expanded) : []) end |
#id(suffix: nil) ⇒ Object
34 35 36 |
# File 'app/components/govuk_component/accordion.rb', line 34 def id(suffix: nil) [title.parameterize, suffix].compact.join('-') end |