Skip to content

Commit 02a08fe

Browse files
committed
add scroll-top
1 parent b7976c3 commit 02a08fe

File tree

10 files changed

+50
-2
lines changed

10 files changed

+50
-2
lines changed

src/assets/scss/1-settings/_colors.scss

+6
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ $footer-color: $light !default;
5858

5959
// Pseudo-Footer
6060
$pseudo-footer-bg: $brand-color !default;
61+
62+
// Scroll Top
63+
$scroll-top-bg: $brand-color !default;
64+
$scroll-top-color: #fff !default;
65+
$scroll-top-hover-bg: $button-hover-bg !default;
66+
$scroll-top-hover-color: #fff !default;

src/assets/scss/1-settings/_settings.scss

+4
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ $code-radius: $radius !default;
6161
$code-color: currentColor !default;
6262
$code-font-size: .75rem !default;
6363
$code-font-family: "Fira Code", courier, "Courier New", monospace !default;
64+
65+
// Scroll top
66+
$scroll-top-radius: $radius !default;
67+
$scroll-top-size: 2rem !default;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.#{$prefix}scroll-top {
2+
align-items: center;
3+
background-color: $scroll-top-bg;
4+
border-radius: $scroll-top-radius;
5+
bottom: $gutter;
6+
color: $scroll-top-color;
7+
display: flex;
8+
height: $scroll-top-size;
9+
position: fixed;
10+
right: $gutter--50;
11+
text-align: center;
12+
text-decoration: none;
13+
width: $scroll-top-size;
14+
z-index: 1;
15+
}
16+
17+
.#{$prefix}scroll-top__icon {
18+
flex: 1;
19+
}
20+
21+
.#{$prefix}scroll-top:hover {
22+
background-color: $scroll-top-hover-bg;
23+
color: $scroll-top-hover-color;
24+
}

src/assets/scss/site.scss

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
@import "6-components/navigation";
5555
@import "6-components/post";
5656
@import "6-components/promo";
57+
@import "6-components/scroll-top";
5758

5859
// utilities
5960
@import "7-utilities/block";

src/assets/scss/themes/_design-theme.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ section {
1010

1111
pre { font-size: .75rem !important; }
1212

13-
.#{$prefix}code { margin-bottom: $gutter; }
13+
.#{$prefix}code {
14+
margin-bottom: $gutter;
15+
}
1416

1517
.#{$prefix}description p + p { margin-top: $gutter * -.75; }
1618

1719
.#{$prefix}preview {
1820
margin-bottom: $gutter;
21+
position: relative;
1922
}
2023

2124
.#{$prefix}preview ul + ul {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a href="#" class="sdi-scroll-top">
2+
<span class="sdi-scroll-top__icon">⬆</span>
3+
</a>

src/eleventy/includes/layouts/base.njk

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
{% include "components/partials/footer.njk" %}
1414
</div>
1515

16+
{% include "components/partials/scroll-top.njk" %}
17+
1618
<script src="/assets/3rdparty/prism/prism.js" type="text/javascript"></script>
1719
</body>
1820
</html>

src/eleventy/pages/5-objects/container/code.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- The deault container -->
1+
<!-- The default container -->
22
<div class="sdi-container">
33
If container-max-width is set to none, it will occupy 100% of the available width.
44
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a href="#" class="sdi-scroll-top">
2+
<span class="sdi-scroll-top__icon"></span>
3+
</a>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
We're using `scroll-top` to let the user easily access the top of the page. Per default it is just an anchor that doesn't exist on the page, so the browser scrolls to top. The best place for this at the bottom of the page, so the user can reach this function with his thumbs instead of reaching for the top of the screen.
2+
You can easily toggle the visibility with some JavaScript and listening for the scroll depth.

0 commit comments

Comments
 (0)