Improve pagination styling

This commit is contained in:
Michael Rose 2016-03-30 15:26:25 -04:00
parent 9d14c68382
commit 570864dfb8
4 changed files with 85 additions and 25 deletions

View file

@ -6,15 +6,17 @@
{% comment %} Link for previous page {% endcomment %} {% comment %} Link for previous page {% endcomment %}
{% if paginator.previous_page %} {% if paginator.previous_page %}
{% if paginator.previous_page == 1 %} {% if paginator.previous_page == 1 %}
<li><a href="{{ base_path }}/" class="btn btn--inverse btn--small">{{ site.data.ui-text[site.locale].pagination_previous }}</a></li> <li><a href="{{ base_path }}/">{{ site.data.ui-text[site.locale].pagination_previous }}</a></li>
{% else %} {% else %}
<li><a href="{{ base_path }}/page{{ paginator.previous_page }}/" class="btn btn--inverse btn--small">{{ site.data.ui-text[site.locale].pagination_previous }}</a></li> <li><a href="{{ base_path }}/page{{ paginator.previous_page }}/">{{ site.data.ui-text[site.locale].pagination_previous }}</a></li>
{% endif %} {% endif %}
{% else %}
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_previous }}</span></a></li>
{% endif %} {% endif %}
{% comment %}First page{% endcomment %} {% comment %} First page {% endcomment %}
{% if paginator.page == 1 %} {% if paginator.page == 1 %}
<li><strong class="current">1</strong></li> <li><a href="#" class="disabled current">1</a></li>
{% else %} {% else %}
<li><a href="{{ base_path }}/">1</a></li> <li><a href="{{ base_path }}/">1</a></li>
{% endif %} {% endif %}
@ -23,7 +25,7 @@
{% if paginator.page > 4 %} {% if paginator.page > 4 %}
{% assign page_start = paginator.page | minus: 2 %} {% assign page_start = paginator.page | minus: 2 %}
{% comment %} Ellipsis for truncated links {% endcomment %} {% comment %} Ellipsis for truncated links {% endcomment %}
<li>&hellip;</li> <li><a href="#" class="disabled">&hellip;</a></li>
{% endif %} {% endif %}
{% assign page_end = paginator.total_pages | minus: 1 %} {% assign page_end = paginator.total_pages | minus: 1 %}
@ -34,32 +36,34 @@
{% for index in (page_start..page_end) %} {% for index in (page_start..page_end) %}
{% if index == paginator.page %} {% if index == paginator.page %}
<li><strong class="current">{{ index }}</strong></li> <li><a href="{{ base_path }}/page{{ index }}/" class="disabled current">{{ index }}</a></li>
{% else %} {% else %}
{% comment %}Distance from current page and this link{% endcomment %} {% comment %} Distance from current page and this link {% endcomment %}
{% assign dist = paginator.page | minus: index %} {% assign dist = paginator.page | minus: index %}
{% if dist < 0 %} {% if dist < 0 %}
{% comment %}Distance must be a positive value{% endcomment %} {% comment %} Distance must be a positive value {% endcomment %}
{% assign dist = 0 | minus: dist %} {% assign dist = 0 | minus: dist %}
{% endif %} {% endif %}
<li><a href="{{ base_path }}/page{{ index }}/">{{ index }}</a></li> <li><a href="{{ base_path }}/page{{ index }}/">{{ index }}</a></li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% comment %}Ellipsis for truncated links{% endcomment %} {% comment %} Ellipsis for truncated links {% endcomment %}
{% if pages_to_end > 3 %} {% if pages_to_end > 3 %}
<li>&hellip;</li> <li><a href="#" class="disabled">&hellip;</a></li>
{% endif %} {% endif %}
{% if paginator.page == paginator.total_pages %} {% if paginator.page == paginator.total_pages %}
<li><strong class="current">{{ paginator.page }}</strong></li> <li><a href="#" class="disabled current">{{ paginator.page }}</a></li>
{% else %} {% else %}
<li><a href="{{ base_path }}/page{{ paginator.total_pages }}/">{{ paginator.total_pages }}</a></li> <li><a href="{{ base_path }}/page{{ paginator.total_pages }}/">{{ paginator.total_pages }}</a></li>
{% endif %} {% endif %}
{% comment %}Link next page{% endcomment %} {% comment %} Link next page {% endcomment %}
{% if paginator.next_page %} {% if paginator.next_page %}
<li><a href="{{ base_path }}/page{{ paginator.next_page }}/" class="btn btn--inverse btn--small">{{ site.data.ui-text[site.locale].pagination_next }}</a></li> <li><a href="{{ base_path }}/page{{ paginator.next_page }}/">{{ site.data.ui-text[site.locale].pagination_next }}</a></li>
{% else %}
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_next }}</span></a></li>
{% endif %} {% endif %}
</ul> </ul>
</nav> </nav>

View file

@ -1,8 +1,12 @@
<nav class="pagination"> <nav class="pagination">
{% if page.previous %} {% if page.previous %}
<a href="{{ base_path }}{{ page.previous.url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_previous }}</a> <a href="{{ base_path }}{{ page.previous.url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_previous }}</a>
{% else %}
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[site.locale].pagination_previous }}</a>
{% endif %} {% endif %}
{% if page.next %} {% if page.next %}
<a href="{{ base_path }}{{ page.next.url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_next }}</a> <a href="{{ base_path }}{{ page.next.url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_next }}</a>
{% else %}
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[site.locale].pagination_next }}</a>
{% endif %} {% endif %}
</nav> </nav>

View file

@ -55,9 +55,8 @@
.pagination { .pagination {
@include full(); @include full();
@include clearfix(); @include clearfix();
margin-top: 2em; margin-top: 1em;
padding-top: 2em; padding-top: 1em;
border-top: 1px solid $border-color;
ul { ul {
margin: 0; margin: 0;
@ -68,16 +67,53 @@
} }
li { li {
display: inline-block; display: block;
} float: left;
margin-left: -1px;
li + li:before { a {
content: ""; margin-bottom: 0.25em;
padding-right: 10px; padding: 0.5em 1em;
} font-family: $sans-serif;
font-size: 14px;
font-weight: bold;
line-height: 1.5;
text-align: center;
text-decoration: none;
color: mix(#fff, $gray, 25%);
border: 1px solid $light-gray;
border-radius: 0;
.current { &:hover {
font-weight: bold; color: $gray;
}
&.current {
color: $primary-color;
}
&.disabled {
color: $light-gray;
pointer-events: none;
cursor: not-allowed;
}
}
&:first-child {
margin-left: 0;
a {
border-top-left-radius: $border-radius;
border-bottom-left-radius: $border-radius;
}
}
&:last-child {
a {
border-top-right-radius: $border-radius;
border-bottom-right-radius: $border-radius;
}
}
} }
/* next/previous buttons */ /* next/previous buttons */
@ -95,6 +131,7 @@
color: mix(#fff, $gray, 25%); color: mix(#fff, $gray, 25%);
border: 1px solid $light-gray; border: 1px solid $light-gray;
border-radius: $border-radius; border-radius: $border-radius;
&:hover { &:hover {
color: $gray; color: $gray;
} }
@ -109,9 +146,24 @@
border-top-left-radius: 0; border-top-left-radius: 0;
border-bottom-left-radius: 0; border-bottom-left-radius: 0;
} }
&.disabled {
color: $light-gray;
pointer-events: none;
cursor: not-allowed;
}
} }
} }
.page__content + .pagination,
.page__meta + .pagination,
.page__share + .pagination,
.page__comments + .pagination {
margin-top: 2em;
padding-top: 2em;
border-top: 1px solid $border-color;
}
/* /*
Priority plus navigation Priority plus navigation

File diff suppressed because one or more lines are too long