Skip to content

Commit e4c33fe

Browse files
committed
docs: adds hero animation
1 parent b53536a commit e4c33fe

File tree

1 file changed

+125
-4
lines changed

1 file changed

+125
-4
lines changed

packages/docs/pages/index.vue

Lines changed: 125 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
<template>
22
<div class="min-h-screen">
33
<!-- Hero Section with enhanced design -->
4-
<section class="relative py-20 overflow-hidden hero-bg">
5-
<div class="absolute inset-0 noise-bg opacity-50"></div>
4+
<section class="relative py-20 overflow-hidden">
5+
<!-- Background falling blocks animation -->
6+
<div class="absolute inset-0 z-0 pointer-events-none overflow-hidden">
7+
<div class="falling-blocks-container">
8+
<div
9+
v-for="i in 20"
10+
:key="i"
11+
class="falling-block"
12+
:style="generateBlockStyle()"
13+
></div>
14+
<!-- JSON symbol blocks -->
15+
<div
16+
v-for="i in 10"
17+
:key="`json-${i}`"
18+
class="falling-json-symbol"
19+
:style="generateJsonSymbolStyle()"
20+
>
21+
{{ getRandomJsonSymbol() }}
22+
</div>
23+
</div>
24+
</div>
625
<div class="container mx-auto px-4 relative z-10">
726
<div class="max-w-4xl mx-auto text-center mb-12">
827
<!-- Title with enhanced animation -->
@@ -51,7 +70,7 @@
5170
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
5271
/>
5372
</svg>
54-
GitHub
73+
Star on GitHub
5574
<span
5675
class="ml-1 transition-transform group-hover:translate-x-1"
5776
>→</span
@@ -673,10 +692,73 @@ for await (const [value, path] of jsonPathReader(reader, [
673692
</template>
674693

675694
<script setup>
676-
import { onMounted } from "vue"
695+
import { onMounted, ref } from "vue"
677696
import Logo from "../components/Logo.vue"
678697
import CodeBlock from "../components/CodeBlock.vue"
679698
699+
// Function to get a random JSON symbol
700+
const getRandomJsonSymbol = () => {
701+
const symbols = ["{", "}", "[", "]", ":", ",", '"', "."]
702+
return symbols[Math.floor(Math.random() * symbols.length)]
703+
}
704+
705+
// Function to generate styles for JSON symbol blocks
706+
const generateJsonSymbolStyle = () => {
707+
const left = Math.floor(Math.random() * 100) // Position across the screen
708+
const delay = Math.random() * 5 // Random delay
709+
const duration = Math.random() * 15 + 15 // Animation duration between 15-30s
710+
const size = Math.floor(Math.random() * 20) + 20 // Size between 20px and 40px
711+
const opacity = Math.random() * 0.1 + 0.05 // Low opacity between 0.05-0.15
712+
713+
return {
714+
left: `${left}%`,
715+
animationDelay: `${delay}s`,
716+
animationDuration: `${duration}s`,
717+
opacity: opacity,
718+
fontSize: `${size}px`,
719+
transform: `rotate(${Math.floor(Math.random() * 20 - 10)}deg)`, // Slight rotation
720+
}
721+
}
722+
723+
// Function to generate random styles for falling blocks
724+
const generateBlockStyle = () => {
725+
const size = Math.floor(Math.random() * 40) + 10 // Size between 10px and 50px
726+
const left = Math.floor(Math.random() * 100) // Position across the screen
727+
const delay = Math.random() * 5 // Random delay
728+
const duration = Math.random() * 10 + 10 // Animation duration between 10-20s
729+
const opacity = Math.random() * 0.08 + 0.02 // Low opacity between 0.02-0.1
730+
731+
// Choose random shape type
732+
const shapeTypes = ["square", "rectangle", "circle", "diamond"]
733+
const shapeType = shapeTypes[Math.floor(Math.random() * shapeTypes.length)]
734+
735+
// Base styles
736+
const styles = {
737+
width: `${size}px`,
738+
height: `${size}px`,
739+
left: `${left}%`,
740+
animationDelay: `${delay}s`,
741+
animationDuration: `${duration}s`,
742+
opacity: opacity,
743+
transform: `rotate(${Math.floor(Math.random() * 360)}deg)`,
744+
}
745+
746+
// Apply shape-specific styles
747+
if (shapeType === "rectangle") {
748+
styles.width = `${size * 1.5}px`
749+
styles.height = `${size * 0.7}px`
750+
} else if (shapeType === "circle") {
751+
styles.borderRadius = "50%"
752+
} else if (shapeType === "diamond") {
753+
styles.transform += " rotate(45deg)"
754+
}
755+
756+
// Add subtle shadow
757+
styles.boxShadow = "0 0 8px rgba(0, 122, 255, 0.1)"
758+
759+
return styles
760+
}
761+
680762
// Create a grid pattern background effect for code blocks
681763
const createBackgroundGridPattern = () => {
682764
if (process.client) {
@@ -871,4 +953,43 @@ onMounted(() => {
871953
color: var(--color-text-secondary);
872954
line-height: 1.4;
873955
}
956+
957+
/* Falling Blocks Animation */
958+
.falling-blocks-container {
959+
position: absolute;
960+
top: 0;
961+
left: 0;
962+
width: 100%;
963+
height: 100%;
964+
overflow: hidden;
965+
}
966+
967+
.falling-block {
968+
position: absolute;
969+
top: -60px;
970+
background-color: var(--color-accent, #3b82f6);
971+
border-radius: 4px;
972+
animation: fall linear infinite;
973+
z-index: 0;
974+
}
975+
976+
.falling-json-symbol {
977+
position: absolute;
978+
top: -60px;
979+
color: var(--color-accent, #3b82f6);
980+
font-family: monospace;
981+
font-weight: bold;
982+
animation: fall linear infinite;
983+
z-index: 0;
984+
text-shadow: 0 0 5px rgba(59, 130, 246, 0.15);
985+
}
986+
987+
@keyframes fall {
988+
0% {
989+
transform: translateY(-100px) rotate(0deg);
990+
}
991+
100% {
992+
transform: translateY(100vh) rotate(360deg);
993+
}
994+
}
874995
</style>

0 commit comments

Comments
 (0)