Spaces:
Running

undefined / index.html
moo00oon's picture
Redesign the page as a dreamlike, digital nebula with only floating bubbles (no platforms or elongated ovals).
f116c5b verified
Raw History Blame Contribute Delete
17.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dream Nebula</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@200;400&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Outfit', sans-serif;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-15px); }
}
.bubble {
position: absolute;
border-radius: 50%;
background: radial-gradient(
circle at 30% 30%,
rgba(255,255,255,0.8) 0%,
transparent 70%
);
backdrop-filter: blur(2px);
transition: transform 0.3s ease, filter 0.3s ease;
will-change: transform;
filter: saturate(1.2);
box-shadow:
inset 0 0 15px rgba(255,255,255,0.2),
inset 10px 0 20px rgba(180,100,255,0.2),
inset -10px 0 20px rgba(100,200,255,0.2);
border: 1px solid rgba(255,255,255,0.15);
animation: float 6s ease-in-out infinite;
}
.bubble::before {
content: '';
position: absolute;
top: 10%;
left: 20%;
width: 40%;
height: 40%;
border-radius: 50%;
background: linear-gradient(45deg,
rgba(255,100,255,0.3),
rgba(100,200,255,0.3),
rgba(100,255,200,0.3));
filter: blur(10px);
z-index: -1;
}
.bubble:hover {
transform: scale(1.1);
filter: brightness(1.1) saturate(1.5);
box-shadow:
inset 0 0 20px rgba(255,255,255,0.3),
inset 15px 0 30px rgba(180,100,255,0.3),
inset -15px 0 30px rgba(100,200,255,0.3);
}
.bubble-expanded {
animation: none;
transform: scale(1.8) !important;
z-index: 100;
backdrop-filter: blur(10px);
box-shadow:
inset 0 0 30px rgba(255,255,255,0.4),
inset 20px 0 40px rgba(180,100,255,0.4),
inset -20px 0 40px rgba(100,200,255,0.4);
}
.cosmic-bg {
background: radial-gradient(ellipse at center,
rgba(15,12,41,1) 0%,
rgba(48,43,99,0.8) 50%,
rgba(36,36,62,0.6) 100%);
position: relative;
overflow: hidden;
}
.cosmic-bg::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
radial-gradient(circle at 20% 30%, rgba(180,100,255,0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 70%, rgba(100,200,255,0.1) 0%, transparent 50%);
pointer-events: none;
}
.thought-content {
opacity: 0;
max-height: 0;
transition: all 0.4s ease-out;
overflow: hidden;
position: relative;
text-align: center;
color: white;
pointer-events: none;
}
.bubble-expanded .thought-content {
opacity: 1;
max-height: 200px;
padding: 15px;
pointer-events: auto;
}
.stellar-text {
font-weight: 200;
letter-spacing: 2px;
background: linear-gradient(90deg, #ffffff, #aad5ff);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: 0 0 15px rgba(170,213,255,0.3);
}
.star {
position: absolute;
background: white;
border-radius: 50%;
pointer-events: none;
}
</style>
</head>
<body class="cosmic-bg h-screen overflow-hidden relative">
<div id="stars-container" class="absolute inset-0 w-full h-full pointer-events-none"></div>
<header class="relative z-10 pt-12 pb-8 px-4 text-center">
<h1 class="text-5xl md:text-6xl font-light stellar-text">
DREAM NEBULA
</h1>
<p class="text-blue-100 mt-2 font-light tracking-wider text-sm md:text-base">FLOATING THOUGHT BUBBLES</p>
</header>
<button id="add-bubble-btn" class="fixed top-6 right-6 z-20 p-3 rounded-full bg-white/10 backdrop-blur-md text-white hover:bg-white/20 transition-all">
<i data-feather="plus" class="w-5 h-5"></i>
</button>
<main class="relative z-10 h-[calc(100vh-180px)]">
<div id="bubble-container" class="absolute inset-0"></div>
</main>
<!-- Add Bubble Modal -->
<div id="add-bubble-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm hidden">
<div class="bg-gradient-to-br from-white/10 to-white/5 rounded-xl p-6 max-w-md w-full mx-4 border border-white/10 backdrop-blur-lg">
<h3 class="text-xl font-light text-white mb-4">Add Thought Bubble</h3>
<textarea id="bubble-text" class="w-full p-3 bg-white/5 text-white rounded-lg border border-white/10 focus:outline-none focus:ring-1 focus:ring-white/30 placeholder-white/50" rows="4" placeholder="Your dreamlike thought..."></textarea>
<div class="flex justify-end space-x-3 mt-4">
<button id="cancel-bubble" class="px-4 py-2 text-white/70 hover:text-white">Cancel</button>
<button id="save-bubble" class="px-4 py-2 bg-white/10 hover:bg-white/20 text-white rounded-lg transition">Save</button>
</div>
</div>
</div>
<!-- Edit Bubble Modal -->
<div id="edit-bubble-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm hidden">
<div class="bg-gradient-to-br from-white/10 to-white/5 rounded-xl p-6 max-w-md w-full mx-4 border border-white/10 backdrop-blur-lg">
<h3 class="text-xl font-light text-white mb-4">Edit Bubble</h3>
<textarea id="edit-bubble-text" class="w-full p-3 bg-white/5 text-white rounded-lg border border-white/10 focus:outline-none focus:ring-1 focus:ring-white/30 placeholder-white/50" rows="4"></textarea>
<div class="flex justify-between mt-4">
<button id="delete-bubble" class="px-4 py-2 text-red-300 hover:text-red-400">Delete</button>
<div class="flex space-x-3">
<button id="cancel-edit" class="px-4 py-2 text-white/70 hover:text-white">Cancel</button>
<button id="save-edit" class="px-4 py-2 bg-white/10 hover:bg-white/20 text-white rounded-lg transition">Save</button>
</div>
</div>
</div>
</div>
<script>
// Generate random stars
function createStars() {
const container = document.getElementById('stars-container');
const starCount = Math.floor(window.innerWidth * window.innerHeight / 1000);
for (let i = 0; i < starCount; i++) {
const star = document.createElement('div');
star.className = 'star';
// Random position and size
const size = Math.random() * 2;
star.style.width = `${size}px`;
star.style.height = `${size}px`;
star.style.left = `${Math.random() * 100}%`;
star.style.top = `${Math.random() * 100}%`;
// Random opacity and animation
star.style.opacity = Math.random() * 0.8 + 0.2;
star.style.animation = `twinkle ${Math.random() * 5 + 5}s infinite alternate`;
container.appendChild(star);
}
}
// Initialize bubble functionality
document.addEventListener('DOMContentLoaded', function() {
createStars();
feather.replace();
// Initialize bubbles from localStorage or create default ones
loadBubbles();
// Modal functionality
const addBtn = document.getElementById('add-bubble-btn');
const addModal = document.getElementById('add-bubble-modal');
const cancelBtn = document.getElementById('cancel-bubble');
const saveBtn = document.getElementById('save-bubble');
addBtn.addEventListener('click', () => addModal.classList.remove('hidden'));
cancelBtn.addEventListener('click', () => {
document.getElementById('bubble-text').value = '';
addModal.classList.add('hidden');
});
saveBtn.addEventListener('click', () => {
const text = document.getElementById('bubble-text').value.trim();
if (text) {
createBubble(text);
document.getElementById('bubble-text').value = '';
addModal.classList.add('hidden');
}
});
// Edit modal functionality
const editModal = document.getElementById('edit-bubble-modal');
const cancelEditBtn = document.getElementById('cancel-edit');
const saveEditBtn = document.getElementById('save-edit');
const deleteBtn = document.getElementById('delete-bubble');
let currentBubbleId = null;
cancelEditBtn.addEventListener('click', () => {
document.getElementById('edit-bubble-text').value = '';
editModal.classList.add('hidden');
});
saveEditBtn.addEventListener('click', () => {
const text = document.getElementById('edit-bubble-text').value.trim();
if (text && currentBubbleId) {
updateBubble(currentBubbleId, text);
editModal.classList.add('hidden');
}
});
deleteBtn.addEventListener('click', () => {
if (currentBubbleId) {
deleteBubble(currentBubbleId);
editModal.classList.add('hidden');
}
});
});
// Bubble functions
function loadBubbles() {
let bubbles = localStorage.getItem('bubbles');
if (!bubbles) {
// Create default bubbles
bubbles = [
{
id: Date.now().toString(),
text: "We are all just fragments of stardust trying to remember where we came from.",
x: 20, y: 30, z: 0,
color: 'rgba(180,100,255,0.2)'
},
{
id: (Date.now() + 1).toString(),
text: "Time is just the universe's way of preventing everything from happening at once.",
x: 70, y: 20, z: 20,
color: 'rgba(100,200,255,0.2)'
},
{
id: (Date.now() + 2).toString(),
text: "The trees are poems the earth writes upon the sky.",
x: 30, y: 60, z: -20,
color: 'rgba(255,100,200,0.2)'
}
];
localStorage.setItem('bubbles', JSON.stringify(bubbles));
} else {
bubbles = JSON.parse(bubbles);
}
bubbles.forEach(bubble => createBubbleElement(bubble));
}
function createBubble(text) {
const bubble = {
id: Date.now().toString(),
text: text,
x: Math.random() * 80 + 10, // 10-90%
y: Math.random() * 80 + 10, // 10-90%
z: Math.random() * 40 - 20, // -20 to 20
color: `rgba(${Math.floor(Math.random() * 100 + 155)}, ${Math.floor(Math.random() * 100 + 100)}, 255, 0.2)`
};
// Save to localStorage
let bubbles = JSON.parse(localStorage.getItem('bubbles') || '[]');
bubbles.push(bubble);
localStorage.setItem('bubbles', JSON.stringify(bubbles));
createBubbleElement(bubble);
}
function createBubbleElement(bubble) {
const container = document.getElementById('bubble-container');
const bubbleEl = document.createElement('div');
const size = Math.random() * 60 + 40; // 40-100px
bubbleEl.className = 'bubble cursor-pointer';
bubbleEl.style.width = `${size}px`;
bubbleEl.style.height = `${size}px`;
bubbleEl.style.left = `${bubble.x}%`;
bubbleEl.style.top = `${bubble.y}%`;
bubbleEl.style.background = bubble.color;
bubbleEl.dataset.id = bubble.id;
// Set transform for z-depth parallax effect
bubbleEl.style.transform = `translateZ(${bubble.z}px)`;
// Create content div
const content = document.createElement('div');
content.className = 'thought-content';
content.textContent = bubble.text;
bubbleEl.appendChild(content);
// Add float animation with GSAP
gsap.to(bubbleEl, {
duration: 10 + Math.random() * 10,
y: `+=${(Math.random() * 30 - 15) * (1 + bubble.z/100)}`,
x: `+=${(Math.random() * 30 - 15) * (1 + bubble.z/100)}`,
ease: "sine.inOut",
repeat: -1,
yoyo: true
});
// Click handler
bubbleEl.addEventListener('click', function(e) {
e.stopPropagation();
// Close any expanded bubble
document.querySelectorAll('.bubble-expanded').forEach(el => {
if (el !== bubbleEl) el.classList.remove('bubble-expanded');
});
// Toggle current bubble
bubbleEl.classList.toggle('bubble-expanded');
// If expanded, open edit modal
if (bubbleEl.classList.contains('bubble-expanded')) {
currentBubbleId = bubble.id;
document.getElementById('edit-bubble-text').value = bubble.text;
editModal.classList.remove('hidden');
}
});
// Hover effect
bubbleEl.addEventListener('mouseenter', () => {
gsap.to(bubbleEl, {
duration: 0.3,
scale: 1.1,
ease: "power2.out"
});
});
bubbleEl.addEventListener('mouseleave', () => {
if (!bubbleEl.classList.contains('bubble-expanded')) {
gsap.to(bubbleEl, {
duration: 0.3,
scale: 1,
ease: "power2.out"
});
}
});
container.appendChild(bubbleEl);
}
function updateBubble(id, text) {
let bubbles = JSON.parse(localStorage.getItem('bubbles') || '[]');
const index = bubbles.findIndex(b => b.id === id);
if (index !== -1) {
bubbles[index].text = text;
localStorage.setItem('bubbles', JSON.stringify(bubbles));
// Update DOM
const bubbleEl = document.querySelector(`.bubble[data-id="${id}"]`);
if (bubbleEl) {
bubbleEl.querySelector('.thought-content').textContent = text;
}
}
}
function deleteBubble(id) {
let bubbles = JSON.parse(localStorage.getItem('bubbles') || '[]');
bubbles = bubbles.filter(b => b.id !== id);
localStorage.setItem('bubbles', JSON.stringify(bubbles));
// Remove from DOM
const bubbleEl = document.querySelector(`.bubble[data-id="${id}"]`);
if (bubbleEl) {
gsap.to(bubbleEl, {
duration: 0.3,
scale: 0,
opacity: 0,
onComplete: () => bubbleEl.remove()
});
}
}
// Close modals when clicking outside
document.addEventListener('click', function(e) {
if (!e.target.closest('#add-bubble-modal > div') && !e.target.closest('#add-bubble-btn')) {
document.getElementById('add-bubble-modal').classList.add('hidden');
}
if (!e.target.closest('#edit-bubble-modal > div')) {
document.getElementById('edit-bubble-modal').classList.add('hidden');
}
});
</script>
</body>
</html>