Class: GovukComponent::PaginationComponent::AdjacentPage

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

Direct Known Subclasses

NextPage, PreviousPage

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(href:, suffix:, text:, block_mode: true, label_text: nil, classes: [], html_attributes: {}) ⇒ AdjacentPage

Returns a new instance of AdjacentPage.



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

def initialize(href:, suffix:, text:, block_mode: true, label_text: nil, classes: [], html_attributes: {})
  @href                 = href
  @label_text           = label_text
  @text                 = text
  @block_mode           = block_mode
  @suffix               = suffix

  super(html_attributes:, classes:)
end

Instance Attribute Details

#block_modeObject (readonly) Also known as: block_mode?

Returns the value of attribute block_mode.



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

def block_mode
  @block_mode
end

#hrefObject (readonly)

Returns the value of attribute href.



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

def href
  @href
end

#label_textObject (readonly)

Returns the value of attribute label_text.



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

def label_text
  @label_text
end

#suffixObject (readonly)

Returns the value of attribute suffix.



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

def suffix
  @suffix
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#visually_hidden_textObject (readonly)

Returns the value of attribute visually_hidden_text.



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

def visually_hidden_text
  @visually_hidden_text
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
# File 'app/components/govuk_component/pagination_component/adjacent_page.rb', line 15

def call
  tag.div(**html_attributes) do
    tag.a(href:, class: ["#{brand}-link", "#{brand}-pagination__link"], rel: suffix) do
      safe_join([body, divider, label_content])
    end
  end
end