-
Notifications
You must be signed in to change notification settings - Fork 1
/
components_pagination.go
106 lines (91 loc) · 2.46 KB
/
components_pagination.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package bulma
import (
e "github.com/willoma/gomplements"
"maragu.dev/gomponents"
"maragu.dev/gomponents/html"
)
// Pagination creates a pagination element.
//
// https://willoma.github.io/bulma-gomponents/pagination.html
func Pagination(children ...any) e.Element {
list := e.Ul(e.Class("pagination-list"))
p := &pagination{
Element: e.Nav(e.Class("pagination"), list),
list: list,
}
p.With(children...)
return p
}
type pagination struct {
e.Element
list e.Element
}
func (p *pagination) With(children ...any) e.Element {
for _, c := range children {
switch c := c.(type) {
case onList:
p.list.With(c...)
case *paginationEllipsis, *paginationLink:
p.list.With(c)
case []any:
p.With(c...)
default:
p.Element.With(c)
}
}
return p
}
func (p *pagination) Clone() e.Element {
return &pagination{
Element: p.Element.Clone(),
list: p.list.Clone(),
}
}
// PaginationPrevious creates the "Previous" link button for a pagination.
//
// https://willoma.github.io/bulma-gomponents/pagination.html
func PaginationPrevious(children ...any) e.Element {
return e.A(e.Class("pagination-previous"), children)
}
// PaginationNext creates the "Next" link button for a pagination.
//
// https://willoma.github.io/bulma-gomponents/pagination.html
func PaginationNext(children ...any) e.Element {
return e.A(e.Class("pagination-next"), children)
}
// PaginationLink creates a single page link button for a pagination.
//
// https://willoma.github.io/bulma-gomponents/pagination.html
func PaginationLink(children ...any) e.Element {
p := &paginationLink{e.A(e.Class("pagination-link"))}
p.With(children...)
return p
}
type paginationLink struct {
e.Element
}
func (p *paginationLink) Clone() e.Element {
return &paginationLink{p.Element.Clone()}
}
// PaginationAHref creates a single page link button for a pagination.
//
// https://willoma.github.io/bulma-gomponents/pagination.html
func PaginationAHref(href string, children ...any) e.Element {
return PaginationLink(html.Href(href), children)
}
// PaginationEllipsis creates an ellipsis element for a pagination.
//
// https://willoma.github.io/bulma-gomponents/pagination.html
func PaginationEllipsis(children ...any) e.Element {
p := &paginationEllipsis{
e.Span(e.Class("pagination-ellipsis"), gomponents.Raw("…")),
}
p.With(children...)
return p
}
type paginationEllipsis struct {
e.Element
}
func (p *paginationEllipsis) Clone() e.Element {
return &paginationEllipsis{p.Element.Clone()}
}