5 changed files with 165 additions and 4 deletions

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
---
/**
* Meatballs.astro
* This component creates meatballs that are appended to the galaxy on interval.
* Meatballs are removed from the document after the animation is completed.
* There are four (4) meatball shower containers, one for each diagonal direction.
*/
---
<div id="meatballs">
<!-- rotations defined in base.css & tailwind.config.mjs -->
<div class="shower ur" />
<div class="shower dr" />
<div class="shower dl" />
<div class="shower ul" />
</div>
<script>
function createMeatball () {
// create a meatball
let meatball = document.createElement("div");
meatball.setAttribute("class", "meatball");
meatball.style.left = Math.round(Math.random() * window.innerWidth) + "px";
meatball.style.top = Math.round(Math.random() * window.innerHeight) + "px";
// append the meatball to a random meatball shower (direction)
const showers = document.querySelectorAll(".shower");
if (showers.length > 0) {
const random = Math.floor(Math.random() * showers.length);
const shower = showers[random];
shower.append(meatball);
}
// remove the meatball after the animation duration
setTimeout(() => {
meatball.remove();
}, 3500);
}
// Create meatballs on interval on two (2) seconds
setInterval(createMeatball, 1500);
</script>
+61
View File
@@ -0,0 +1,61 @@
---
/**
* NoodleTwinklingStars.astro
* This component creates twinkling noodles that are appended to the galaxy on interval.
* Twinkling noodles are removed from the document after the animation is completed.
* The svg below is just a template for the script to clone and append to the galaxy.
*/
---
<svg
id="noodle"
class="template"
width="149"
height="149"
viewBox="0 0 149 149"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="absolute left-full animate-twinkle"
>
<circle cx="74" cy="74" r="11" fill="#FF6B6B"/>
<rect y="141.421" width="200" height="10" transform="rotate(-45 0 141.421)" fill="url(#paint0_linear_4_2)"/>
<rect x="7.07107" width="200" height="10" transform="rotate(45 7.07107 0)" fill="url(#paint1_linear_4_2)"/>
<defs>
<linearGradient id="paint0_linear_4_2" x1="0" y1="146.421" x2="200" y2="146.421" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6B6B"/>
<stop offset="0.445" stop-color="white"/>
<stop offset="0.58721" stop-color="white"/>
<stop offset="1" stop-color="#FF6B6B"/>
</linearGradient>
<linearGradient id="paint1_linear_4_2" x1="7.07107" y1="5" x2="207.071" y2="5" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6B6B"/>
<stop offset="0.42" stop-color="white"/>
<stop offset="0.555" stop-color="white"/>
<stop offset="1" stop-color="#FF6B6B"/>
</linearGradient>
</defs>
</svg>
<script is:inline>
// Generate a twinkling noodle and append it to the galaxy, remove it after animation.
function generateNoodle() {
const noodleTemplate = document.getElementById("noodle")
if (!noodleTemplate) { return; }
// Clone the noodle template and set its attributes.
const noodle = noodleTemplate.cloneNode(true);
noodle.style.position = "absolute";
noodle.style.left = Math.floor(Math.random() * window.innerWidth) + "px";
noodle.style.top = Math.floor(Math.random() * (window.innerHeight/3)) + "px";
noodle.style.width = window.innerWidth < 768 ? Math.floor(Math.random() * (15 - 7.5 + 1) + 7.5) : Math.floor(Math.random() * (30 - 15 + 1) + 15) + "px";
noodle.style.height = noodle.style.width;
noodle.classList.add("twinkle");
document.getElementById("galaxy").appendChild(noodle);
// Remove the twinkling noodle after the animation is completed.
setTimeout(() => {
noodle.remove();
}, 2500);
}
setInterval(generateNoodle, 5000);
</script>
+4 -4
View File
@@ -4,8 +4,8 @@ import PageLayout from "@layouts/PageLayout.astro"
import ArrowCard from "@components/ArrowCard"
import StackCard from "@components/StackCard.astro"
import { SITE, SOCIALS } from "@consts"
import TwinklingStars from "@components/TwinklingStars.astro"
import MeteorShower from "@components/MeteorShower.astro"
import NoodleTwinklingStars from "@components/NoodleTwinklingStars.astro"
import MeatballShower from "@components/MeatballShower.astro"
// Fetch blog posts and projects from Appwrite
const posts = (await getBlogPosts())
@@ -66,8 +66,8 @@ const stack = [
<!-- Dark Theme: Twinkling Stars / Meteor Shower -->
<div id="galaxy" class="fixed inset-0">
<div class="hidden dark:block">
<TwinklingStars/>
<MeteorShower/>
<NoodleTwinklingStars/>
<MeatballShower/>
</div>
</div>
+44
View File
@@ -280,6 +280,50 @@ article img {
@apply rotate-315;
}
/**
* TWINKLE NOODLES
*/
#noodle.template {
@apply absolute -left-full; /* hide offscreen */
}
#noodle.twinkle {
@apply animate-twinkle; /* defined in tailwind.config */
}
/**
* Meatballs
*/
#meatballs .shower {
@apply absolute inset-0 top-0;;
@apply left-1/2 -translate-x-1/2;
@apply w-screen aspect-square;
}
#meatballs .meatball {
@apply animate-meatball; /* defined in tailwind.config */
@apply absolute top-1/2 left-1/2 w-px h-[75vh];
@apply bg-gradient-to-b from-white to-transparent;
}
#meatballs .shower.ur {
@apply rotate-45;
}
#meatballs .shower.dr {
@apply rotate-135;
}
#meatballs .shower.dl {
@apply rotate-225;
}
#meatballs .shower.ul {
@apply rotate-315;
}
.copy-cnt{
@apply absolute w-full;
top:var(--copy-btn-margin);
+14
View File
@@ -61,6 +61,7 @@ export default {
animation: {
twinkle: "twinkle 2s ease-in-out forwards",
meteor: "meteor 3s ease-in-out forwards",
meatball: "meatball 3s ease-in-out forwards",
},
keyframes: {
twinkle: {
@@ -90,6 +91,19 @@ export default {
transform: "translateY(0)"
},
},
meatball: {
"0%": {
opacity: 0,
transform: "translateY(200%)"
},
"50%": {
opacity: 1
},
"100%": {
opacity: 0,
transform: "translateY(0)"
},
},
},
colors: {
spaghetti: {