dess / index.html
stay-toxicx's picture
clicking the card again makes everything normal and deselects it - Initial Deployment
f79db03 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Expandable Card Gallery</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.card {
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
will-change: transform, width, height;
}
.thumbnail {
transition: all 0.3s ease;
}
.thumbnail:hover {
transform: translateY(-5px) scale(1.03);
box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.15);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.expanded-card {
z-index: 50;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
.content-editable:focus {
outline: none;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen">
<!-- Login Modal -->
<div id="loginModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white p-8 rounded-lg w-96">
<h2 class="text-2xl font-bold mb-6 text-center">Login</h2>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Username</label>
<input type="text" id="username" class="w-full px-3 py-2 border rounded">
</div>
<div class="mb-6">
<label class="block text-gray-700 mb-2">Password</label>
<input type="password" id="password" class="w-full px-3 py-2 border rounded">
</div>
<button onclick="handleLogin()" class="w-full bg-blue-600 text-white py-2 rounded hover:bg-blue-700">Login</button>
</div>
</div>
<div class="container mx-auto px-4 py-12" id="mainContent" style="display: none;">
<div class="flex justify-center items-center gap-4 mb-2">
<h1 class="text-4xl font-bold text-gray-800">Interactive Card Gallery</h1>
<button id="logoutBtn" class="hidden bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-full shadow-lg transition-all">
<i class="fas fa-sign-out-alt mr-2"></i> Logout
</button>
</div>
<p class="text-center text-gray-600 mb-12">Click on any card to expand it. Double-click text or image to edit.</p>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6" id="gallery">
<!-- Cards will be added here by JavaScript -->
</div>
<div class="mt-8 text-center">
<button id="seeMoreBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-full shadow-lg transition-all mb-4">
<i class="fas fa-eye mr-2"></i> See More
</button>
<button id="addCardBtn" class="bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded-full shadow-lg transition-all hidden">
<i class="fas fa-plus mr-2"></i> Add New Card
</button>
</div>
</div>
<script>
let currentUser = null;
let showAllCards = false;
// Sample users (in real app, this would be server-side)
const users = [
{ username: 'admin', password: 'admin123', role: 'admin' },
{ username: 'user', password: 'user123', role: 'normal' }
];
function handleLogin() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const user = users.find(u => u.username === username && u.password === password);
if (user) {
currentUser = user;
document.getElementById('loginModal').style.display = 'none';
document.getElementById('mainContent').style.display = 'block';
if (user.role === 'admin') {
document.getElementById('addCardBtn').classList.remove('hidden');
}
document.getElementById('logoutBtn').classList.remove('hidden');
renderGallery();
} else {
alert('Invalid credentials');
}
}
function handleLogout() {
currentUser = null;
showAllCards = false;
document.getElementById('mainContent').style.display = 'none';
document.getElementById('loginModal').style.display = 'flex';
document.getElementById('addCardBtn').classList.add('hidden');
document.getElementById('logoutBtn').classList.add('hidden');
document.getElementById('seeMoreBtn').style.display = 'block';
}
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('logoutBtn').addEventListener('click', handleLogout);
const gallery = document.getElementById('gallery');
const addCardBtn = document.getElementById('addCardBtn');
const seeMoreBtn = document.getElementById('seeMoreBtn');
let expandedCardId = null;
let cards = [];
// Sample initial data
const initialData = [
{
id: 1,
title: "Mountain View",
description: "Beautiful mountain landscape with snow peaks and green valleys. Perfect for hiking and nature photography.",
imageUrl: "https://images.unsplash.com/photo-1454496522488-7a8e488e8606?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
},
{
id: 2,
title: "Ocean Sunset",
description: "Stunning sunset over the ocean with vibrant colors reflecting on the water. A peaceful moment to cherish.",
imageUrl: "https://images.unsplash.com/photo-1519046904884-53103b34b206?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
},
{
id: 3,
title: "City Lights",
description: "Urban cityscape at night with illuminated skyscrapers and busy streets. The energy of modern life.Urban cityscape at night with illuminated skyscrapers and busy streets. The energy of modern life.",
imageUrl: "https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
},
{
id: 4,
title: "Forest Path",
description: "Mystical forest path surrounded by tall trees and sunlight filtering through the leaves. A walk to remember.",
imageUrl: "https://images.unsplash.com/photo-1448375240586-882707db888b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
},
{
id: 5,
title: "Desert Dunes",
description: "Endless sand dunes under a clear blue sky. The silence and vastness of the desert landscape.",
imageUrl: "https://images.unsplash.com/photo-1509316785289-025f5b846b35?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
},
{
id: 6,
title: "Waterfall",
description: "Majestic waterfall cascading down rocky cliffs surrounded by lush vegetation. The power of nature.",
imageUrl: "https://images.unsplash.com/photo-1511497584788-876760111969?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
}
];
// Initialize gallery with sample data
cards = [...initialData];
renderGallery();
// Add new card
seeMoreBtn.addEventListener('click', function() {
showAllCards = true;
renderGallery();
this.style.display = 'none';
});
addCardBtn.addEventListener('click', function() {
if (currentUser?.role !== 'admin') {
alert('Only admins can add cards');
return;
}
const newId = cards.length > 0 ? Math.max(...cards.map(card => card.id)) + 1 : 1;
const newCard = {
id: newId,
title: "New Card",
description: "Double-click to edit this text. Add your own content here.",
imageUrl: "https://images.unsplash.com/photo-1506744038136-46273834b3fb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80"
};
cards.push(newCard);
renderGallery();
// Auto-expand the new card
setTimeout(() => {
expandCard(newId);
}, 100);
});
// Render gallery function
function renderGallery() {
gallery.innerHTML = '';
const cardsToShow = showAllCards ? cards : cards.slice(0, 6);
cardsToShow.forEach(card => {
const isExpanded = expandedCardId === card.id;
const cardElement = document.createElement('div');
cardElement.className = `card relative rounded-xl overflow-hidden ${isExpanded ? 'expanded-card fixed inset-0 m-auto w-11/12 h-5/6 bg-white' : 'thumbnail bg-white shadow-md cursor-pointer h-80'}`;
cardElement.dataset.id = card.id;
cardElement.innerHTML = `
<div class="h-full flex flex-col">
<div class="relative h-2/3 overflow-hidden">
<img src="${card.imageUrl}"
alt="${card.title}"
class="w-full h-full object-cover content-editable"
data-field="imageUrl"
ondblclick="makeEditable(this)"
data-id="${card.id}">
</div>
<div class="p-4 flex-1 flex flex-col">
<h3 class="text-xl font-semibold mb-2 content-editable"
data-field="title"
ondblclick="makeEditable(this)"
data-id="${card.id}">${card.title}</h3>
<p class="text-gray-600 flex-1 content-editable"
data-field="description"
ondblclick="makeEditable(this)"
data-id="${card.id}">${card.description}</p>
${isExpanded ? `
<div class="mt-4 flex justify-between">
<button class="bg-gray-500 hover:bg-gray-600 text-white px-4 py-2 rounded-full" onclick="event.stopPropagation(); collapseCard(${card.id})">
<i class="fas fa-times mr-2"></i> Close
</button>
<button class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-full" onclick="event.stopPropagation(); deleteCard(${card.id})">
<i class="fas fa-trash mr-2"></i> Delete
</button>
</div>
` : ''}
</div>
</div>
`;
if (!isExpanded) {
cardElement.addEventListener('click', function() {
if (expandedCardId === card.id) {
collapseCard(card.id);
} else {
expandCard(card.id);
}
});
}
gallery.appendChild(cardElement);
});
}
// Expand/collapse card functions
function expandCard(id) {
expandedCardId = id;
renderGallery();
// Add click event to close when clicking outside
if (id) {
setTimeout(() => {
const expandedElement = document.querySelector(`.expanded-card[data-id="${id}"]`);
if (expandedElement) {
expandedElement.addEventListener('click', function(e) {
if (e.target === this) {
collapseCard(id);
}
});
}
}, 50);
}
}
function collapseCard(id) {
expandedCardId = null;
renderGallery();
}
// Expose collapseCard to global scope
window.collapseCard = collapseCard;
// Make elements editable (exposed to global scope)
window.makeEditable = function(element) {
const id = parseInt(element.dataset.id);
const field = element.dataset.field;
element.contentEditable = true;
element.focus();
element.addEventListener('blur', function() {
element.contentEditable = false;
// Update the card data
const cardIndex = cards.findIndex(card => card.id === id);
if (cardIndex !== -1) {
cards[cardIndex][field] = element.textContent;
}
});
element.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
element.blur();
}
});
};
// Change image function (exposed to global scope)
window.changeImage = function(id) {
event.stopPropagation();
const newUrl = prompt("Enter new image URL:");
if (newUrl) {
const cardIndex = cards.findIndex(card => card.id === id);
if (cardIndex !== -1) {
cards[cardIndex].imageUrl = newUrl;
renderGallery();
}
}
};
// Delete card function (exposed to global scope)
window.deleteCard = function(id) {
if (currentUser?.role !== 'admin') {
alert('Only admins can delete cards');
return;
}
event.stopPropagation();
if (confirm("Are you sure you want to delete this card?")) {
cards = cards.filter(card => card.id !== id);
if (expandedCardId === id) {
expandedCardId = null;
}
renderGallery();
}
};
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=stay-toxicx/dess" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>