Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new design for previous and next page buttons #11770

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions src/_includes/next-prev-nav.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{% if include.next or include.prev -%}
{% if include.next and include.prev -%}
{% assign nav_class = 'site-nextprev-nav' -%}
{% else -%}
{% assign nav_class = 'site-nextprev-nav__single' -%}
{% endif -%}
<nav class="{{nav_class}}">
<ul>
{% if include.prev.path -%}
<li class="prev">
<a href="{{ include.prev.path }}">{{ include.prev.title }}</a>
</li>
{% endif -%}
{% if include.next.path -%}
<li class="next">
<a href="{{ include.next.path }}">{{ include.next.title }}</a>
</li>
{% endif -%}
</ul>
{% if next or prev -%}
<nav id="site-prev-next">
{% if prev.path -%}
<a class="prev" href="{{ prev.path }}">
<span class="material-symbols" aria-hidden="true">chevron_left</span>
<div>
<span class="prev-next-subtitle" aria-label="Previous page:">Previous</span>
<span class="prev-next-title">{{ prev.title}}</span>
</div>
</a>
{% endif -%}
{% if next.path -%}
<a class="next" href="{{ next.path }}">
<div>
<span class="prev-next-subtitle" aria-label="Next page:">Next</span>
<span class="prev-next-title">{{ next.title}}</span>
</div>
<span class="material-symbols" aria-hidden="true">chevron_right</span>
</a>
{% endif -%}
</nav>
{% endif -%}
10 changes: 5 additions & 5 deletions src/_layouts/base.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% assign cache_bust = '?v=4' %}
{% assign cache_bust = '?v=5' %}
{% assign page_url = page.url | regex_replace: '/index$|/index.html$|\.html$|/$' -%}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{% if short-title %}{{short-title}}{% else %}{{title}}{% endif %} | {{site.title}}</title>
<link rel="icon" href="/assets/images/branding/flutter/icon/64.png" eleventy:ignore>
<link rel="apple-touch-icon" href="/assets/images/branding/flutter/logo/flutter-logomark-320px.png" eleventy:ignore>
<link rel="icon" href="/assets/images/branding/flutter/icon/64.png">
<link rel="apple-touch-icon" href="/assets/images/branding/flutter/logo/flutter-logomark-320px.png">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="theme-color" content="#ffffff">

Expand All @@ -18,7 +18,6 @@

{%- if isProduction == true -%}
<meta name="google-site-verification" content="{{ site.google_site_verification }}">
{% endif -%}
<script>
window.dataLayer = window.dataLayer || [];
</script>
Expand All @@ -37,6 +36,7 @@
ga('create', '{{ site.google_analytics_id }}', 'auto');
ga('send', 'pageview');
</script>
{% endif -%}

{% assign desc = description | default: site.description | strip_html | strip_newlines | truncate: 160 -%}
{% unless desc and desc != '' -%}
Expand All @@ -53,7 +53,7 @@
<meta property="og:title" content="{{title | escape}}">
<meta property="og:url" content="{{site.url | append: page_url}}">
<meta property="og:description" content="{{desc | escape}}">
<meta property="og:image" content="{{site.url | append: og_image_path}}" eleventy:ignore>
<meta property="og:image" content="{{site.url | append: og_image_path}}">

{% unless strip_fonts == true -%}
<link href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion src/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 id="document-title">{{ title }}</h1>
</header>
{{ content }}

{% include next-prev-nav.html prev=prev, next=next %}
{% render next-prev-nav.html, prev:prev, next:next %}

{% include trailing.html %}
</article>
Expand Down
93 changes: 50 additions & 43 deletions src/_sass/components/_next-prev-nav.scss
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
@use '../base/mixins';
@use '../base/variables' as *;

.site-nextprev-nav, // Nav with both links
.site-nextprev-nav__single // Nav with single link
{
clear: both;
#site-prev-next {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
gap: 1rem;
margin-block-end: 1rem;

ul {
$spacer-base: 0.75rem;
.prev {
text-align: left;
justify-content: flex-start;
}

list-style-type: none;
margin: 0;
padding: 0;
.next {
text-align: right;
justify-content: flex-end;
margin-left: auto;
}

li {
display: flex;
margin-bottom: $spacer-base;
white-space: nowrap;
@media (min-width: 576px) {
flex-wrap: nowrap;

a {
text-overflow: ellipsis;
overflow: hidden;
}
.prev, .next {
max-width: 50%;
}
}

&.prev:before {
color: $site-color-primary;
content: "\2329"; // &lang;
padding-right: $spacer-base * 0.5;
}
a {
overflow-x: hidden;
flex-basis: 100%;

&.next {
justify-content: flex-end;
text-align: right;
}
text-decoration: none;
color: $site-color-body;
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 0.25rem;

&.next:after {
color: $site-color-primary;
content: "\232A"; // &rang;
padding-left: $spacer-base * 0.5;
}
}
}
}
display: flex;
flex-direction: row;
align-items: center;
padding: 0.5rem;
min-height: 100%;

.site-nextprev-nav > ul > li {
width: 49%;
> div {
display: flex;
flex-direction: column;
padding: 0.5rem;

&.prev { float: left; }
}
.prev-next-subtitle {
font-size: 0.75rem;
line-height: 0.75rem;
}
}

.site-nextprev-nav__single > ul > li {
&.prev { width: 100%; }
&:hover {
@include mixins.interaction-style(3%);
}

&.next {
float: right;
width: 100%;
&:active {
@include mixins.interaction-style(5%);
}
}
}