pakdeveloper commited on
Commit
febf9f7
·
verified ·
1 Parent(s): 20e14f6

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +233 -300
index.html CHANGED
@@ -1,307 +1,240 @@
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
- @keyframes slideIn {
178
- from {
179
- transform: translateY(100%);
180
- opacity: 0;
181
  }
182
- to {
183
- transform: translateY(0);
184
- opacity: 1;
185
- }
186
- }
187
- </style>
188
- </head>
189
- <body>
190
- <div class="container">
191
- <h1>Image Gallery</h1>
192
- <div class="upload-zone" id="uploadZone">
193
- <div class="upload-zone-content">
194
- <svg class="upload-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
195
- <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"/>
196
- </svg>
197
- <div class="upload-text">Click or drag and drop your images here</div>
198
- <div class="upload-subtext">Supports: JPG, PNG, GIF</div>
199
- <button class="select-button">Select Image</button>
200
- </div>
201
- <input type="file" id="fileInput" accept="image/*" multiple hidden>
202
- </div>
203
- <div class="gallery" id="gallery"></div>
204
- </div>
205
- <div class="modal" id="modal">
206
- <img id="modalImage" src="" alt="Full size image">
207
- </div>
208
- <div class="toast" id="toast"></div>
209
-
210
- <script>
211
- const uploadZone = document.getElementById('uploadZone');
212
- const fileInput = document.getElementById('fileInput');
213
- const gallery = document.getElementById('gallery');
214
- const modal = document.getElementById('modal');
215
- const modalImage = document.getElementById('modalImage');
216
- const toast = document.getElementById('toast');
217
-
218
- let images = [];
219
-
220
- function showToast(message) {
221
- toast.textContent = message;
222
- toast.style.display = 'block';
223
- setTimeout(() => {
224
- toast.style.display = 'none';
225
- }, 3000);
226
- }
227
-
228
- function handleDrag(e) {
229
- e.preventDefault();
230
- e.stopPropagation();
231
-
232
- if (e.type === "dragenter" || e.type === "dragover") {
233
- uploadZone.classList.add('dragging');
234
- } else if (e.type === "dragleave" || e.type === "drop") {
235
- uploadZone.classList.remove('dragging');
236
- }
237
- }
238
-
239
- uploadZone.addEventListener('click', () => fileInput.click());
240
- uploadZone.addEventListener('dragenter', handleDrag);
241
- uploadZone.addEventListener('dragover', handleDrag);
242
- uploadZone.addEventListener('dragleave', handleDrag);
243
- uploadZone.addEventListener('drop', (e) => {
244
- handleDrag(e);
245
- const files = Array.from(e.dataTransfer.files);
246
- handleFiles(files);
247
  });
248
-
249
- fileInput.addEventListener('change', (e) => {
250
- const files = Array.from(e.target.files || []);
251
- handleFiles(files);
252
- fileInput.value = '';
253
- });
254
-
255
- function handleFiles(files) {
256
- files.forEach(file => {
257
- if (file.type.startsWith('image/')) {
258
- const reader = new FileReader();
259
- reader.onload = (e) => {
260
- addImage({
261
- id: Date.now(),
262
- url: e.target.result
263
- });
264
- showToast('Image uploaded successfully');
265
- };
266
- reader.readAsDataURL(file);
267
- }
268
- });
269
- }
270
-
271
- function addImage(image) {
272
- images.push(image);
273
- renderGallery();
274
- }
275
-
276
- function deleteImage(id) {
277
- images = images.filter(img => img.id !== id);
278
- renderGallery();
279
- showToast('Image deleted successfully');
280
- }
281
-
282
- function showModal(url) {
283
- modalImage.src = url;
284
- modal.classList.add('active');
285
- }
286
-
287
- modal.addEventListener('click', () => {
288
- modal.classList.remove('active');
289
- });
290
-
291
- function renderGallery() {
292
- gallery.innerHTML = images.map(img => `
293
- <div class="image-card">
294
- <img src="${img.url}" alt="Gallery image" onclick="showModal('${img.url}')">
295
- <div class="image-overlay">
296
- <button class="delete-button" onclick="deleteImage(${img.id})">
297
- <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
298
- <path d="M18 6L6 18M6 6l12 12"/>
299
- </svg>
300
- </button>
301
- </div>
302
  </div>
303
- `).join('');
304
- }
305
- </script>
306
- </body>
307
- </html>
 
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>