Class: ShadcnPhlexcomponents::PaginationPrevious

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/pagination.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

#initialize(options = nil, html_options = nil) ⇒ PaginationPrevious

Returns a new instance of PaginationPrevious.



66
67
68
69
# File 'lib/shadcn_phlexcomponents/components/pagination.rb', line 66

def initialize(options = nil, html_options = nil)
  @options = options
  @html_options = html_options
end

Instance Method Details

#default_attributes ⇒ Object



71
72
73
74
75
76
77
# File 'lib/shadcn_phlexcomponents/components/pagination.rb', line 71

def default_attributes
  {
    aria: {
      label: "Go to previous page",
    },
  }
end

#view_template ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/shadcn_phlexcomponents/components/pagination.rb', line 79

def view_template
  @html_options ||= {}
  @html_options = mix(default_attributes, @html_options)
  @html_options[:class] = class_variants(class: @html_options[:class])
  @html_options[:size] = :default

  PaginationLink(@options, @html_options) do
    icon("chevron-left")
    span(class: "hidden sm:block") { "Previous" }
  end
end