Class: PhlexKit::PaginationNext
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::PaginationNext
- Defined in:
- app/components/phlex_kit/pagination/pagination_next.rb
Overview
"Next" control (label + chevron, label hidden on small screens), ported from shadcn/ui's PaginationNext. Renders its own
Constant Summary collapse
- DEFAULT_LABEL =
"Next"
Instance Method Summary collapse
-
#initialize(href: "#", label: DEFAULT_LABEL, **attrs) ⇒ PaginationNext
constructor
A new instance of PaginationNext.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(href: "#", label: DEFAULT_LABEL, **attrs) ⇒ PaginationNext
Returns a new instance of PaginationNext.
7 8 9 10 11 |
# File 'app/components/phlex_kit/pagination/pagination_next.rb', line 7 def initialize(href: "#", label: DEFAULT_LABEL, **attrs) @href = href @label = label @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/phlex_kit/pagination/pagination_next.rb', line 13 def view_template # The English aria-label only accompanies the default English label; a # custom (possibly localized) label: speaks for itself — hardcoding # "Go to next page" over it would make AT announce the wrong language. base = { href: @href, class: "pk-button ghost pk-pagination-next" } # ...and never over a caller-supplied aria label — `mix` would fuse # the two strings instead of overriding. base[:aria] = { label: "Go to next page" } if @label == DEFAULT_LABEL && !aria_labelled? li do a(**mix(base, @attrs)) do span(class: "pk-pagination-label") { @label } render Icon.new(:chevron_right, size: nil) end end end |