-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticipate.html
597 lines (514 loc) · 19 KB
/
participate.html
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Approvideo - Create sustainable DIY solutions and mint NFTs to support environmental initiatives">
<meta name="theme-color" content="#059669">
<script src="https://unpkg.com/svelte@3/compiler.js"></script>
<script>
// Create a new Svelte component
const app = new Svelte({
target: document.getElementById('app'),
props: {
// Initial props here
}
});
</script>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js');
}
</script>
<!-- Add manifest for PWA -->
<link rel="manifest" href="/manifest.json">
<!-- Add these meta tags for better SEO and social sharing -->
<meta property="og:title" content="Approvideo - Sustainable DIY Solutions">
<meta property="og:description" content="Create sustainable DIY solutions and mint NFTs to support environmental initiatives">
<meta property="og:image" content="/path-to-your-og-image.jpg">
<meta name="twitter:card" content="summary_large_image">
<!-- Preload key assets -->
<link rel="modulepreload" href="https://unpkg.com/lucide-svelte@latest/dist/esm/icons/recycle.js">
<link rel="modulepreload" href="https://unpkg.com/lucide-svelte@latest/dist/esm/icons/zap.js">
<!-- Accessibility Meta Tags -->
<meta name="application-name" content="Approvideo">
<meta name="apple-mobile-web-app-title" content="Approvideo">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="color-scheme" content="dark light">
<title>Approvideo - Sustainable DIY Solutions</title>
<!-- Preload Critical Assets -->
<link rel="preload" href="/fonts/Inter-var.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/fonts/JetBrainsMono-Regular.woff2" as="font" type="font/woff2" crossorigin>
<!-- Fonts with Extended Unicode Range -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=JetBrains+Mono:wght@400;700&display=swap&text=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F%3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D%7E" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
// Previous theme configurations...
// Enhanced focus styles
ringWidth: {
'3': '3px',
'4': '4px',
},
ringOffsetWidth: {
'3': '3px',
'4': '4px',
},
// Motion-safe animations
screens: {
'motion-safe': { 'raw': '(prefers-reduced-motion: no-preference)' },
'motion-reduce': { 'raw': '(prefers-reduced-motion: reduce)' },
},
},
},
}
</script>
<!-- Base Styles with Accessibility Enhancements -->
<style>
@layer base {
/* Previous base styles... */
/* Enhanced focus styles */
:focus {
@apply outline-2 outline-offset-2 outline-eco-primary;
}
:focus:not(:focus-visible) {
@apply outline-none;
}
:focus-visible {
@apply outline-2 outline-offset-2 outline-eco-primary ring-2 ring-eco-primary ring-offset-2;
}
/* Skip to main content link */
.skip-to-main {
@apply sr-only focus:not-sr-only focus:fixed focus:top-4 focus:left-4
bg-eco-primary text-white px-4 py-2 rounded-md z-50;
}
/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
/* High contrast mode adjustments */
@media (forced-colors: active) {
.button-primary {
@apply border-current;
}
.icon {
@apply fill-current;
}
}
/* Print styles */
@media print {
.no-print {
display: none !important;
}
body {
@apply text-black bg-white;
}
a[href]:after {
content: " (" attr(href) ")";
}
}
}
/* Utility classes for accessibility */
.visually-hidden:not(:focus):not(:active) {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
/* Enhanced touch targets for mobile */
@media (pointer: coarse) {
.interactive-element {
@apply min-h-[44px] min-w-[44px];
}
}
/* Color contrast helpers */
.text-accessible {
@apply text-gray-900 dark:text-gray-100;
}
.bg-accessible {
@apply bg-white dark:bg-gray-900;
}
</style>
<!-- Accessibility Polyfills and Helpers -->
<script>
// Polyfill for :focus-visible
document.addEventListener('DOMContentLoaded', function() {
if (!('focusVisible' in document.documentElement.style)) {
import('https://unpkg.com/[email protected]/dist/focus-visible.min.js');
}
});
// Announce dynamic content changes
window.announce = (message, priority = 'polite') => {
let announcer = document.getElementById('announcer');
if (!announcer) {
announcer = document.createElement('div');
announcer.id = 'announcer';
announcer.setAttribute('aria-live', priority);
announcer.setAttribute('aria-atomic', 'true');
announcer.className = 'sr-only';
document.body.appendChild(announcer);
}
announcer.textContent = message;
};
</script>
%sveltekit.head%
</head>
<body>
<!-- Skip to main content link -->
<a href="#main-content" class="skip-to-main">
Skip to main content
</a>
<!-- Live announcer for dynamic content -->
<div id="announcer" class="sr-only" aria-live="polite" aria-atomic="true"></div>
<!-- Progress Bar Enhancement -->
<div class="flex mb-8" role="progressbar" aria-valuemin="0" aria-valuemax="2" aria-valuenow={currentStep}>
{#each Array(3) as _, i}
<div class="flex-1 relative">
<div class={`h-2 ${i <= currentStep ? 'bg-green-500' : 'bg-gray-700'}
transition-all duration-500`}
aria-hidden="true"></div>
<div class={`absolute -top-2 left-1/2 w-6 h-6 rounded-full
transform -translate-x-1/2
${i === currentStep ? 'bg-green-400 animate-pulse' :
i < currentStep ? 'bg-green-500' : 'bg-gray-700'}`}
aria-label={`Step ${i + 1} ${i === currentStep ? '(current)' : ''}`}></div>
</div>
{/each}
</div>
<!-- Enhanced Blockchain Selection Buttons -->
<button
class={`p-6 rounded-lg border-2 transition-all duration-300
${selectedChain === chain.id ?
'border-green-500 bg-green-500/20' :
'border-gray-700 hover:border-green-500/50'}`}
on:click={() => selectedChain = chain.id}
aria-selected={selectedChain === chain.id}
role="radio"
aria-label={`Select ${chain.name} blockchain`}>
<div class="text-3xl mb-2" aria-hidden="true">{chain.icon}</div>
<div class="text-white">{chain.name}</div>
</button>
<!-- Enhanced Input Field -->
<input
type="number"
min="10"
bind:value={donationAmount}
on:input={handleDonationChange}
class="w-full bg-black/50 border border-green-500/30 rounded px-4 py-2 text-white"
aria-label="Donation amount in USD"
aria-describedby="donation-description"
/>
<div id="donation-description" class="sr-only">
Enter amount of 10 USD or more to generate unique NFT art
</div>
<!-- Generated Art Enhancement -->
{#if generatedArt}
<div class="relative" role="img" aria-label="Generated NFT artwork based on your donation">
<img
src={generatedArt}
alt="Your unique generative NFT art"
class="w-full rounded-lg shadow-lg mb-4"
class:opacity-50={isGenerating}
/>
<button
on:click={regenerateArt}
class="absolute top-2 right-2 bg-black/50 p-2 rounded-full
hover:bg-green-500/20 border border-green-500/30"
aria-label="Regenerate NFT artwork">
<Recycle class="w-5 h-5 text-green-400" />
</button>
</div>
{/if}
// Add error display
{#if error}
<div role="alert" class="bg-red-500/20 border border-red-500 rounded-lg p-4 mb-4 text-red-300">
{error}
</div>
{/if}
// Add loading indicator
{#if isLoading}
<div class="flex items-center justify-center p-4" aria-live="polite">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-green-500"></div>
</div>
{/if}
<div id="svelte"
role="document"
class="min-h-screen">
%sveltekit.body%
</div>
<script>
import { onMount } from 'svelte';
import { fade, fly } from 'svelte/transition';
import { Bird, Leaf, Droplet, Recycle, Zap } from 'lucide-svelte';
// State management
let currentStep = 0;
let selectedChain = null;
let generatedArt = null;
let donationAmount = 0;
let isGenerating = false;
let error = null;
let isLoading = false;
// SVG generation parameters
let seedValue = Math.random();
let complexity = 5;
let colorScheme = 'eco';
const chains = [
{ id: 'algo', name: 'Algorand', icon: '🌊' },
{ id: 'tezos', name: 'Tezos', icon: '🌱' }
];
// Generate unique art based on donation amount and seed
function generateArt(amount, seed) {
const canvas = document.createElement('canvas');
canvas.width = 500;
canvas.height = 500;
const ctx = canvas.getContext('2d');
// Base pattern
ctx.fillStyle = '#001a0f';
ctx.fillRect(0, 0, 500, 500);
// Generate layers based on donation amount
const layers = Math.floor(amount / 10) + 3;
for (let i = 0; i < layers; i++) {
const hue = (seed * 360 + i * (360 / layers)) % 360;
ctx.strokeStyle = `hsla(${hue}, 70%, 50%, 0.5)`;
ctx.lineWidth = 2;
// Create organic patterns
for (let j = 0; j < complexity * 2; j++) {
ctx.beginPath();
ctx.moveTo(
seed * 500,
(i / layers) * 500
);
// Generate control points for curved lines
for (let k = 0; k < 5; k++) {
ctx.quadraticCurveTo(
((seed + k) * 500) % 500,
((i + k) * 500 / layers) % 500,
((seed + k + 1) * 500) % 500,
((i + k + 1) * 500 / layers) % 500
);
}
ctx.stroke();
}
}
// Add glitch effect
if (amount > 50) {
for (let i = 0; i < 3; i++) {
const x = Math.random() * 500;
const y = Math.random() * 500;
const w = Math.random() * 100 + 50;
const h = Math.random() * 20 + 10;
const imageData = ctx.getImageData(x, y, w, h);
ctx.putImageData(imageData, x + (Math.random() * 20 - 10), y);
}
}
return canvas.toDataURL();
}
// Handle donation input
function handleDonationChange(event) {
donationAmount = Number(event.target.value);
if (donationAmount >= 10) {
regenerateArt();
}
}
async function regenerateArt() {
try {
isGenerating = true;
isLoading = true;
error = null;
await new Promise(resolve => setTimeout(resolve, 500));
seedValue = Math.random();
generatedArt = generateArt(donationAmount, seedValue);
// Announce to screen readers
window.announce('New NFT artwork generated');
} catch (err) {
error = 'Failed to generate artwork. Please try again.';
window.announce('Error generating artwork', 'assertive');
} finally {
isGenerating = false;
isLoading = false;
}
}
// Step navigation
function nextStep() {
if (currentStep === 1 && !generatedArt) {
regenerateArt();
}
currentStep++;
}
function prevStep() {
currentStep--;
}
// Add debouncing for donation input
let debounceTimer;
function handleDonationChange(event) {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
donationAmount = Number(event.target.value);
if (donationAmount >= 10) {
regenerateArt();
}
}, 500);
}
// Add canvas cleanup
onMount(() => {
return () => {
if (canvas) {
canvas.width = 0;
canvas.height = 0;
canvas = null;
}
};
});
// Add image preloading
const preloadImage = (src) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.src = src;
});
};
</script>
<main class="min-h-screen bg-gradient-to-br from-gray-900 via-green-900 to-gray-900">
<div class="container mx-auto px-4 py-16">
<h1 class="text-5xl font-bold text-center text-green-400 mb-8"
in:fly={{ y: -20, duration: 500 }}>
Eco Ops Check-in NFTs
</h1>
<!-- Wizard Container -->
<div class="max-w-2xl mx-auto bg-black/50 backdrop-blur-sm rounded-lg border border-green-500/30 p-8">
<!-- Progress Bar -->
<div class="flex mb-8">
{#each Array(3) as _, i}
<div class="flex-1 relative">
<div class={`h-2 ${i <= currentStep ? 'bg-green-500' : 'bg-gray-700'}
transition-all duration-500`}></div>
<div class={`absolute -top-2 left-1/2 w-6 h-6 rounded-full
transform -translate-x-1/2
${i === currentStep ? 'bg-green-400 animate-pulse' :
i < currentStep ? 'bg-green-500' : 'bg-gray-700'}`}>
</div>
</div>
{/each}
</div>
<!-- Step Content -->
{#if currentStep === 0}
<div in:fade={{ duration: 300 }}>
<h2 class="text-2xl font-bold text-green-400 mb-4">Choose Your Blockchain</h2>
<div class="grid grid-cols-2 gap-4">
{#each chains as chain}
<button
class={`p-6 rounded-lg border-2 transition-all duration-300
${selectedChain === chain.id ?
'border-green-500 bg-green-500/20' :
'border-gray-700 hover:border-green-500/50'}`}
on:click={() => selectedChain = chain.id}>
<div class="text-3xl mb-2">{chain.icon}</div>
<div class="text-white">{chain.name}</div>
</button>
{/each}
</div>
</div>
{:else if currentStep === 1}
<div in:fade={{ duration: 300 }}>
<h2 class="text-2xl font-bold text-green-400 mb-4">Generate Your NFT</h2>
<div class="mb-6">
<label class="block text-green-400 mb-2">Donation Amount (USD)</label>
<input
type="number"
min="10"
bind:value={donationAmount}
on:input={handleDonationChange}
class="w-full bg-black/50 border border-green-500/30 rounded px-4 py-2 text-white"
/>
</div>
{#if generatedArt}
<div class="relative">
<img
src={generatedArt}
alt="Generated NFT Art"
class="w-full rounded-lg shadow-lg mb-4"
class:opacity-50={isGenerating}
/>
<button
on:click={regenerateArt}
class="absolute top-2 right-2 bg-black/50 p-2 rounded-full
hover:bg-green-500/20 border border-green-500/30">
<Recycle class="w-5 h-5 text-green-400" />
</button>
</div>
{/if}
</div>
{:else if currentStep === 2}
<div in:fade={{ duration: 300 }}>
<h2 class="text-2xl font-bold text-green-400 mb-4">Confirm & Mint</h2>
<div class="bg-black/30 rounded-lg p-6 mb-6">
<div class="flex justify-between mb-4">
<span class="text-gray-400">Blockchain</span>
<span class="text-white">{chains.find(c => c.id === selectedChain)?.name}</span>
</div>
<div class="flex justify-between mb-4">
<span class="text-gray-400">Donation</span>
<span class="text-white">${donationAmount}</span>
</div>
<div class="flex justify-between">
<span class="text-gray-400">Recipient</span>
<span class="text-white">SCDHub 501c3</span>
</div>
</div>
</div>
{/if}
<!-- Navigation Buttons -->
<div class="flex justify-between mt-8">
{#if currentStep > 0}
<button
on:click={prevStep}
class="px-6 py-2 border border-green-500/30 rounded
hover:bg-green-500/20 text-green-400">
Back
</button>
{:else}
<div></div>
{/if}
<button
on:click={currentStep === 2 ? null : nextStep}
disabled={currentStep === 0 && !selectedChain}
class={`px-6 py-2 rounded text-white
${currentStep === 2 ? 'bg-green-500 hover:bg-green-600' :
'bg-green-500/50 hover:bg-green-500/70'}
${currentStep === 0 && !selectedChain ? 'opacity-50 cursor-not-allowed' : ''}`}>
{currentStep === 2 ? 'Mint NFT' : 'Next'}
</button>
</div>
</div>
</div>
</main>
<style>
:global(body) {
margin: 0;
font-family: system-ui, -apple-system, sans-serif;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
</style>
</body>
</html>