-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
655 lines (586 loc) · 36.1 KB
/
index.html
File metadata and controls
655 lines (586 loc) · 36.1 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
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canadian Bioinformatics Workshops</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel=“icon” type=“image/x-icon” href=“favicon.ico”>
<link rel=“icon” type=“image/png” sizes=“32x32" href=“favicon-32x32.png”>
<link rel=“icon” type=“image/png” sizes=“16x16" href=“favicon-16x16.png”>
<link rel=“apple-touch-icon” sizes=“180x180” href=“apple-touch-icon.png”>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: { sans: ['Manrope', 'sans-serif'], },
colors: {
// Original Brand Colors (Used for borders and color bar)
'brand-purple': '#5A1F65',
'region-bc': '#3C9048',
'region-alberta': '#86264E',
'region-prairies': '#BD8528',
'region-ontario': '#BB682C',
'region-quebec': '#427FA4',
'region-atlantic': '#208A99',
'region-online': '#5A1F65', // Same as brand-purple
// NEW LIGHTER REGIONAL COLORS FOR TAG BACKGROUNDS (AAA compliant with text-gray-900)
'region-bc-light': '#8ed792', // CBH British Columbia light
'region-alberta-light': '#ca668a', // CBH Alberta light
'region-prairies-light': '#f6bc6a', // CBH Prairies light
'region-ontario-light': '#ffb37a', // CBH Ontario light
'region-quebec-light': '#9bccf0', // CBH Quebec light
'region-atlantic-light': '#84d3e1', // CBH Atlantic light
'region-online-light': '#cc7ed9', // CBW light (matching brand-purple light)
}
}
}
}
</script>
<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=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
html, body { font-family: 'Manrope', sans-serif; scroll-behavior: smooth; }
body { background-color: #f8fafc; }
/* Removed hover effects from .card directly */
.container { background-color: white; padding: 2rem; border-radius: 1rem; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); width: 100%; max-width: 80rem; border: 1px solid #e5e7eb; }
/* Apply transition to the wrapper that gets the hover effects */
.dropdown-panel, .year-section, .card-interactive-wrapper { transition: all 0.3s ease-in-out; }
/* Permanent grayscale for past-no-materials cards */
.card.past-no-materials img,
.card.past-no-materials .h-1\.5, /* Targets the color bar */
.card.past-no-materials .flex-wrap > span { /* Targets the region tags */
filter: grayscale(100%);
}
/* No transition for the image on past-no-materials cards because it's permanently gray */
.card.past-no-materials img {
opacity: 1; /* Ensure it's not faded */
}
/* No hover specific styles for color bar/region tags for past-no-materials because they are permanently gray */
.card.past-no-materials:hover .h-1\.5,
.card.past-no-materials:hover .flex-wrap > span {
filter: grayscale(100%); /* Keeps it grayscale on hover as it's already gray */
}
/* Styling for the "Materials Coming Soon" and "Materials Not Available" overlay */
.materials-overlay {
background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent dark overlay */
opacity: 0; /* Initially hidden */
transition: opacity 0.3s ease-in-out; /* Smooth transition */
display: flex;
align-items: center;
justify-content: center;
pointer-events: none; /* Allows clicks to pass through to elements below if desired, though here it covers the image */
text-align: center;
color: white;
font-weight: 700;
font-size: 1.25rem; /* text-xl */
padding: 1rem;
}
/* When the parent card (which has 'group' class) is hovered, show the overlay */
.card.group:hover .materials-overlay {
opacity: 1;
}
.card.hidden, .year-section.hidden { opacity: 0; transform: scale(0.95); max-height: 0; overflow: hidden; margin: 0 !important; padding: 0 !important; border: none; pointer-events: none; }
.filter-button:hover .dropdown-arrow { transform: translateY(2px); }
/* Focus styles for keyboard navigation */
/* Applied to the <a> tag when the card is clickable, or to internal interactive elements */
a:focus, button:focus, input:focus, .card:focus-within {
outline: 2px solid #5A1F65; /* Brand purple outline */
outline-offset: 3px;
}
@media (max-width: 639px) {
.carousel-on-mobile {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
gap: 1rem;
padding: 0.5rem 1rem;
margin: 0 -1rem;
scrollbar-width: none;
-ms-overflow-style: none;
}
.carousel-on-mobile::-webkit-scrollbar {
display: none;
}
.carousel-on-mobile > .card {
flex: 0 0 80%;
max-width: 320px;
scroll-snap-align: start;
}
}
.truncate-2-lines {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
/* --- Specific Status Display Styles (Icon + Text) --- */
.status-icon-text {
display: flex;
align-items: center;
font-size: 0.875rem; /* text-sm */
font-weight: 600; /* font-semibold */
margin-bottom: 0.5rem; /* Spacing between status and title */
color: #1f2937; /* Tailwind's gray-900 for black text */
}
.status-icon-text .icon-symbol { /* Targeting the span with the Unicode character */
font-size: 1.25rem; /* Roughly match the size of the previous Font Awesome icons */
margin-right: 0.5rem;
flex-shrink: 0;
display: inline-block; /* Treat icon as inline-block */
vertical-align: middle; /* Align icon vertically in the middle */
line-height: 1; /* Ensures icon is properly aligned vertically */
}
/* Custom colors for icons - using Tailwind's default palette */
.icon-green { color: #059669; /* Emerald 600 */ }
.icon-orange { color: #EA580C; /* Orange 600 */ }
</style>
</head>
<body class="antialiased">
<div class="container mx-auto my-8 md:my-12">
<header class="text-center mb-12">
<a href="https://bioinformatics.ca" target="_blank" rel="noopener noreferrer">
<img src="img/CBW_logo.png" alt="Canadian Bioinformatics Workshops Logo - Link to Bioinformatics.ca homepage" class="mx-auto mb-6 h-40 w-auto">
</a>
<h1 class="text-4xl md:text-5xl font-extrabold text-gray-800 tracking-tight">Canadian Bioinformatics Workshops</h1>
</header>
<nav aria-label="Main Navigation" class="text-center mb-12 flex justify-center items-center gap-4 md:gap-6 flex-wrap py-4">
<a href="#current-workshops-section" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">Upcoming Workshops</a>
<a href="#past-workshops-section" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">Past Workshops</a>
<a href="https://bioinformatics.ca/hub/about/" target="_blank" rel="noopener noreferrer" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">About<img src="img/box-arrow-up-right.svg" alt="External link icon" class="ml-2 inline-block w-3 h-3"><span class="sr-only"> (opens in new tab)</span></a>
<a href="https://bioinformatics.ca/workshops/workshop-application-form/" target="_blank" rel="noopener noreferrer" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">Apply Now<img src="img/box-arrow-up-right.svg" alt="External link icon" class="ml-2 inline-block w-3 h-3"><span class="sr-only"> (opens in new tab)</span></a>
</nav>
<div id="filter-bar" role="region" aria-label="Workshop Filters" class="mb-12 flex justify-center items-center flex-wrap gap-4 p-4 bg-slate-100/70 rounded-xl">
<div class="relative w-full sm:w-auto">
<label for="text-search-input" class="sr-only">Search workshops by keyword</label>
<input type="search" id="text-search-input" placeholder="Search workshops..." class="w-full sm:w-48 px-4 py-2.5 border border-gray-300 rounded-lg shadow-sm focus:ring-brand-purple focus:border-brand-purple transition">
</div>
</div>
<main id="link-container" class="space-y-16">
<div id="no-results-message" class="hidden" role="status" aria-live="polite">
<div class="text-center py-12 px-6 bg-slate-50 rounded-lg">
<h3 class="mt-2 text-xl font-semibold text-gray-900">No workshops found</h3>
<p class="mt-1 text-base text-gray-500">Could not load or render workshops. Please check the browser console for details.</p>
</div>
</div>
</main>
</div>
<script>
document.addEventListener('DOMContentLoaded', async () => {
try {
const response = await fetch('workshops.json');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const linksData = await response.json();
const regionOrder = ['BC', 'Alberta', 'Prairies', 'Ontario', 'Quebec', 'Atlantic', 'Online'];
const today = new Date();
today.setHours(0, 0, 0, 0); // Normalize 'today' to start of day for comparison
const linkContainer = document.getElementById('link-container');
const noResultsMessage = document.getElementById('no-results-message');
const searchInput = document.getElementById('text-search-input');
const filterBar = document.getElementById('filter-bar');
const allFilters = {
year: { container: null, active: new Set(), label: "Year" },
regions: { container: null, active: new Set(), label: "Region" },
title: { container: null, active: new Set(), label: "Workshop" },
tags: { container: null, active: new Set(), label: "Topics" },
format: { container: null, active: new Set(), label: "Format" },
status: { container: null, active: new Set(), label: "Status" }
};
function formatDateRange(startDateStr, endDateStr) {
const start = new Date(startDateStr + 'T00:00:00');
const end = new Date(endDateStr + 'T00:00:00');
const startMonth = start.toLocaleString('en-US', { month: 'long' });
const startDay = start.getDate();
const year = start.getFullYear();
if (!endDateStr || startDateStr === endDateStr) return `${startMonth} ${startDay}, ${year}`;
const endMonth = end.toLocaleString('en-US', { month: 'long' });
const endDay = end.getDate();
if (startMonth === endMonth) return `${startMonth} ${startDay} - ${endMonth} ${endDay}, ${year}`;
return `${startMonth} ${startDay} - ${endMonth} ${endDay}, ${year}`;
}
function createCardElement(link) {
const workshopStartDate = new Date(link.startDate + 'T00:00:00');
const workshopEndDate = new Date(link.endDate + 'T00:00:00');
const isPastWorkshop = workshopEndDate < today;
const hasNoUrl = (!link.url || link.url === "");
// Determine if this card should have the 'past-no-materials' behavior (permanent graying, MNA overlay)
const applyPastNoMaterialsBehavior = isPastWorkshop && hasNoUrl;
// Determine if this card needs the "Materials Coming Soon" overlay
const applyComingSoonOverlay = !isPastWorkshop && hasNoUrl;
// Apply 'past-no-materials' class for permanent grayscale and potential hover background
const cardClassSuffix = applyPastNoMaterialsBehavior ? ' past-no-materials hover:bg-gray-100' : '';
const card = document.createElement('article');
card.className = `card flex flex-col bg-white rounded-xl shadow-lg overflow-hidden ${cardClassSuffix}`;
card.setAttribute('role', 'group'); // Used for group-hover targeting in CSS
card.dataset.year = JSON.stringify([link.year]);
card.dataset.title = JSON.stringify([link.title]);
card.dataset.tags = JSON.stringify(link.tags);
card.dataset.regions = JSON.stringify(link.regions);
card.dataset.format = JSON.stringify([link.format]);
card.dataset.search = (
link.title + ' ' +
link.tags.join(' ') + ' ' +
(link.locations || []).join(' ') + ' ' +
(link.instructors || []).join(' ')
).toLowerCase();
let statusInfoHTML = '';
let statusTags = [];
// Determine primary workshop status (Happening Now, Upcoming, Past)
if (workshopStartDate <= today && today <= workshopEndDate) {
statusInfoHTML = `
<div class="status-icon-text icon-green mb-2">
<span class="icon-symbol">●</span> <span>Happening Now</span>
</div>`;
statusTags = ["Happening Now"];
} else if (workshopStartDate > today) {
statusInfoHTML = `
<div class="status-icon-text icon-orange mb-2">
<span class="icon-symbol">⏱</span> <span>Upcoming</span>
</div>`;
statusTags = ["Upcoming"];
} else { // Workshop is in the past
statusTags = ["Past"];
}
card.dataset.status = JSON.stringify(statusTags);
const sortedRegions = [...link.regions].sort((a,b) => regionOrder.indexOf(a) - regionOrder.indexOf(b));
const regionTagsHTML = sortedRegions.map(region => {
const borderClass = `border-region-${region.toLowerCase().replace(' ', '-')}`;
const lightBgClass = `bg-region-${region.toLowerCase().replace(' ', '-')}-light`;
// Region tags will be permanently grayscale if applyPastNoMaterialsBehavior is true (CSS handles this)
return `<span class="flex items-center justify-center ${lightBgClass} text-gray-900 border-2 ${borderClass} rounded-full px-3 py-1 text-xs font-bold shadow-sm" title="Region: ${region}">${region}</span>`;
}).join('');
const regionColors = sortedRegions.map(region => tailwind.config.theme.extend.colors[`region-${region.toLowerCase()}`]).filter(Boolean);
let colorBarHTML = '<div class="h-1.5 bg-gray-300"><span class="sr-only">Workshop regions color bar</span></div>';
if (regionColors.length > 1) {
// Color bar will be permanently grayscale if applyPastNoMaterialsBehavior is true (CSS handles this)
colorBarHTML = `<div class="h-1.5" style="background-image: linear-gradient(to right, ${regionColors.join(', ')})"><span class="sr-only">Workshop regions color bar</span></div>`;
} else if (regionColors.length === 1) {
// Color bar will be permanently grayscale if applyPastNoMaterialsBehavior is true (CSS handles this)
colorBarHTML = `<div class="h-1.5" style="background-color: ${regionColors[0]}"><span class="sr-only">Workshop region: ${sortedRegions[0]}</span></div>`;
}
const locationsHTML = (link.locations || []).map(loc => `
<div class="flex items-center text-sm text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-gray-400 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
<span class="font-medium">${loc}</span>
</div>
`).join('');
// Image class: permanent grayscale for past-no-materials
const imageBaseClass = 'w-full h-48 object-cover';
// No hover effect on the image itself, as it's permanently gray for past-no-materials and an overlay for coming soon
const imageHoverEffectClass = applyPastNoMaterialsBehavior ? '' : 'transition-all duration-300'; // No extra hover classes needed here, CSS handles static grayscale.
// No materials status tag for past-no-materials
let materialsStatusTagHTML = '';
let titleAriaLabelSuffix = '';
// Overlay for "Materials Coming Soon" or "Materials Not Available"
let overlayHTML = '';
if (applyComingSoonOverlay) {
overlayHTML = `
<div class="absolute inset-0 flex items-center justify-content-center materials-overlay">
<span class="text-xl font-bold uppercase">Materials Coming Soon</span>
<span class="sr-only"> for ${link.title} workshop</span>
</div>
`;
} else if (applyPastNoMaterialsBehavior) {
overlayHTML = `
<div class="absolute inset-0 flex items-center justify-content-center materials-overlay">
<span class="text-xl font-bold uppercase">Material Not Available</span>
<span class="sr-only"> for ${link.title} workshop</span>
</div>
`;
titleAriaLabelSuffix = ' - Material not available';
}
// Common HTML structure for the card's visual content, regardless of clickability
const commonCardVisuals = `
<div class="relative">
<img loading="lazy" class="${imageBaseClass} ${imageHoverEffectClass}" src="${link.image}" alt="Image for ${link.title} workshop${titleAriaLabelSuffix}" onerror="this.onerror=null;this.src='https://images.unsplash.com/photo-1584824486509-112e4181ff6b?q=80&w=800';">
${overlayHTML}
<div class="absolute top-3 right-3 z-10">
<div class="flex flex-wrap justify-end gap-2 max-w-[calc(100% - 6rem)]">
${regionTagsHTML}
</div>
</div>
</div>
<div class="p-5 flex flex-col flex-grow">
${statusInfoHTML} <div class="min-h-16">
<h3 class="text-lg font-bold ${applyPastNoMaterialsBehavior ? 'text-gray-600' : 'text-gray-800'} truncate-2-lines" ${titleAriaLabelSuffix ? `aria-label="${link.title}${titleAriaLabelSuffix}"` : ''}>
${link.title}
</h3>
</div>
<div class="space-y-2 mt-3">
<div class="flex items-center text-sm text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-gray-400 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
<span class="font-medium">${formatDateRange(link.startDate, link.endDate)}</span>
</div>
${locationsHTML}
</div>
</div>
`;
if (link.url) {
// If URL exists, wrap the entire visual content in an <a> tag
card.innerHTML = `
<a href="${link.url}" target="_blank" rel="noopener noreferrer"
class="card-interactive-wrapper flex flex-col flex-grow transform hover:-translate-y-1 transition-all duration-300 ease-in-out hover:shadow-xl">
${colorBarHTML}
${commonCardVisuals}
<span class="sr-only">View workshop materials for ${link.title} (opens in new tab)</span>
</a>
`;
} else {
// If no URL, provide the content directly within the article
card.classList.add('group'); // Crucial for the `group-hover` effect on the overlay
card.innerHTML = `
${colorBarHTML}
<div class="flex flex-col flex-grow">
${commonCardVisuals}
</div>
`;
}
return card;
}
function generatePageContent() {
const currentAndUpcomingLinks = [];
const pastLinks = [];
for (const link of linksData) {
const workshopEndDate = new Date(link.endDate + 'T00:00:00');
const isPast = workshopEndDate < today;
if (!isPast) currentAndUpcomingLinks.push(link);
else pastLinks.push(link);
}
// Sort current and upcoming workshops by start date
currentAndUpcomingLinks.sort((a, b) => new Date(a.startDate) - new Date(b.startDate));
// Sort past workshops by start date (most recent first)
pastLinks.sort((a, b) => new Date(b.startDate) - new Date(a.startDate));
if (currentAndUpcomingLinks.length > 0) {
const currentSection = document.createElement('section');
currentSection.className = 'year-section';
currentSection.id = 'current-workshops-section';
const currentTitle = document.createElement('h2');
currentTitle.className = 'text-3xl font-bold mb-8 text-gray-800 pl-3 border-l-4 border-green-500';
currentTitle.textContent = 'Happening Now & Upcoming';
const gridContainer = document.createElement('div');
gridContainer.className = 'carousel-on-mobile sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-8';
gridContainer.setAttribute('role', 'region');
gridContainer.setAttribute('aria-label', 'List of Upcoming and Happening Now Workshops');
currentAndUpcomingLinks.forEach(link => gridContainer.appendChild(createCardElement(link)));
currentSection.appendChild(currentTitle);
currentSection.appendChild(gridContainer);
linkContainer.insertBefore(currentSection, noResultsMessage);
}
const pastLinksByYear = pastLinks.reduce((acc, link) => { (acc[link.year] = acc[link.year] || []).push(link); return acc; }, {});
const sortedYears = Object.keys(pastLinksByYear).sort((a, b) => b - a); // Sort years descending
let firstPastSectionAssigned = false;
sortedYears.forEach(year => {
const yearSection = document.createElement('section');
yearSection.className = 'year-section';
if (!firstPastSectionAssigned) { yearSection.id = 'past-workshops-section'; firstPastSectionAssigned = true; }
const yearTitle = document.createElement('h2');
yearTitle.className = 'text-3xl font-bold mb-8 text-gray-800 pl-3 border-l-4 border-brand-purple';
yearTitle.textContent = `${year}`;
const gridContainer = document.createElement('div');
gridContainer.className = 'carousel-on-mobile sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-8';
gridContainer.setAttribute('role', 'region');
gridContainer.setAttribute('aria-label', `List of Past Workshops from ${year}`);
pastLinksByYear[year].forEach(link => gridContainer.appendChild(createCardElement(link)));
yearSection.appendChild(yearTitle);
yearSection.appendChild(gridContainer);
linkContainer.insertBefore(yearSection, noResultsMessage);
});
}
function updateFilterCounts() {
for (const type in allFilters) {
// Defensive check to ensure allFilters[type] and allFilters[type].active exist and is a Set
if (allFilters[type] && allFilters[type].active instanceof Set) {
const count = allFilters[type].active.size;
const countEl = document.getElementById(`${type}-filter-count`);
if(countEl) {
countEl.textContent = count;
countEl.classList.toggle('hidden', count === 0);
const button = countEl.closest('.filter-button');
if (button) {
if (count > 0) {
button.setAttribute('aria-label', `${allFilters[type].label} filter active, ${count} selected`);
} else {
button.setAttribute('aria-label', `${allFilters[type].label} filter`);
}
}
}
} else {
// Log a detailed error to help diagnose which filter type is problematic
console.error(`Error: Filter type '${type}' or its 'active' property is not a Set. Current state for this filter:`, allFilters[type]);
}
}
}
function applyFilters() {
const searchTerm = searchInput.value.toLowerCase().trim();
let totalVisibleCards = 0;
noResultsMessage.classList.add('hidden');
noResultsMessage.setAttribute('aria-live', 'off');
document.querySelectorAll('.card').forEach(card => {
const searchMatch = !searchTerm || card.dataset.search.includes(searchTerm);
let filtersMatch = true;
for (const type in allFilters) {
if (allFilters[type].active.size === 0) continue;
const cardValues = new Set(JSON.parse(card.dataset[type] || '[]').map(String));
if (![...allFilters[type].active].some(filterValue => cardValues.has(filterValue))) {
filtersMatch = false;
break;
}
}
if (searchMatch && filtersMatch) {
card.classList.remove('hidden');
totalVisibleCards++;
} else {
card.classList.add('hidden');
}
});
document.querySelectorAll('.year-section').forEach(section => {
const visibleCards = section.querySelectorAll('.card:not(.hidden)').length;
section.classList.toggle('hidden', visibleCards === 0);
});
if (totalVisibleCards === 0) {
noResultsMessage.classList.remove('hidden');
noResultsMessage.setAttribute('aria-live', 'polite');
} else {
noResultsMessage.setAttribute('aria-live', 'off');
}
updateFilterCounts();
}
function generateFilterOptions() {
const options = {
year: [...new Set(linksData.map(link => link.year))].sort((a, b) => b - a),
regions: regionOrder,
title: [...new Set(linksData.map(link => link.title))].sort(),
tags: [...new Set(linksData.flatMap(link => link.tags))].sort(),
format: [...new Set(linksData.map(link => link.format))].sort(),
status: ["Upcoming", "Happening Now", "Past"]
};
for (const type in allFilters) {
if (options[type] && options[type].length > 0) {
const dropdown = document.createElement('div');
dropdown.className = 'relative';
const dropdownButtonId = `filter-button-${type}`;
const dropdownPanelId = `filter-panel-${type}`;
const dropdownPanel = document.createElement('div');
dropdownPanel.className = 'dropdown-panel hidden absolute z-10 mt-2 w-56 bg-white rounded-md shadow-2xl border border-gray-200/80 origin-top-right right-0 max-h-60 overflow-y-auto';
dropdownPanel.setAttribute('role', 'listbox');
dropdownPanel.setAttribute('id', dropdownPanelId);
dropdownPanel.setAttribute('aria-labelledby', dropdownButtonId);
const checkboxContainer = document.createElement('div');
checkboxContainer.className = 'p-2 space-y-1';
options[type].forEach(value => {
const optionId = `filter-${type}-${String(value).replace(/\s+/g, '-')}`;
const label = document.createElement('label');
label.className = 'flex items-center space-x-3 p-2 hover:bg-slate-100 rounded-md cursor-pointer';
label.setAttribute('for', optionId);
label.innerHTML = `
<input type="checkbox" id="${optionId}" data-type="${type}" value="${value}"
class="h-4 w-4 rounded border-gray-300 text-brand-purple focus:ring-brand-purple/50">
<span class="text-sm text-gray-700 font-medium">${value}</span>
`;
checkboxContainer.appendChild(label);
});
dropdownPanel.appendChild(checkboxContainer);
dropdown.innerHTML = `
<button id="${dropdownButtonId}" class="filter-button bg-white hover:bg-gray-50 text-gray-700 font-semibold py-2.5 px-5 border border-gray-300 rounded-lg shadow-sm flex items-center transition-all duration-200"
aria-haspopup="listbox" aria-expanded="false" aria-controls="${dropdownPanelId}">
<span>${allFilters[type].label}</span>
<span id="${type}-filter-count" class="ml-2 bg-brand-purple text-white text-xs font-bold rounded-full h-5 w-5 flex items-center justify-center hidden">0</span>
<svg class="dropdown-arrow w-4 h-4 ml-2 text-gray-500 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path></svg>
</button>`;
dropdown.appendChild(dropdownPanel);
filterBar.appendChild(dropdown);
allFilters[type].container = checkboxContainer;
}
}
const resetButton = document.createElement('button');
resetButton.id = 'reset-filters-button';
resetButton.className = 'bg-gray-600 hover:bg-gray-700 text-white font-semibold py-2.5 px-5 rounded-lg shadow-sm flex items-center transition-all duration-200';
resetButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h5M20 20v-5h-5M4 9a9 9 0 0114.12-5.12M20 15a9 9 0 01-14.12 5.12" /></svg>Reset Filters`;
filterBar.appendChild(resetButton);
}
function setupInteraction() {
filterBar.addEventListener('click', e => {
const button = e.target.closest('.filter-button');
if (button) {
const panel = button.nextElementSibling;
const isExpanded = button.getAttribute('aria-expanded') === 'true';
document.querySelectorAll('.dropdown-panel').forEach(p => {
p.classList.add('hidden');
p.previousElementSibling.setAttribute('aria-expanded', 'false');
});
if (!isExpanded) {
panel.classList.remove('hidden');
button.setAttribute('aria-expanded', 'true');
} else {
panel.classList.add('hidden');
button.setAttribute('aria-expanded', 'false');
}
return;
}
if (e.target.type === 'checkbox') {
const type = e.target.dataset.type;
const value = e.target.value;
if (e.target.checked) allFilters[type].active.add(value);
else allFilters[type].active.delete(value);
applyFilters();
return;
}
if(e.target.closest('#reset-filters-button')) {
searchInput.value = '';
document.querySelectorAll('input[type="checkbox"]').forEach(cb => cb.checked = false);
for (const type in allFilters) allFilters[type].active.clear();
applyFilters();
const liveRegion = document.createElement('div');
liveRegion.setAttribute('aria-live', 'polite');
liveRegion.classList.add('sr-only');
liveRegion.textContent = 'All filters reset.';
document.body.appendChild(liveRegion);
setTimeout(() => liveRegion.remove(), 1000);
}
});
document.addEventListener('click', e => {
if (!e.target.closest('.relative') && !e.target.closest('.dropdown-panel')) {
document.querySelectorAll('.dropdown-panel').forEach(p => {
p.classList.add('hidden');
p.previousElementSibling.setAttribute('aria-expanded', 'false');
});
}
});
document.addEventListener('keydown', e => {
if (e.key === 'Escape') {
document.querySelectorAll('.dropdown-panel').forEach(p => {
p.classList.add('hidden');
p.previousElementSibling.setAttribute('aria-expanded', 'false');
});
}
});
searchInput.addEventListener('input', applyFilters);
}
generatePageContent();
generateFilterOptions();
setupInteraction();
updateFilterCounts();
} catch (error) {
console.error("Could not initialize the app:", error);
document.body.innerHTML = `<div class="text-center p-8"><h2 class="text-xl font-bold text-red-700">A critical error occurred.</h2><p class="mt-2 text-red-500">Could not load or render workshops. Please check the browser console for details.</p></div>`;
}
});
</script>
<style>
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
</style>
</body>
</html>