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

37 scroll to top button #57

Merged
merged 9 commits into from
Aug 28, 2023
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
26 changes: 20 additions & 6 deletions blocks/v2-footer/v2-footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,34 @@
}

/* Scroll to top */
.scroll-to-top {

.v2-scroll-to-top {
display: none;
position: fixed;
bottom: 20px;
margin: 0;
bottom: 30px;
right: 30px;
z-index: 99;
border: none;
cursor: pointer;
border-radius: 10px;
padding: 12px 24px;
padding: 12px;
background-color: var(--c-primary-gold);
box-shadow: 0 8px 16px rgb(0 0 0 / 30%);
}

.v2-scroll-to-top:hover {
background-color: var(--button-secondary-gold-hover);
}

.scroll-to-top:hover {
background-color: #53565A;
.v2-scroll-to-top:active {
background-color: var(--button-secondary-gold-pressed);
}

/* stylelint-disable-next-line no-descending-specificity */
.v2-scroll-to-top svg {
cogniSyb marked this conversation as resolved.
Show resolved Hide resolved
transform: rotate(-90deg);
height: 24px;
width: 24px;
}

@media (min-width: 1200px) {
Expand Down
7 changes: 4 additions & 3 deletions blocks/v2-footer/v2-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ function goToTopFunction() {
}

function addScrollToTopButton(mainEl) {
const scrollToTopButton = createElement('button', ['scroll-to-top', 'button'], { title: 'Go to the top of the page' });
const icon = createElement('i', ['fa', 'fa-angle-up']);
scrollToTopButton.appendChild(icon);
const scrollToTopButton = createElement('button', ['v2-scroll-to-top'], { title: 'Go to the top of the page' });
const svgIcon = document.createRange().createContextualFragment(`
<svg xmlns="http://www.w3.org/2000/svg"><use href="#icons-sprite-arrow-right"></use></svg>`);
scrollToTopButton.append(...svgIcon.children);
cogniSyb marked this conversation as resolved.
Show resolved Hide resolved

scrollToTopButton.addEventListener('click', goToTopFunction);
window.addEventListener('scroll', () => displayScrollToTop(scrollToTopButton));
Expand Down