Skip to content

Commit 62bcd60

Browse files
committed
feat(ui): redesign the pagination button on home page
1 parent 414b8f9 commit 62bcd60

File tree

5 files changed

+97
-110
lines changed

5 files changed

+97
-110
lines changed

_includes/post-paginator.html

Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,91 @@
11
<!-- The paginator for post list on HomgPage. -->
22

3-
<ul class="pagination align-items-center mt-4 mb-1 ps-lg-2">
4-
<!-- left arrow -->
5-
{% if paginator.previous_page %}
6-
{% assign prev_url = paginator.previous_page_path | relative_url %}
7-
{% else %}
8-
{% assign prev_url = '#' %}
9-
{% endif %}
3+
<nav aria-label="Page Navigation">
4+
<ul class="pagination align-items-center mt-4 mb-0">
5+
<!-- left arrow -->
6+
{% if paginator.previous_page %}
7+
{% assign prev_url = paginator.previous_page_path | relative_url %}
8+
{% else %}
9+
{% assign prev_url = '#' %}
10+
{% endif %}
1011

11-
<li class="page-item {% unless paginator.previous_page %}disabled{% endunless %}">
12-
<a class="page-link btn-box-shadow" href="{{ prev_url }}" aria-label="previous-page">
13-
<i class="fas fa-angle-left"></i>
14-
</a>
15-
</li>
12+
<li class="page-item {% unless paginator.previous_page %}disabled{% endunless %}">
13+
<a class="page-link" href="{{ prev_url }}" aria-label="previous-page">
14+
<i class="fas fa-angle-left"></i>
15+
</a>
16+
</li>
1617

17-
<!-- page numbers -->
18-
{% assign left_ellipsis = false %}
19-
{% assign right_ellipsis = false %}
18+
<!-- page numbers -->
19+
{% assign left_ellipsis = false %}
20+
{% assign right_ellipsis = false %}
2021

21-
{% for i in (1..paginator.total_pages) %}
22-
{% assign pre = paginator.page | minus: 1 %}
23-
{% assign next = paginator.page | plus: 1 %}
24-
{% assign pre_less = pre | minus: 1 %}
25-
{% assign next_more = next | plus: 1 %}
26-
{% assign show = false %}
22+
{% for i in (1..paginator.total_pages) %}
23+
{% assign pre = paginator.page | minus: 1 %}
24+
{% assign next = paginator.page | plus: 1 %}
25+
{% assign pre_less = pre | minus: 1 %}
26+
{% assign next_more = next | plus: 1 %}
27+
{% assign show = false %}
2728

28-
{% if paginator.page == 1 %}
29-
{% if i <= 3 or i == paginator.total_pages %}
30-
{% assign show = true %}
31-
{% endif %}
32-
{% elsif paginator.page == paginator.total_pages %}
33-
{% if i == 1 or i >= pre_less %}
34-
{% assign show = true %}
29+
{% if paginator.page == 1 %}
30+
{% if i <= 3 or i == paginator.total_pages %}
31+
{% assign show = true %}
32+
{% endif %}
33+
{% elsif paginator.page == paginator.total_pages %}
34+
{% if i == 1 or i >= pre_less %}
35+
{% assign show = true %}
36+
{% endif %}
37+
{% else %}
38+
{% if i == 1 or i == paginator.total_pages %}
39+
{% assign show = true %}
40+
{% elsif i >= pre and i <= next %}
41+
{% assign show = true %}
42+
{% endif %}
3543
{% endif %}
36-
{% else %}
37-
{% if i == 1 or i == paginator.total_pages %}
38-
{% assign show = true %}
39-
{% elsif i >= pre and i <= next %}
40-
{% assign show = true %}
41-
{% endif %}
42-
{% endif %}
4344

44-
{% if show %}
45-
<!-- show number -->
46-
<li class="page-item {% if i == paginator.page %} active{% endif %}">
47-
<a
48-
class="page-link btn-box-shadow"
49-
href="{% if i > 1 %}{{ site.paginate_path | replace: ':num', i | relative_url }}{% else %}{{ '/' | relative_url }}{% endif %}"
50-
>
51-
{{- i -}}
52-
</a>
53-
</li>
54-
{% else %}
55-
<!-- hide number -->
56-
{% if i < pre and left_ellipsis == false %}
57-
<li class="page-item disabled">
58-
<span class="page-link btn-box-shadow">...</span>
59-
</li>
60-
{% assign left_ellipsis = true %}
61-
{% elsif i > next and right_ellipsis == false %}
62-
<li class="page-item disabled">
63-
<span class="page-link btn-box-shadow">...</span>
45+
{% if show %}
46+
<!-- show number -->
47+
<li class="page-item {% if i == paginator.page %} active{% endif %}">
48+
<a
49+
class="page-link"
50+
href="{% if i > 1 %}{{ site.paginate_path | replace: ':num', i | relative_url }}{% else %}{{ '/' | relative_url }}{% endif %}"
51+
>
52+
{{- i -}}
53+
</a>
6454
</li>
65-
{% assign right_ellipsis = true %}
55+
{% else %}
56+
<!-- hide number -->
57+
{% if i < pre and left_ellipsis == false %}
58+
<li class="page-item disabled">
59+
<span class="page-link">...</span>
60+
</li>
61+
{% assign left_ellipsis = true %}
62+
{% elsif i > next and right_ellipsis == false %}
63+
<li class="page-item disabled">
64+
<span class="page-link">...</span>
65+
</li>
66+
{% assign right_ellipsis = true %}
67+
{% endif %}
6668
{% endif %}
67-
{% endif %}
68-
{% endfor %}
69+
{% endfor %}
6970

70-
<!-- mobile pagination -->
71-
<li class="page-index align-middle">
72-
<span>{{ paginator.page }}</span>
73-
<span class="text-muted">/ {{ paginator.total_pages }}</span>
74-
</li>
71+
<!-- mobile pagination -->
72+
<li class="page-index align-middle">
73+
<span>{{ paginator.page }}</span>
74+
<span class="text-muted">/ {{ paginator.total_pages }}</span>
75+
</li>
7576

76-
<!-- right arrow -->
77-
{% if paginator.next_page_path %}
78-
{% assign next_url = paginator.next_page_path | relative_url %}
79-
{% else %}
80-
{% assign next_url = '#' %}
81-
{% endif %}
77+
<!-- right arrow -->
78+
{% if paginator.next_page_path %}
79+
{% assign next_url = paginator.next_page_path | relative_url %}
80+
{% else %}
81+
{% assign next_url = '#' %}
82+
{% endif %}
8283

83-
<li class="page-item {% unless paginator.next_page_path %}disabled{% endunless %}">
84-
<a class="page-link btn-box-shadow" href="{{ next_url }}" aria-label="next-page">
85-
<i class="fas fa-angle-right"></i>
86-
</a>
87-
</li>
88-
</ul>
84+
<li class="page-item {% unless paginator.next_page_path %}disabled{% endunless %}">
85+
<a class="page-link" href="{{ next_url }}" aria-label="next-page">
86+
<i class="fas fa-angle-right"></i>
87+
</a>
88+
</li>
89+
</ul>
90+
</nav>
8991
<!-- .pagination -->

_sass/addon/commons.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ i {
604604
}
605605

606606
.btn-box-shadow {
607-
box-shadow: 0 0 8px 0 var(--btn-box-shadow) !important;
607+
box-shadow: var(--card-shadow);
608608
}
609609

610610
/* overwrite bootstrap muted */

_sass/colors/typography-dark.scss

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
--blockquote-text-color: #868686;
1818
--link-color: rgb(138, 180, 248);
1919
--link-underline-color: rgb(82, 108, 150);
20-
--button-bg: rgb(39, 40, 43);
21-
--btn-border-color: rgb(63, 65, 68);
20+
--button-bg: #1e1e1e;
21+
--btn-border-color: #2e2f31;
2222
--btn-backtotop-color: var(--text-color);
23-
--btn-backtotop-border-color: var(--btn-border-color);
23+
--btn-backtotop-border-color: #212122;
2424
--btn-box-shadow: var(--main-bg);
2525
--card-header-bg: #292929;
2626
--checkbox-color: rgb(118, 120, 121);
@@ -55,9 +55,7 @@
5555
/* Home page */
5656
--post-list-text-color: rgb(175, 176, 177);
5757
--btn-patinator-text-color: var(--text-color);
58-
--btn-paginator-hover-color: rgb(64, 65, 66);
59-
--btn-paginator-border-color: var(--btn-border-color);
60-
--btn-text-color: var(--text-color);
58+
--btn-paginator-hover-color: #2e2e2e;
6159

6260
/* Posts */
6361
--toc-highlight: rgb(116, 178, 243);

_sass/colors/typography-light.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
--post-list-text-color: dimgray;
6060
--btn-patinator-text-color: #555555;
6161
--btn-paginator-hover-color: var(--sidebar-bg);
62-
--btn-paginator-border-color: var(--sidebar-bg);
63-
--btn-text-color: #676666;
6462

6563
/* Posts */
6664
--toc-highlight: #0550ae;

_sass/layout/home.scss

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,37 @@
8989
} /* #post-list */
9090

9191
.pagination {
92-
color: var(--btn-patinator-text-color);
92+
color: var(--text-color);
9393
font-family: Lato, sans-serif;
94+
justify-content: space-evenly;
9495

9596
a:hover {
9697
text-decoration: none;
9798
}
9899

99100
.page-item {
100101
.page-link {
101-
color: inherit;
102-
width: 2.5rem;
103-
height: 2.5rem;
104-
padding: 0;
102+
color: var(--btn-patinator-text-color);
103+
padding: 0 0.6rem;
105104
display: -webkit-box;
106105
-webkit-box-pack: center;
107106
-webkit-box-align: center;
108-
border-radius: 50%;
109-
border: 1px solid var(--btn-paginator-border-color);
110-
background-color: var(--button-bg);
107+
border-radius: 0.5rem;
108+
border: 0;
109+
background-color: inherit;
110+
}
111111

112-
&:hover {
112+
&.active {
113+
.page-link {
113114
background-color: var(--btn-paginator-hover-color);
114115
}
115116
}
116117

117-
&.active {
118+
&:not(.active) {
118119
.page-link {
119-
background-color: var(--btn-paginator-hover-color);
120-
color: var(--btn-text-color);
120+
&:hover {
121+
box-shadow: inset var(--btn-border-color) 0 0 0 1px;
122+
}
121123
}
122124
}
123125

@@ -126,15 +128,8 @@
126128

127129
.page-link {
128130
color: rgba(108, 117, 125, 0.57);
129-
border-color: var(--btn-paginator-border-color);
130-
background-color: var(--button-bg);
131131
}
132132
}
133-
134-
&:first-child .page-link,
135-
&:last-child .page-link {
136-
border-radius: 50%;
137-
}
138133
} /* .page-item */
139134
} /* .pagination */
140135

@@ -175,8 +170,6 @@
175170
/* Hide SideBar and TOC */
176171
@media all and (max-width: 830px) {
177172
.pagination {
178-
justify-content: space-evenly;
179-
180173
.page-item {
181174
&:not(:first-child):not(:last-child) {
182175
display: none;
@@ -193,16 +186,12 @@
193186

194187
.pagination {
195188
font-size: 0.85rem;
189+
justify-content: center;
196190

197191
.page-item {
198192
&:not(:last-child) {
199193
margin-right: 0.7rem;
200194
}
201-
202-
.page-link {
203-
width: 2rem;
204-
height: 2rem;
205-
}
206195
}
207196

208197
.page-index {

0 commit comments

Comments
 (0)