Class: Bulmacomp::PaginationComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bulmacomp::PaginationComponent
- Defined in:
- app/components/bulmacomp/pagination_component.rb
Overview
Make an HTML strucrure for a bulma pagination
<nav class="pagination" role="navigation" aria-label="pagination"></nav>
Instance Method Summary collapse
-
#call ⇒ String
Generate safe string with bulma pagination.
-
#initialize(elements: [], pre: [], **opts) {|optional| ... } ⇒ PaginationComponent
constructor
A new instance of PaginationComponent.
-
#map_elements ⇒ String
Map elements in a li tag.
-
#ulify ⇒ String
generate a ul tag with map_elements and content.
Constructor Details
#initialize(elements: [], pre: [], **opts) {|optional| ... } ⇒ PaginationComponent
Returns a new instance of PaginationComponent.
78 79 80 81 82 |
# File 'app/components/bulmacomp/pagination_component.rb', line 78 def initialize(elements: [], pre: [], **opts) @elements = elements @pre = pre @opts = { class: "pagination", role: "navigation", aria_label: "pagination" }.merge opts end |
Instance Method Details
#call ⇒ String
Generate safe string with bulma pagination
86 87 88 |
# File 'app/components/bulmacomp/pagination_component.rb', line 86 def call tag.nav safe_join([ @pre, ulify ]), **@opts end |
#map_elements ⇒ String
Map elements in a li tag
102 103 104 |
# File 'app/components/bulmacomp/pagination_component.rb', line 102 def map_elements safe_join(@elements.map { |e| tag.li e }) end |
#ulify ⇒ String
generate a ul tag with map_elements and content
92 93 94 |
# File 'app/components/bulmacomp/pagination_component.rb', line 92 def ulify tag.ul safe_join([ map_elements, content ]) end |