Skip to content

Commit 4c31146

Browse files
committed
page go-to
1 parent d008673 commit 4c31146

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

_includes/paginator-buttons.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
<span class="button_null"> &#9664; </span>
99
{% endif %}
1010

11-
<!-- pages -->
12-
<span class="page_number">
13-
<p>{{ paginator.page }}/{{ paginator.total_pages }}</p>
14-
</span>
15-
1611
<!-- Next button -->
1712
{% if paginator.next_page %}
1813
<a class="button_link" href="{{ paginator.next_page_path }}">
@@ -22,3 +17,7 @@
2217
<span class="button_null"> &#9654; </span>
2318
{% endif %}
2419
</div>
20+
21+
<!-- Pages -->
22+
{% include paginator-goto.html %}
23+

_includes/paginator-goto.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% assign npages = paginator.total_pages %}
2+
3+
{% if npages > 1 %}
4+
<div class="paginator-goto">
5+
<details>
6+
<summary>
7+
<span class="label">{{ paginator.page }}/{{ paginator.total_pages }}</span>
8+
</summary>
9+
<!-- list -->
10+
<div class="grid-container">
11+
<a class="grid-item" href="{{ site.baseurl }}/">1</a>
12+
{% for index in (2..npages) %}
13+
<a class="grid-item" href="{{ site.baseurl }}/page{{ index }}">{{index}}</a>
14+
{% endfor %}
15+
</nav>
16+
</details>
17+
</div>
18+
{% endif %}

_sass/pagination.scss

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
align-items:center;
102102

103103
.box {
104+
margin: 0px 25px;
104105
padding: 6px;
105106
height: 20px;
106107
line-height: 20px;
@@ -116,6 +117,7 @@
116117
@extend .box;
117118
font-size: 24px;
118119
border-radius: 5px;
120+
z-index: 1;
119121
}
120122

121123
.button_link:hover {
@@ -131,23 +133,55 @@
131133

132134
.page_number {
133135
@extend .box;
134-
border-left: none;
135-
border-right: none;
136136
color: gray;
137137
}
138138
}
139139

140-
// Other options
141-
.pagination_options {
140+
// Go to page
141+
.paginator-goto {
142142
display: flex;
143143
flex-direction: row;
144144
justify-content: center;
145-
padding-top: 10px;
146145

147-
h3 {
148-
text-align: center;
149-
color: $grey-color-dark;
150-
margin-left: 10px;
151-
margin-right: 10px;
146+
summary::-webkit-details-marker {
147+
display:none;
148+
}
149+
summary {
150+
text-align: center;
151+
font-size: 16px;
152+
color: gray;
153+
transform: TRANSLATEY(-26px);
154+
}
155+
summary:hover, details[open] {
156+
.label {
157+
color: white;
158+
background: $brand-color;
159+
}
160+
}
161+
summary:focus {
162+
outline: none;
163+
}
164+
165+
.label {
166+
padding: 5px 10px;
167+
border-radius: 10px;
168+
}
169+
170+
.grid-container {
171+
display: grid;
172+
grid-template-columns: repeat(6, 1fr);
173+
grid-gap: 10px;
174+
transform: TRANSLATEY(-10px);
175+
}
176+
.grid-item {
177+
font-size: 18px;
178+
text-align: center;
179+
padding: 0px 10px;
180+
border: 1px solid LightGray;
181+
border-radius: 8px;
182+
}
183+
.grid-item:hover {
184+
text-decoration: none;
185+
box-shadow: 0px 0px 2px 1px LightGray;
152186
}
153187
}

0 commit comments

Comments
 (0)