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 83 |
# File 'app/components/bulmacomp/pagination_component.rb', line 78 def initialize(elements: [], pre: [], **opts) super @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
87 88 89 |
# File 'app/components/bulmacomp/pagination_component.rb', line 87 def call tag.nav safe_join([@pre, ulify]), **@opts end |
#map_elements ⇒ String
Map elements in a li tag
103 104 105 |
# File 'app/components/bulmacomp/pagination_component.rb', line 103 def map_elements safe_join(@elements.map { |e| tag.li e }) end |
#ulify ⇒ String
generate a ul tag with map_elements and content
93 94 95 |
# File 'app/components/bulmacomp/pagination_component.rb', line 93 def ulify tag.ul safe_join([map_elements, content]) end |