Class: GovukComponent::DetailsComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/details_component.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(summary_text: nil, text: nil, classes: [], id: nil, open: nil, html_attributes: {}) ⇒ DetailsComponent

Returns a new instance of DetailsComponent.



6
7
8
9
10
11
12
13
# File 'app/components/govuk_component/details_component.rb', line 6

def initialize(summary_text: nil, text: nil, classes: [], id: nil, open: nil, html_attributes: {})
  @summary_text = summary_text
  @text         = text
  @id           = id
  @open         = open

  super(classes:, html_attributes:)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'app/components/govuk_component/details_component.rb', line 2

def id
  @id
end

#openObject (readonly)

Returns the value of attribute open.



2
3
4
# File 'app/components/govuk_component/details_component.rb', line 2

def open
  @open
end

#summary_textObject (readonly)

Returns the value of attribute summary_text.



2
3
4
# File 'app/components/govuk_component/details_component.rb', line 2

def summary_text
  @summary_text
end

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'app/components/govuk_component/details_component.rb', line 2

def text
  @text
end

Instance Method Details

#callObject



15
16
17
18
19
# File 'app/components/govuk_component/details_component.rb', line 15

def call
  tag.details(id:, open:, **html_attributes) do
    safe_join([summary, description])
  end
end