Class: PhlexKit::PaginationLink

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/pagination/pagination_link.rb

Overview

A page-number link (square ghost button; outline when active), ported from shadcn/ui's PaginationLink. Renders its own

  • . See pagination.rb.

  • Instance Method Summary collapse

    Methods inherited from BaseComponent

    #on

    Constructor Details

    #initialize(href: "#", active: false, **attrs) ⇒ PaginationLink

    Returns a new instance of PaginationLink.

    
    
    5
    6
    7
    8
    9
    # File 'app/components/phlex_kit/pagination/pagination_link.rb', line 5
    
    def initialize(href: "#", active: false, **attrs)
      @href = href
      @active = active
      @attrs = attrs
    end

    Instance Method Details

    #view_template(&block) ⇒ Object

    
    
    11
    12
    13
    14
    15
    16
    17
    18
    19
    # File 'app/components/phlex_kit/pagination/pagination_link.rb', line 11
    
    def view_template(&block)
      li do
        a(**mix({
          href: @href,
          class: "pk-button #{@active ? "outline" : "ghost"} icon",
          aria: { current: (@active ? "page" : nil) }
        }, @attrs), &block)
      end
    end