-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVirtual Art Gallery.html
More file actions
351 lines (294 loc) · 9.55 KB
/
Virtual Art Gallery.html
File metadata and controls
351 lines (294 loc) · 9.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Virtual Art Gallery</title>
<style>
/* General Styles */
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
color: #333;
transition: background-color 0.3s, color 0.3s;
}
.dark-mode {
background-color: #333;
color: #f4f4f4;
}
/* Header Styles */
header {
background-color: #444;
color: #fff;
padding: 1rem 0;
text-align: center;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
header h1 {
margin: 0;
font-size: 2.5rem;
}
/* Navigation Styles */
nav {
background-color: #ddd;
padding: 0.5rem 0;
text-align: center;
margin-bottom: 20px;
}
nav a {
color: #333;
text-decoration: none;
padding: 0.5rem 1rem;
margin: 0 0.5rem;
border-radius: 5px;
transition: background-color 0.3s, color 0.3s;
}
nav a:hover {
background-color: #444;
color: #fff;
}
.dark-mode nav {
background-color: #555;
}
.dark-mode nav a {
color: #f4f4f4;
}
/* Gallery Styles */
#gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
padding: 20px;
max-width: 1200px;
margin: 0 auto;
}
.artwork {
background-color: #fff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.3s;
}
.artwork:hover {
transform: translateY(-5px);
}
.artwork img {
width: 100%;
height: auto;
display: block;
}
.artwork-details {
padding: 1rem;
}
.artwork-details h3 {
margin: 0 0 0.5rem;
font-size: 1.2rem;
}
.artwork-details p {
margin: 0;
font-size: 0.9rem;
color: #666;
}
.dark-mode .artwork {
background-color: #444;
box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}
.dark-mode .artwork-details h3,
.dark-mode .artwork-details p {
color: #ddd;
}
/* Upload Form Styles */
#upload-form {
max-width: 600px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
#upload-form h2 {
text-align: center;
margin-bottom: 1rem;
}
#upload-form label {
display: block;
margin-top: 0.5rem;
font-weight: bold;
}
#upload-form input[type="text"],
#upload-form textarea,
#upload-form input[type="file"] {
width: 100%;
padding: 0.75rem;
margin-top: 0.25rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
#upload-form button {
background-color: #5cb85c;
color: white;
padding: 0.75rem 1.5rem;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s;
}
#upload-form button:hover {
background-color: #449d44;
}
.dark-mode #upload-form {
background-color: #444;
color: #ddd;
box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}
.dark-mode #upload-form input[type="text"],
.dark-mode #upload-form textarea,
.dark-mode #upload-form input[type="file"] {
background-color: #555;
color: #ddd;
border-color: #777;
}
/* Dark Mode Toggle */
#dark-mode-toggle {
position: fixed;
top: 20px;
right: 20px;
background-color: #333;
color: #fff;
border: none;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
z-index: 100;
transition: background-color 0.3s;
}
#dark-mode-toggle:hover {
background-color: #555;
}
/* Footer Styles */
footer {
text-align: center;
padding: 1rem 0;
background-color: #444;
color: #fff;
position: relative;
bottom: 0;
width: 100%;
}
/* Responsive Design */
@media (max-width: 768px) {
header h1 {
font-size: 2rem;
}
nav a {
padding: 0.4rem 0.8rem;
margin: 0 0.3rem;
}
#gallery {
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
padding: 10px;
}
#upload-form {
padding: 10px;
}
}
</style>
</head>
<body>
<button id="dark-mode-toggle">Toggle Dark Mode</button>
<header>
<h1>Virtual Art Gallery</h1>
</header>
<nav>
<a href="#">Home</a>
<a href="#gallery">Gallery</a>
<a href="#upload-form">Upload Art</a>
</nav>
<section id="gallery">
<!-- Artworks will be dynamically added here -->
</section>
<section id="upload-form">
<h2>Upload Your Artwork</h2>
<label for="artwork-title">Title:</label>
<input type="text" id="artwork-title" name="artwork-title" required>
<label for="artist-name">Artist Name:</label>
<input type="text" id="artist-name" name="artist-name" required>
<label for="artwork-description">Description:</label>
<textarea id="artwork-description" name="artwork-description" rows="4" required></textarea>
<label for="artwork-image">Upload Image:</label>
<input type="file" id="artwork-image" name="artwork-image" accept="image/*" required>
<button onclick="uploadArtwork()">Upload</button>
</section>
<footer>
<p>© 2024 Virtual Art Gallery</p>
</footer>
<script>
const gallery = document.getElementById('gallery');
const darkModeToggle = document.getElementById('dark-mode-toggle');
const body = document.body;
// Load artworks from local storage (if any)
let artworks = JSON.parse(localStorage.getItem('artworks')) || [];
renderGallery();
// Dark Mode Toggle Functionality
darkModeToggle.addEventListener('click', () => {
body.classList.toggle('dark-mode');
const isDarkMode = body.classList.contains('dark-mode');
localStorage.setItem('dark-mode', isDarkMode);
});
// Check for dark mode preference in local storage
if (localStorage.getItem('dark-mode') === 'true') {
body.classList.add('dark-mode');
}
function uploadArtwork() {
const title = document.getElementById('artwork-title').value;
const artist = document.getElementById('artist-name').value;
const description = document.getElementById('artwork-description').value;
const imageFile = document.getElementById('artwork-image').files[0];
if (!title || !artist || !description || !imageFile) {
alert('Please fill in all fields.');
return;
}
const reader = new FileReader();
reader.onload = function (e) {
const imageUrl = e.target.result;
const artwork = {
title: title,
artist: artist,
description: description,
imageUrl: imageUrl
};
artworks.push(artwork);
localStorage.setItem('artworks', JSON.stringify(artworks));
renderGallery();
// Clear the form
document.getElementById('artwork-title').value = '';
document.getElementById('artist-name').value = '';
document.getElementById('artwork-description').value = '';
document.getElementById('artwork-image').value = '';
}
reader.readAsDataURL(imageFile);
}
function renderGallery() {
gallery.innerHTML = ''; // Clear existing gallery
artworks.forEach(artwork => {
const artworkElement = document.createElement('div');
artworkElement.classList.add('artwork');
artworkElement.innerHTML = `
<img src="${artwork.imageUrl}" alt="${artwork.title}">
<div class="artwork-details">
<h3>${artwork.title}</h3>
<p>Artist: ${artwork.artist}</p>
<p>${artwork.description}</p>
</div>
`;
gallery.appendChild(artworkElement);
});
}
</script>
</body>
</html>