Skip to content

Commit

Permalink
feat: view transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
williamsjokvist committed Jan 3, 2024
1 parent ea10e39 commit 204748a
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/components/DownloadButton.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Icon from "astro-icon"
---

<script defer>
<script>
function removeNonUserAgentDownloads() {
const isWindows = window.navigator.userAgent.indexOf("Win") != -1
const isMacOS = window.navigator.userAgent.indexOf("Mac") != -1
Expand All @@ -18,7 +18,7 @@ import Icon from "astro-icon"
}
}

document.addEventListener("DOMContentLoaded", removeNonUserAgentDownloads)
document.addEventListener("astro:page-load", removeNonUserAgentDownloads)
</script>

<a
Expand Down
6 changes: 3 additions & 3 deletions src/components/SiteFooter.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
---

<script defer>
<script>
const fetchDownloadCount = async () => {
const res = await fetch(
`https://api.github.com/repos/williamsjokvist/cfn-tracker/releases`,
Expand All @@ -28,10 +28,10 @@
const assignDownloadCount = async () => {
const download_count = await fetchDownloadCount();
const cfnTrackerEl = document.getElementById(`cfn-tracker-download-count`);
cfnTrackerEl.innerText = download_count;
cfnTrackerEl.innerText = download_count.toString();
}

document.addEventListener("DOMContentLoaded", assignDownloadCount);
document.addEventListener("astro:page-load", assignDownloadCount);
</script>

<footer class="py-36 text-xl lowercase text-center">
Expand Down
55 changes: 29 additions & 26 deletions src/components/Streamers.astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,36 @@ const streamers = [{

<script>
import { gsap, Power2 } from "../lib/gsap";
gsap.from("#used-by > h2", {
autoAlpha: 0,
translateY: 20,
duration: 3.25,
ease: Power2.easeInOut,
stagger: 0.25,
scrollTrigger: {
scroller: "main",
trigger: "#used-by h2",
start: "center bottom",
toggleActions: "play none none reverse",
},
});

gsap.from("#used-by-list > *", {
autoAlpha: 0,
translateY: 20,
duration: 3,
ease: Power2.easeInOut,
stagger: 0.25,
scrollTrigger: {
scroller: document.body,
trigger: "#used-by h2",
start: "center bottom",
toggleActions: "play none none reverse",
},
});
document.addEventListener("astro:page-load", () => {
gsap.from("#used-by > h2", {
autoAlpha: 0,
translateY: 20,
duration: 3.25,
ease: Power2.easeInOut,
stagger: 0.25,
scrollTrigger: {
scroller: "main",
trigger: "#used-by h2",
start: "center bottom",
toggleActions: "play none none reverse",
},
});

gsap.from("#used-by-list > *", {
autoAlpha: 0,
translateY: 20,
duration: 3,
ease: Power2.easeInOut,
stagger: 0.25,
scrollTrigger: {
scroller: document.body,
trigger: "#used-by h2",
start: "center bottom",
toggleActions: "play none none reverse",
},
});
})
</script>

<section id="used-by" class="my-28">
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import { ViewTransitions } from 'astro:transitions';
import NavBar from '../components/NavBar.astro';
import SiteFooter from '../components/SiteFooter.astro';
export interface Props {
Expand All @@ -17,7 +18,7 @@ const { title } = Astro.props;
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;800&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=League+Spartan:wght@200;300;600&display=swap" rel="stylesheet">

<ViewTransitions />
<meta name="generator" content={Astro.generator} />
<title>CFN Tracker</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
Expand Down
17 changes: 10 additions & 7 deletions src/pages/changelog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import Layout from '../layouts/Layout.astro';
---
<script>
import { gsap, Power2 } from "../lib/gsap";
gsap.from("#changelog > *", {
autoAlpha: 0,
translateY: 20,
duration: .75,
ease: Power2.easeInOut,
stagger: 0.125,
});

document.addEventListener("astro:page-load", () => {
gsap.from("#changelog > *", {
autoAlpha: 0,
translateY: 20,
duration: .75,
ease: Power2.easeInOut,
stagger: 0.125,
});
})
</script>

<Layout title="CFN Tracker - Changelog">
Expand Down
16 changes: 9 additions & 7 deletions src/pages/faq.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import Layout from '../layouts/Layout.astro';
---
<script>
import { gsap, Power3 } from "../lib/gsap";
gsap.from("#faq > *", {
autoAlpha: 0,
translateY: 20,
duration: .75,
ease: Power3.easeInOut,
stagger: 0.125,
});
document.addEventListener("astro:page-load", () => {
gsap.from("#faq > *", {
autoAlpha: 0,
translateY: 20,
duration: .75,
ease: Power3.easeInOut,
stagger: 0.125,
});
})
</script>

<Layout title="CFN Tracker - FAQ">
Expand Down
16 changes: 9 additions & 7 deletions src/pages/guide.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import Layout from '../layouts/Layout.astro';
---
<script>
import { gsap, Power3 } from "../lib/gsap";
gsap.from("#guide > *", {
autoAlpha: 0,
translateY: 20,
duration: .75,
ease: Power3.easeInOut,
stagger: 0.125,
});
document.addEventListener("astro:page-load", () => {
gsap.from("#guide > *", {
autoAlpha: 0,
translateY: 20,
duration: .75,
ease: Power3.easeInOut,
stagger: 0.125,
});
})
</script>

<Layout title="CFN Tracker - Guide">
Expand Down

0 comments on commit 204748a

Please sign in to comment.