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

Added ScrollToTop button #262

Merged
merged 4 commits into from
Jul 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
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/assets/arrowUp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/components/ScrollToTop.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
import { Icon } from "astro-icon";
import { Picture } from "@astrojs/image/components";
import arrowUp from "assets/arrowUp.svg";
---

<main>
<div id="scroll" class="text-4xl fixed bottom-6 right-5 z-10 cursor-pointer text-black bg-gradient-to-r from-[#e8ebf1] to-[#cad0db] px-1 py-2.5 rounded-full transition-all delay-300 ease-in-out hover:scale-110" onclick=`handleScroll()`>
<Picture
src={arrowUp}
alt="Arrow"
widths={[100, 100, 100]}
aspectRatio="4:3"
sizes="(max-width: 10px) 19vw, 40px"
loading="eager"
format="avif"
/>
</div>
</main>
<script>
const scroll = document.getElementById("scroll");

scroll.addEventListener('click', function(e) {
window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
})
</script>
2 changes: 2 additions & 0 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Hero from "@components/hero.astro";
import Logos from "@components/logos.astro";
import Layout from "@layouts/Layout.astro";
import Newsletter from "@components/newsletter.astro";
import ScrollToTop from "@components/ScrollToTop.astro";
---

<Layout title="">
Expand All @@ -16,5 +17,6 @@ import Newsletter from "@components/newsletter.astro";
<Logos />
<Cta />
<Newsletter />
<ScrollToTop/>
</Container>
</Layout>