Skip to content

Commit f6479e4

Browse files
authored
Merge pull request #405 from pythoncanarias/404-add-up-button
feat: add footer button with scroll up function
2 parents e6249d6 + fb87214 commit f6479e4

6 files changed

Lines changed: 64 additions & 4 deletions

File tree

apps/commons/static/commons/css/base.scss

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ body {
4949

5050
.footer-page {
5151
background-color: $footer-bg;
52+
position: relative;
5253

5354
a {
5455
color: $footer-fg;
@@ -60,11 +61,11 @@ body {
6061

6162
.footer-column {
6263
color: #ebebeb;
63-
padding-top: 0.5rem;
64+
padding-top: 2rem;
6465
padding-bottom: 0.5rem;
6566

6667
@include from($desktop) {
67-
padding-top: 1rem;
68+
padding-top: 2rem;
6869
padding-bottom: 3rem;
6970
}
7071
}
@@ -106,3 +107,19 @@ body {
106107
.container {
107108
padding-top: 2rem;
108109
}
110+
111+
.footer-button {
112+
position: absolute;
113+
top: -22.5px;
114+
left: calc(50% - 22.5px);
115+
z-index: 100;
116+
margin: 0 auto;
117+
display: flex;
118+
justify-content: center;
119+
align-items: center;
120+
width: 45px;
121+
height: 45px;
122+
border-radius: 22.5px;
123+
border-color: $header-bg;
124+
background-color: whitesmoke;
125+
}
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import NavbarBurger from './navbar-burger'
22
import Notifications from './notifications'
33
import Collapsable from './collapsable'
4+
import ScrollUpButton from './scrollUpButton'
45

56
export default {
67
init: () => {
78
NavbarBurger.init()
89
Notifications.init()
910
Collapsable.init()
11+
ScrollUpButton.init()
1012
},
1113
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
function init() {
4+
const scrollToTopBtn = document.getElementById('scrollToTopBtn')
5+
6+
const rootElement = document.documentElement
7+
8+
function scrollToTop(ev) {
9+
ev.preventDefault()
10+
// Scroll to top logic
11+
rootElement.scrollTo({
12+
top: 0,
13+
behavior: 'smooth',
14+
})
15+
}
16+
17+
scrollToTopBtn.addEventListener('click', scrollToTop)
18+
}
19+
20+
export default {
21+
init,
22+
}

apps/commons/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{% if menu %}
4040
is-wide
4141
{% endif %}
42-
">
42+
" id="content-page">
4343
{% if menu %}
4444
<div class="columns is-display">
4545
<div class="column is-one-quarter">

apps/commons/templates/footer.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
{% load utils %}
12
<footer class="footer-page has-text-centered" style="margin-top: 4em;">
2-
3+
<a class="footer-button" id="scrollToTopBtn" href=""
4+
><img
5+
class="footer__button--image"
6+
src="{{ assets|get_asset_key:'commons/img/ico-arrow.svg' }}"
7+
alt="scroll button up"
8+
titile="scroll button up"
9+
/></a>
310
<div class="columns">
411
<div class="column has-text-weight-light">
512
<div class="footer-column">

0 commit comments

Comments
 (0)