Class: NitroKit::Pagination
Instance Attribute Summary
Attributes inherited from Component
#attrs
Instance Method Summary
collapse
Methods inherited from Component
#builder, builder_method, from_template
Constructor Details
#initialize(**attrs) ⇒ Pagination
Returns a new instance of Pagination.
5
6
7
8
9
10
11
|
# File 'app/components/nitro_kit/pagination.rb', line 5
def initialize(**attrs)
super(
attrs,
class: merge_class(nav_class, attrs[:class]),
aria: { label: "Pagination" }
)
end
|
Instance Method Details
#ellipsis(**attrs) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/components/nitro_kit/pagination.rb', line 62
def ellipsis(**attrs)
builder do
render(
Button.new(
**mattr(
attrs,
variant: :ghost,
disabled: true,
class: page_class
)
)
) do
"…"
end
end
end
|
#next(text = nil, **attrs, &block) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/components/nitro_kit/pagination.rb', line 32
def next(text = nil, **attrs, &block)
builder do
page_link(**mattr(attrs, aria: { label: "Next page" })) do
if text || block_given?
text_or_block(text, &block)
else
plain("Next")
render(Icon.new("arrow-right"))
end
end
end
end
|
#page(text = nil, current: false, **attrs, &block) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/components/nitro_kit/pagination.rb', line 45
def page(text = nil, current: false, **attrs, &block)
builder do
page_link(
**mattr(
attrs,
aria: {
current: current ? "page" : nil
},
disabled: current,
class: [ page_class, current && "bg-zinc-200/50 dark:bg-zinc-800/50" ]
)
) do
text_or_block(text, &block)
end
end
end
|
#prev(text = nil, **attrs, &block) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/components/nitro_kit/pagination.rb', line 19
def prev(text = nil, **attrs, &block)
builder do
page_link(**mattr(attrs, aria: { label: "Previous page" })) do
if text || block_given?
text_or_block(text, &block)
else
render(Icon.new("arrow-left"))
plain("Previous")
end
end
end
end
|
#view_template ⇒ Object
13
14
15
16
17
|
# File 'app/components/nitro_kit/pagination.rb', line 13
def view_template
nav(**attrs) do
yield
end
end
|