Okay, let's adjust the approach to make the orbs glow and move randomly, creating an "electric circuit" feel, and remove the glowing effect from the main wire background.
This involves:
- Creating multiple orb elements.
- Styling the orbs (size, shape, color, glow using
box-shadow).
- Using CSS animations for movement and potentially a pulsing glow.
- Using JavaScript within the Vue component to manage the number of orbs, their initial random positions, and potentially random animation delays/durations to make their movement look less synchronized.
Here's the updated code:
<template>
<div class="relative min-h-screen w-full overflow-hidden">
<!-- Base background -->
<div class="bg-background absolute top-0 -z-20 h-full w-full" />
<!-- Wire background (no animation needed here anymore) -->
<!-- Ensure the .wire-bg CSS rule somewhere actually sets the background image/color -->
<div class="wire-bg absolute top-0 -z-10 h-full w-full" />
<!-- Floating orbs overlay -->
<div class="floating-orbs absolute top-0 h-full w-full pointer-events-none">
<!-- v-for to create multiple orb elements -->
<span
v-for="orb in numOrbs"
:key="orb"
class="orb"
:style="getOrbStyle(orb)"
></span>
</div>
<slot />
</div>
<common-custom-scrollbar />
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
// --- Configuration ---
const numOrbs = 40; // Number of orbs
const minOrbSize = 5; // Minimum size in pixels
const maxOrbSize = 10; // Maximum size in pixels
const minAnimDuration = 10; // Minimum animation duration in seconds
const maxAnimDuration = 25; // Maximum animation duration in seconds
const minAnimDelay = 0; // Minimum animation delay in seconds
const maxAnimDelay = 10; // Maximum animation delay in seconds
// --- Reactive State (Not strictly needed if styles are generated once on setup) ---
// const orbs = ref<Array<{}>>([]); // If you needed to store orb data
// --- Methods / Computed Properties ---
// Function to generate unique style for each orb
const getOrbStyle = (index: number) => {
const size = Math.random() * (maxOrbSize - minOrbSize) + minOrbSize;
const duration = Math.random() * (maxAnimDuration - minAnimDuration) + minAnimDuration;
const delay = Math.random() * (maxAnimDelay - minAnimDelay) + minAnimDelay;
// Initial random position within the container (using percentages)
const initialLeft = Math.random() * 100;
const initialTop = Math.random() * 100;
return {
width: `${size}px`,
height: `${size}px`,
left: `${initialLeft}%`,
top: `${initialTop}%`,
animationDelay: `${delay}s`,
animationDuration: `${duration}s`,
// You could potentially vary color here too
// backgroundColor: `hsl(${Math.random() * 360}, 100%, 60%)`,
};
};
// --- Lifecycle Hooks ---
onMounted(() => {
// We could add logic here if needed, but getOrbStyle
// already sets initial positions and animation properties
// directly when the spans are rendered via v-for.
});
</script>
<style scoped>
/* No @keyframes hueShift anymore */
/* Style for the container holding the orbs */
.floating-orbs {
/* position: absolute, top: 0, height: 100%, width: 100% handled in template */
pointer-events: none; /* Allows clicks/interactions to pass through */
overflow: hidden; /* Ensures orbs are clipped if they move outside */
/* Add perspective if you use 3D transforms for movement */
/* perspective: 1000px; */
}
/* Style for individual orb elements */
.orb {
display: block;
position: absolute; /* Position relative to the .floating-orbs container */
border-radius: 50%; /* Make them round */
background-color: #0ff; /* Electric blue color */
/* You can experiment with colors like #00ffff, #39ff14 (neon green), #ff00ff (magenta) */
/* Glow effect using box-shadow */
box-shadow: 0 0 5px 1px #0ff, /* Inner tight glow */
0 0 15px 4px #0ff, /* Medium glow */
0 0 25px 7px #0ff; /* Outer wide glow */
/* Adjust blur and spread values (last two numbers) for the glow intensity */
/* Initial position, size, duration, and delay are set via inline style from getOrbStyle */
/* Apply animation for movement */
/* We use two animations: one for movement, one for a subtle pulse/flicker (optional) */
animation: moveCircuit linear infinite,
pulseGlow 2s ease-in-out infinite alternate; /* Pulse animation duration and timing */
/* Ensure hardware acceleration */
transform: translate3d(0, 0, 0);
will-change: transform, opacity; /* Indicate properties that will change */
}
/* Keyframes for the movement (define a complex, non-linear path) */
/* This is one sample path; you could define multiple or use JS for true randomness */
@keyframes moveCircuit {
0% {
transform: translate(0, 0);
opacity: 0.7; /* Start somewhat transparent */
}
10% {
transform: translate(10vw, 5vh);
opacity: 0.8;
}
20% {
transform: translate(30vw, 15vh);
opacity: 0.7;
}
30% {
transform: translate(20vw, 35vh);
opacity: 0.9;
}
40% {
transform: translate(50vw, 40vh);
opacity: 0.8;
}
50% {
transform: translate(70vw, 20vh);
opacity: 0.7;
}
60% {
transform: translate(85vw, 55vh);
opacity: 0.95; /* Brighter moment */
}
70% {
transform: translate(60vw, 70vh);
opacity: 0.8;
}
80% {
transform: translate(30vw, 85vh);
opacity: 0.7;
}
90% {
transform: translate(10vw, 60vh);
opacity: 0.85;
}
100% {
transform: translate(0, 0); /* Return to start (relative translate) */
opacity: 0.7;
}
}
/* Keyframes for a subtle pulsing/flickering glow effect */
@keyframes pulseGlow {
0%, 100% {
box-shadow: 0 0 5px 1px #0ff, 0 0 15px 4px #0ff, 0 0 25px 7px #0ff;
opacity: 0.7; /* Match opacity with movement keyframes or remove here */
}
50% {
box-shadow: 0 0 8px 2px #0ff, 0 0 20px 6px #0ff, 0 0 35px 10px #0ff;
opacity: 1; /* Brighter/more opaque at pulse peak */
}
}
/* Ensure wire-bg exists and has content */
/* .wire-bg { ... your background image/color styles ... } */
</style>