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

[Feature] Implements a scroll-to-top element for longer page contexts #97

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
25 changes: 24 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,29 @@ <h2>Title</h2>
</pre>


<h3 id="scroll-to-top">Scroll to Top - Block</h3><a class="permalink" href="#scroll-to-top">permalink</a>

<h4>Expected Contexts</h3>
<ul>
<li>The
<span class="distinct">Scroll to top</span> element appears just before the opening
<span class="distinct">Footer</span> tag and immediately after the closing
<span class="distinct">Main</span> tag, and appears only once per page, on all page levels.
</li>

</ul>

<pre>
<code class="lang-html">

<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

</code>
</pre>


<h3 id="page-header-region">Page Header - Region</h3><a class="permalink" href="#page-header-region">permalink</a>

<h4>Expected Contexts</h4>
Expand Down Expand Up @@ -993,7 +1016,7 @@ <h1>Name</h1>
</div>

</header>

</code>
</pre>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/archive-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ <h2><a href="#">Open Access in Practice: A Conversation with President Larry Kra

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/blog-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ <h2>Images Attribution</h2>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/blog-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ <h3><a href="#">Open Access in Practice: A Conversation with President Larry Kra

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/default-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ <h3>Steps to launch</h3>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/home-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ <h2>Images Attribution</h2>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/license-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ <h1>License</h1>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/person-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ <h2><a href="#">Open Access in Practice: A Conversation with President Larry Kra

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/program-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ <h2><a href="#">Open Access in Practice: A Conversation with President Larry Kra

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/program-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ <h2><a href="#">Open Access in Practice: A Conversation with President Larry Kra

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/search-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ <h2><a href="#">Open Access in Practice: A Conversation with President Larry Kra

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/team-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ <h2>Be a part of our team</h2>
<a href="#">Check Open Positions</a>
</article> -->

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/contexts/walkthrough-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ <h1>Walkthrough</h1>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/index-logo.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ <h1>Index Logo Specimen</h1>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/product-logo.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ <h1>Product Logo Specimen</h1>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/tests/grid-sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ <h1>Grid Testing</h1>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/tests/grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ <h1>Grid Testing</h1>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
5 changes: 5 additions & 0 deletions specimen/tests/kitchensink.html
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ <h2>Images Attribution</h2>

</main>

<!-- Scroll-to-top element -->
<aside class="scroll-to-top-wrapper">
<a href="#" class="scroll-to-top" aria-label="Scroll to top" tabindex="0"></a>
</aside>

<footer>
<a class="identity-logo" href="#">Creative Commons</a>

Expand Down
55 changes: 53 additions & 2 deletions src/css/vocabulary.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ body {
display: grid;
grid-template-columns: 5% 3% 6% 6% 15% 30% 15% 6% 6% 3% 5%;
overflow-x: hidden;
position: relative;

font-weight: 400;
-moz-osx-font-smoothing: grayscale;
Expand Down Expand Up @@ -1795,6 +1796,53 @@ body > footer .license svg {

/* program-page context */

/* scroll to top element */

.scroll-to-top-wrapper {
position: absolute;
left: 0;
bottom: 470px;
display: grid;
grid-template-columns: inherit;
width: 100%;
height: calc(100% - 220vh); /* to account for the top offset */
pointer-events: none;
backface-visibility: hidden;
overflow: clip;
}

.scroll-to-top {
position: sticky;
top: 88vh;
grid-column: 10 / span 1;
width: 2.5em;
height: 2.5em;
display: flex;
justify-content: center;
align-items: center;
pointer-events: all;
margin-bottom: 10px;

border-radius: 50%;
text-decoration: none;
background-color: var(--vocabulary-neutral-color-lighter-gray);

}

.scroll-to-top:before {
display: inline-block;
width: 100%;
height: 100%;
content: var(--fa-angle-up);
}

.scroll-to-top:hover {
background-color: var(--vocabulary-brand-color-tomato);
}

.scroll-to-top:focus {
outline: 2px solid var(--vocabulary-brand-color-dark-tomato)
}

/* responsive contexts */

Expand Down Expand Up @@ -1830,7 +1878,11 @@ body > footer .license svg {
display: flex;
flex-wrap: wrap;
}


.scroll-to-top{
display: none;
}

main article.posts.related ul {
grid-template-columns: 1fr 1fr;
}
Expand Down Expand Up @@ -1911,7 +1963,6 @@ body > footer .license svg {
.search-index .search-form form button {
width: 20%;
}

}

@media (max-width: 680px) {
Expand Down