Spaces:
Running
Running
Update index.html
Browse files- index.html +159 -77
index.html
CHANGED
|
@@ -9,122 +9,177 @@
|
|
| 9 |
margin: 0;
|
| 10 |
padding: 0;
|
| 11 |
box-sizing: border-box;
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
body {
|
| 15 |
-
font-family: Arial, sans-serif;
|
| 16 |
-
padding: 20px;
|
| 17 |
-
background: #f0f0f0;
|
| 18 |
min-height: 100vh;
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
.container {
|
| 22 |
max-width: 1200px;
|
| 23 |
margin: 0 auto;
|
| 24 |
-
padding:
|
| 25 |
}
|
| 26 |
|
| 27 |
h1 {
|
| 28 |
-
font-size:
|
|
|
|
| 29 |
color: #262626;
|
| 30 |
-
margin-bottom:
|
| 31 |
}
|
| 32 |
|
| 33 |
.upload-zone {
|
| 34 |
-
border: 2px dashed #ccc;
|
| 35 |
-
padding: 40px;
|
| 36 |
-
text-align: center;
|
| 37 |
-
margin-bottom: 20px;
|
| 38 |
-
cursor: pointer;
|
| 39 |
background: white;
|
| 40 |
-
|
| 41 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
-
.upload-zone:hover
|
|
|
|
| 45 |
border-color: #405DE6;
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
-
.upload-zone
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
.upload-icon {
|
| 54 |
-
width:
|
| 55 |
-
height:
|
| 56 |
-
margin-bottom: 1rem;
|
| 57 |
color: #405DE6;
|
| 58 |
}
|
| 59 |
|
| 60 |
.upload-text {
|
| 61 |
font-size: 1.125rem;
|
| 62 |
font-weight: 600;
|
| 63 |
-
margin-bottom: 0.5rem;
|
| 64 |
}
|
| 65 |
|
| 66 |
.upload-subtext {
|
| 67 |
font-size: 0.875rem;
|
| 68 |
-
color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}
|
| 70 |
|
| 71 |
.gallery {
|
| 72 |
display: grid;
|
| 73 |
-
grid-template-columns: repeat(auto-fill, minmax(
|
| 74 |
-
gap:
|
| 75 |
-
padding: 20px 0;
|
| 76 |
}
|
| 77 |
|
| 78 |
.image-card {
|
| 79 |
position: relative;
|
| 80 |
background: white;
|
| 81 |
-
border-radius:
|
| 82 |
overflow: hidden;
|
| 83 |
-
box-shadow: 0
|
| 84 |
}
|
| 85 |
|
| 86 |
.image-card img {
|
| 87 |
width: 100%;
|
| 88 |
-
|
| 89 |
object-fit: cover;
|
|
|
|
| 90 |
}
|
| 91 |
|
| 92 |
-
.
|
| 93 |
position: absolute;
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
border: none;
|
| 98 |
-
border-radius:
|
| 99 |
-
width:
|
| 100 |
-
height:
|
| 101 |
cursor: pointer;
|
| 102 |
display: flex;
|
| 103 |
align-items: center;
|
| 104 |
justify-content: center;
|
| 105 |
-
|
| 106 |
}
|
| 107 |
|
| 108 |
-
.delete-
|
| 109 |
-
background:
|
| 110 |
color: white;
|
| 111 |
}
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
.toast {
|
| 114 |
position: fixed;
|
| 115 |
-
bottom:
|
| 116 |
-
right:
|
| 117 |
-
|
|
|
|
| 118 |
color: white;
|
| 119 |
-
|
| 120 |
-
border-radius: 4px;
|
| 121 |
display: none;
|
| 122 |
-
animation: slideIn 0.
|
| 123 |
}
|
| 124 |
|
| 125 |
@keyframes slideIn {
|
| 126 |
-
from {
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
</style>
|
| 130 |
</head>
|
|
@@ -132,74 +187,86 @@
|
|
| 132 |
<div class="container">
|
| 133 |
<h1>Image Gallery</h1>
|
| 134 |
<div class="upload-zone" id="uploadZone">
|
| 135 |
-
<
|
| 136 |
-
<
|
| 137 |
-
|
| 138 |
-
<
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
| 142 |
<input type="file" id="fileInput" accept="image/*" multiple hidden>
|
| 143 |
</div>
|
| 144 |
<div class="gallery" id="gallery"></div>
|
| 145 |
</div>
|
|
|
|
|
|
|
|
|
|
| 146 |
<div class="toast" id="toast"></div>
|
| 147 |
|
| 148 |
<script>
|
| 149 |
const uploadZone = document.getElementById('uploadZone');
|
| 150 |
const fileInput = document.getElementById('fileInput');
|
| 151 |
const gallery = document.getElementById('gallery');
|
|
|
|
|
|
|
| 152 |
const toast = document.getElementById('toast');
|
| 153 |
|
| 154 |
let images = [];
|
| 155 |
|
| 156 |
-
function showToast(message
|
| 157 |
toast.textContent = message;
|
| 158 |
toast.style.display = 'block';
|
| 159 |
setTimeout(() => {
|
| 160 |
toast.style.display = 'none';
|
| 161 |
-
},
|
| 162 |
}
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
uploadZone.addEventListener('dragover', (e) => {
|
| 167 |
e.preventDefault();
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
uploadZone.addEventListener('drop', (e) => {
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
handleFiles(
|
| 179 |
});
|
| 180 |
|
| 181 |
fileInput.addEventListener('change', (e) => {
|
| 182 |
-
|
|
|
|
| 183 |
fileInput.value = '';
|
| 184 |
});
|
| 185 |
|
| 186 |
function handleFiles(files) {
|
| 187 |
-
|
| 188 |
if (file.type.startsWith('image/')) {
|
| 189 |
const reader = new FileReader();
|
| 190 |
reader.onload = (e) => {
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
| 193 |
showToast('Image uploaded successfully');
|
| 194 |
};
|
| 195 |
reader.readAsDataURL(file);
|
| 196 |
}
|
| 197 |
-
}
|
| 198 |
}
|
| 199 |
|
| 200 |
-
function addImage(
|
| 201 |
-
|
| 202 |
-
images.push({ id, url });
|
| 203 |
renderGallery();
|
| 204 |
}
|
| 205 |
|
|
@@ -209,11 +276,26 @@
|
|
| 209 |
showToast('Image deleted successfully');
|
| 210 |
}
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
function renderGallery() {
|
| 213 |
gallery.innerHTML = images.map(img => `
|
| 214 |
<div class="image-card">
|
| 215 |
-
<img src="${img.url}" alt="Gallery image">
|
| 216 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
</div>
|
| 218 |
`).join('');
|
| 219 |
}
|
|
|
|
| 9 |
margin: 0;
|
| 10 |
padding: 0;
|
| 11 |
box-sizing: border-box;
|
| 12 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
| 13 |
}
|
| 14 |
|
| 15 |
body {
|
|
|
|
|
|
|
|
|
|
| 16 |
min-height: 100vh;
|
| 17 |
+
background: #FAFAFA;
|
| 18 |
}
|
| 19 |
|
| 20 |
.container {
|
| 21 |
max-width: 1200px;
|
| 22 |
margin: 0 auto;
|
| 23 |
+
padding: 2rem;
|
| 24 |
}
|
| 25 |
|
| 26 |
h1 {
|
| 27 |
+
font-size: 1.875rem;
|
| 28 |
+
font-weight: bold;
|
| 29 |
color: #262626;
|
| 30 |
+
margin-bottom: 2rem;
|
| 31 |
}
|
| 32 |
|
| 33 |
.upload-zone {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
background: white;
|
| 35 |
+
border: 2px dashed #e2e8f0;
|
| 36 |
+
border-radius: 0.5rem;
|
| 37 |
+
padding: 2rem;
|
| 38 |
+
margin-bottom: 2rem;
|
| 39 |
+
cursor: pointer;
|
| 40 |
+
transition: all 0.2s;
|
| 41 |
}
|
| 42 |
|
| 43 |
+
.upload-zone:hover,
|
| 44 |
+
.upload-zone.dragging {
|
| 45 |
border-color: #405DE6;
|
| 46 |
+
background: #f8fafc;
|
| 47 |
}
|
| 48 |
|
| 49 |
+
.upload-zone-content {
|
| 50 |
+
display: flex;
|
| 51 |
+
flex-direction: column;
|
| 52 |
+
align-items: center;
|
| 53 |
+
gap: 1rem;
|
| 54 |
}
|
| 55 |
|
| 56 |
.upload-icon {
|
| 57 |
+
width: 3rem;
|
| 58 |
+
height: 3rem;
|
|
|
|
| 59 |
color: #405DE6;
|
| 60 |
}
|
| 61 |
|
| 62 |
.upload-text {
|
| 63 |
font-size: 1.125rem;
|
| 64 |
font-weight: 600;
|
|
|
|
| 65 |
}
|
| 66 |
|
| 67 |
.upload-subtext {
|
| 68 |
font-size: 0.875rem;
|
| 69 |
+
color: #64748b;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.select-button {
|
| 73 |
+
margin-top: 1rem;
|
| 74 |
+
padding: 0.5rem 1rem;
|
| 75 |
+
background: white;
|
| 76 |
+
border: 1px solid #e2e8f0;
|
| 77 |
+
border-radius: 0.375rem;
|
| 78 |
+
font-size: 0.875rem;
|
| 79 |
+
cursor: pointer;
|
| 80 |
+
transition: all 0.2s;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.select-button:hover {
|
| 84 |
+
background: #405DE6;
|
| 85 |
+
color: white;
|
| 86 |
}
|
| 87 |
|
| 88 |
.gallery {
|
| 89 |
display: grid;
|
| 90 |
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
| 91 |
+
gap: 1rem;
|
|
|
|
| 92 |
}
|
| 93 |
|
| 94 |
.image-card {
|
| 95 |
position: relative;
|
| 96 |
background: white;
|
| 97 |
+
border-radius: 0.5rem;
|
| 98 |
overflow: hidden;
|
| 99 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
| 100 |
}
|
| 101 |
|
| 102 |
.image-card img {
|
| 103 |
width: 100%;
|
| 104 |
+
aspect-ratio: 1;
|
| 105 |
object-fit: cover;
|
| 106 |
+
cursor: pointer;
|
| 107 |
}
|
| 108 |
|
| 109 |
+
.image-overlay {
|
| 110 |
position: absolute;
|
| 111 |
+
inset: 0;
|
| 112 |
+
background: rgba(0,0,0,0.4);
|
| 113 |
+
opacity: 0;
|
| 114 |
+
transition: opacity 0.2s;
|
| 115 |
+
display: flex;
|
| 116 |
+
align-items: center;
|
| 117 |
+
justify-content: center;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.image-card:hover .image-overlay {
|
| 121 |
+
opacity: 1;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.delete-button {
|
| 125 |
+
background: white;
|
| 126 |
border: none;
|
| 127 |
+
border-radius: 9999px;
|
| 128 |
+
width: 2.5rem;
|
| 129 |
+
height: 2.5rem;
|
| 130 |
cursor: pointer;
|
| 131 |
display: flex;
|
| 132 |
align-items: center;
|
| 133 |
justify-content: center;
|
| 134 |
+
transition: all 0.2s;
|
| 135 |
}
|
| 136 |
|
| 137 |
+
.delete-button:hover {
|
| 138 |
+
background: #ef4444;
|
| 139 |
color: white;
|
| 140 |
}
|
| 141 |
|
| 142 |
+
.modal {
|
| 143 |
+
position: fixed;
|
| 144 |
+
inset: 0;
|
| 145 |
+
background: rgba(0,0,0,0.8);
|
| 146 |
+
display: none;
|
| 147 |
+
align-items: center;
|
| 148 |
+
justify-content: center;
|
| 149 |
+
z-index: 50;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.modal.active {
|
| 153 |
+
display: flex;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.modal img {
|
| 157 |
+
max-width: 90vw;
|
| 158 |
+
max-height: 90vh;
|
| 159 |
+
object-fit: contain;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
.toast {
|
| 163 |
position: fixed;
|
| 164 |
+
bottom: 1rem;
|
| 165 |
+
right: 1rem;
|
| 166 |
+
padding: 1rem;
|
| 167 |
+
background: #262626;
|
| 168 |
color: white;
|
| 169 |
+
border-radius: 0.375rem;
|
|
|
|
| 170 |
display: none;
|
| 171 |
+
animation: slideIn 0.2s ease-out;
|
| 172 |
}
|
| 173 |
|
| 174 |
@keyframes slideIn {
|
| 175 |
+
from {
|
| 176 |
+
transform: translateY(100%);
|
| 177 |
+
opacity: 0;
|
| 178 |
+
}
|
| 179 |
+
to {
|
| 180 |
+
transform: translateY(0);
|
| 181 |
+
opacity: 1;
|
| 182 |
+
}
|
| 183 |
}
|
| 184 |
</style>
|
| 185 |
</head>
|
|
|
|
| 187 |
<div class="container">
|
| 188 |
<h1>Image Gallery</h1>
|
| 189 |
<div class="upload-zone" id="uploadZone">
|
| 190 |
+
<div class="upload-zone-content">
|
| 191 |
+
<svg class="upload-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 192 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/>
|
| 193 |
+
</svg>
|
| 194 |
+
<div class="upload-text">Click or drag and drop your images here</div>
|
| 195 |
+
<div class="upload-subtext">Supports: JPG, PNG, GIF</div>
|
| 196 |
+
<button class="select-button">Select Image</button>
|
| 197 |
+
</div>
|
| 198 |
<input type="file" id="fileInput" accept="image/*" multiple hidden>
|
| 199 |
</div>
|
| 200 |
<div class="gallery" id="gallery"></div>
|
| 201 |
</div>
|
| 202 |
+
<div class="modal" id="modal">
|
| 203 |
+
<img id="modalImage" src="" alt="Full size image">
|
| 204 |
+
</div>
|
| 205 |
<div class="toast" id="toast"></div>
|
| 206 |
|
| 207 |
<script>
|
| 208 |
const uploadZone = document.getElementById('uploadZone');
|
| 209 |
const fileInput = document.getElementById('fileInput');
|
| 210 |
const gallery = document.getElementById('gallery');
|
| 211 |
+
const modal = document.getElementById('modal');
|
| 212 |
+
const modalImage = document.getElementById('modalImage');
|
| 213 |
const toast = document.getElementById('toast');
|
| 214 |
|
| 215 |
let images = [];
|
| 216 |
|
| 217 |
+
function showToast(message) {
|
| 218 |
toast.textContent = message;
|
| 219 |
toast.style.display = 'block';
|
| 220 |
setTimeout(() => {
|
| 221 |
toast.style.display = 'none';
|
| 222 |
+
}, 3000);
|
| 223 |
}
|
| 224 |
|
| 225 |
+
function handleDrag(e) {
|
|
|
|
|
|
|
| 226 |
e.preventDefault();
|
| 227 |
+
e.stopPropagation();
|
| 228 |
+
|
| 229 |
+
if (e.type === "dragenter" || e.type === "dragover") {
|
| 230 |
+
uploadZone.classList.add('dragging');
|
| 231 |
+
} else if (e.type === "dragleave" || e.type === "drop") {
|
| 232 |
+
uploadZone.classList.remove('dragging');
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
|
| 236 |
+
uploadZone.addEventListener('click', () => fileInput.click());
|
| 237 |
+
uploadZone.addEventListener('dragenter', handleDrag);
|
| 238 |
+
uploadZone.addEventListener('dragover', handleDrag);
|
| 239 |
+
uploadZone.addEventListener('dragleave', handleDrag);
|
| 240 |
uploadZone.addEventListener('drop', (e) => {
|
| 241 |
+
handleDrag(e);
|
| 242 |
+
const files = Array.from(e.dataTransfer.files);
|
| 243 |
+
handleFiles(files);
|
| 244 |
});
|
| 245 |
|
| 246 |
fileInput.addEventListener('change', (e) => {
|
| 247 |
+
const files = Array.from(e.target.files || []);
|
| 248 |
+
handleFiles(files);
|
| 249 |
fileInput.value = '';
|
| 250 |
});
|
| 251 |
|
| 252 |
function handleFiles(files) {
|
| 253 |
+
files.forEach(file => {
|
| 254 |
if (file.type.startsWith('image/')) {
|
| 255 |
const reader = new FileReader();
|
| 256 |
reader.onload = (e) => {
|
| 257 |
+
addImage({
|
| 258 |
+
id: Date.now(),
|
| 259 |
+
url: e.target.result
|
| 260 |
+
});
|
| 261 |
showToast('Image uploaded successfully');
|
| 262 |
};
|
| 263 |
reader.readAsDataURL(file);
|
| 264 |
}
|
| 265 |
+
});
|
| 266 |
}
|
| 267 |
|
| 268 |
+
function addImage(image) {
|
| 269 |
+
images.push(image);
|
|
|
|
| 270 |
renderGallery();
|
| 271 |
}
|
| 272 |
|
|
|
|
| 276 |
showToast('Image deleted successfully');
|
| 277 |
}
|
| 278 |
|
| 279 |
+
function showModal(url) {
|
| 280 |
+
modalImage.src = url;
|
| 281 |
+
modal.classList.add('active');
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
modal.addEventListener('click', () => {
|
| 285 |
+
modal.classList.remove('active');
|
| 286 |
+
});
|
| 287 |
+
|
| 288 |
function renderGallery() {
|
| 289 |
gallery.innerHTML = images.map(img => `
|
| 290 |
<div class="image-card">
|
| 291 |
+
<img src="${img.url}" alt="Gallery image" onclick="showModal('${img.url}')">
|
| 292 |
+
<div class="image-overlay">
|
| 293 |
+
<button class="delete-button" onclick="deleteImage(${img.id})">
|
| 294 |
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
| 295 |
+
<path d="M18 6L6 18M6 6l12 12"/>
|
| 296 |
+
</svg>
|
| 297 |
+
</button>
|
| 298 |
+
</div>
|
| 299 |
</div>
|
| 300 |
`).join('');
|
| 301 |
}
|