pakdeveloper commited on
Commit
669a5ef
·
verified ·
1 Parent(s): febf9f7

Update index.html

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