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