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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// alpine-init.js - Alpine.js initialization and global stores
|
| 2 |
+
// Navigation data is loaded globally in index.html
|
| 3 |
+
|
| 4 |
+
// Alpine.js data stores and components
|
| 5 |
+
document.addEventListener('alpine:init', () => {
|
| 6 |
+
// Use navigation data from global scope
|
| 7 |
+
const navigationAreas = window.navigationAreas || [];
|
| 8 |
+
|
| 9 |
+
// Create a lookup map for easy access by area ID
|
| 10 |
+
const areaTopicsMap = {};
|
| 11 |
+
navigationAreas.forEach(area => {
|
| 12 |
+
areaTopicsMap[area.id] = {
|
| 13 |
+
title: area.navTitle,
|
| 14 |
+
topics: area.topics.map(topic => ({
|
| 15 |
+
id: topic.id,
|
| 16 |
+
name: topic.navName
|
| 17 |
+
}))
|
| 18 |
+
};
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
// Global navigation state
|
| 22 |
+
Alpine.store('navigation', {
|
| 23 |
+
currentArea: null,
|
| 24 |
+
currentTopic: null,
|
| 25 |
+
currentPage: null,
|
| 26 |
+
|
| 27 |
+
setArea(area) {
|
| 28 |
+
this.currentArea = area;
|
| 29 |
+
this.updateTopicNav();
|
| 30 |
+
},
|
| 31 |
+
|
| 32 |
+
setTopic(topic) {
|
| 33 |
+
this.currentTopic = topic;
|
| 34 |
+
this.updateTopicNav();
|
| 35 |
+
},
|
| 36 |
+
|
| 37 |
+
setPage(page) {
|
| 38 |
+
this.currentPage = page;
|
| 39 |
+
this.updateTopicNav();
|
| 40 |
+
},
|
| 41 |
+
|
| 42 |
+
updateTopicNav() {
|
| 43 |
+
// Trigger update in topic navigation component
|
| 44 |
+
if (window.Alpine) {
|
| 45 |
+
const event = new CustomEvent('navigation-updated', {
|
| 46 |
+
detail: {
|
| 47 |
+
area: this.currentArea,
|
| 48 |
+
topic: this.currentTopic,
|
| 49 |
+
page: this.currentPage
|
| 50 |
+
}
|
| 51 |
+
});
|
| 52 |
+
window.dispatchEvent(event);
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
});
|
| 56 |
+
|
| 57 |
+
// Mobile Topic Navigation Component
|
| 58 |
+
// Uses navigation data generated from areas.js
|
| 59 |
+
Alpine.data('mobileTopicNav', () => ({
|
| 60 |
+
areas: navigationAreas.map(area => ({
|
| 61 |
+
id: area.id,
|
| 62 |
+
title: area.navTitle,
|
| 63 |
+
topics: area.topics.map(topic => ({
|
| 64 |
+
id: topic.id,
|
| 65 |
+
name: topic.navName
|
| 66 |
+
}))
|
| 67 |
+
}))
|
| 68 |
+
}));
|
| 69 |
+
|
| 70 |
+
// Home Hover Component
|
| 71 |
+
Alpine.data('homeHover', () => ({
|
| 72 |
+
homeHovered: false,
|
| 73 |
+
|
| 74 |
+
setHomeHover(state) {
|
| 75 |
+
this.homeHovered = state;
|
| 76 |
+
window.dispatchEvent(new CustomEvent('home-hovered', { detail: { hovered: state } }));
|
| 77 |
+
}
|
| 78 |
+
}));
|
| 79 |
+
|
| 80 |
+
// Area Hover Component (for showing topics on hover)
|
| 81 |
+
Alpine.data('areaHover', () => ({
|
| 82 |
+
hoveredArea: null,
|
| 83 |
+
// Make navigation areas available to the template
|
| 84 |
+
areas: navigationAreas,
|
| 85 |
+
|
| 86 |
+
setHover(area) {
|
| 87 |
+
this.hoveredArea = area;
|
| 88 |
+
this.homeHovered = false; // Clear home hover when hovering area
|
| 89 |
+
// Trigger update in topic navigation
|
| 90 |
+
window.dispatchEvent(new CustomEvent('area-hovered', { detail: { area } }));
|
| 91 |
+
window.dispatchEvent(new CustomEvent('home-hovered', { detail: { hovered: false } }));
|
| 92 |
+
},
|
| 93 |
+
|
| 94 |
+
clearAllHover() {
|
| 95 |
+
this.hoveredArea = null;
|
| 96 |
+
this.homeHovered = false;
|
| 97 |
+
window.dispatchEvent(new CustomEvent('area-hovered', { detail: { area: null } }));
|
| 98 |
+
window.dispatchEvent(new CustomEvent('home-hovered', { detail: { hovered: false } }));
|
| 99 |
+
},
|
| 100 |
+
|
| 101 |
+
isActiveArea(area) {
|
| 102 |
+
return window.router && window.router.currentArea === area;
|
| 103 |
+
}
|
| 104 |
+
}));
|
| 105 |
+
|
| 106 |
+
// Sub-Navigation Component (combines Home and Area menus)
|
| 107 |
+
Alpine.data('subNavigation', () => ({
|
| 108 |
+
// Area state
|
| 109 |
+
areaId: null,
|
| 110 |
+
areaTitle: '',
|
| 111 |
+
topics: [],
|
| 112 |
+
currentTopic: null,
|
| 113 |
+
hoveredArea: null,
|
| 114 |
+
|
| 115 |
+
// Home state
|
| 116 |
+
homeHovered: false,
|
| 117 |
+
isHomePage: false,
|
| 118 |
+
|
| 119 |
+
// Computed properties
|
| 120 |
+
get showHomeMenu() {
|
| 121 |
+
// Show home menu if we're hovering over Home OR if we're on the home page
|
| 122 |
+
return this.homeHovered || this.isHomePage;
|
| 123 |
+
},
|
| 124 |
+
|
| 125 |
+
get showAreaMenu() {
|
| 126 |
+
// Show area menu if we're hovering over an area OR if we're on an area page
|
| 127 |
+
// BUT hide if we're showing the home menu
|
| 128 |
+
return (this.areaId !== null || this.hoveredArea !== null) && !this.showHomeMenu;
|
| 129 |
+
},
|
| 130 |
+
|
| 131 |
+
get displayAreaId() {
|
| 132 |
+
return this.hoveredArea || this.areaId;
|
| 133 |
+
},
|
| 134 |
+
|
| 135 |
+
get displayAreaTitle() {
|
| 136 |
+
const area = this.hoveredArea || this.areaId;
|
| 137 |
+
return area && areaTopicsMap[area] ? areaTopicsMap[area].title : '';
|
| 138 |
+
},
|
| 139 |
+
|
| 140 |
+
get displayTopics() {
|
| 141 |
+
const area = this.hoveredArea || this.areaId;
|
| 142 |
+
return area && areaTopicsMap[area] ? areaTopicsMap[area].topics : [];
|
| 143 |
+
},
|
| 144 |
+
|
| 145 |
+
init() {
|
| 146 |
+
// Listen for navigation updates
|
| 147 |
+
window.addEventListener('navigation-updated', (e) => {
|
| 148 |
+
this.updateFromRouter(e.detail.area, e.detail.topic, e.detail.page);
|
| 149 |
+
});
|
| 150 |
+
|
| 151 |
+
// Listen for area hover
|
| 152 |
+
window.addEventListener('area-hovered', (e) => {
|
| 153 |
+
this.hoveredArea = e.detail.area;
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
+
// Listen for home hover
|
| 157 |
+
window.addEventListener('home-hovered', (e) => {
|
| 158 |
+
this.homeHovered = e.detail.hovered;
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
// Initial update from router
|
| 162 |
+
if (window.router) {
|
| 163 |
+
this.updateFromRouter(
|
| 164 |
+
window.router.currentArea,
|
| 165 |
+
window.router.currentTopic,
|
| 166 |
+
window.router.currentPage
|
| 167 |
+
);
|
| 168 |
+
}
|
| 169 |
+
},
|
| 170 |
+
|
| 171 |
+
updateFromRouter(area, topic, page) {
|
| 172 |
+
// Update home page status
|
| 173 |
+
this.isHomePage = page === 'home' && !area;
|
| 174 |
+
|
| 175 |
+
// Update area and topic
|
| 176 |
+
if (area && areaTopicsMap[area]) {
|
| 177 |
+
this.areaId = area;
|
| 178 |
+
this.areaTitle = areaTopicsMap[area].title;
|
| 179 |
+
this.topics = areaTopicsMap[area].topics;
|
| 180 |
+
this.currentTopic = topic || null;
|
| 181 |
+
} else {
|
| 182 |
+
this.areaId = null;
|
| 183 |
+
this.areaTitle = '';
|
| 184 |
+
this.topics = [];
|
| 185 |
+
this.currentTopic = null;
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
}));
|
| 189 |
+
});
|
| 190 |
+
|
js/main.js
CHANGED
|
@@ -26,7 +26,7 @@ export function createTeamMember(name, role, hfUsername, tags) {
|
|
| 26 |
<div class="flex-shrink-0">
|
| 27 |
<div class="w-14 h-14 rounded-full overflow-hidden bg-gradient-to-br from-${color}-400 to-${color}-600 flex items-center justify-center relative">
|
| 28 |
<img
|
| 29 |
-
src="images/${hfUsername}.jpeg"
|
| 30 |
alt="${name}"
|
| 31 |
class="w-full h-full object-cover"
|
| 32 |
onerror="this.style.display='none'; this.nextElementSibling.style.display='flex';"
|
|
@@ -139,72 +139,26 @@ document.addEventListener('DOMContentLoaded', async function() { // Mark as asyn
|
|
| 139 |
// No need to call initializeTeamMembers, initializeHomeAreaCards, etc. here
|
| 140 |
// as they will be called by the router when loading the home page
|
| 141 |
|
| 142 |
-
//
|
| 143 |
const searchToggle = document.getElementById('search-toggle');
|
| 144 |
const searchSidebar = document.getElementById('search-sidebar');
|
| 145 |
const searchClose = document.getElementById('search-close');
|
| 146 |
const mainContent = document.getElementById('main-content');
|
| 147 |
const overlay = document.getElementById('sidebar-overlay');
|
| 148 |
-
// Left sidebar toggle functionality
|
| 149 |
-
const sidebarToggle = document.getElementById('sidebar-toggle');
|
| 150 |
-
const leftSidebar = document.getElementById('left-sidebar');
|
| 151 |
-
const mainContentEl = document.getElementById('main-content');
|
| 152 |
-
const leftSidebarBg = document.getElementById('left-sidebar-background'); // Get the background element
|
| 153 |
-
|
| 154 |
-
function toggleLeftSidebar() {
|
| 155 |
-
const isOpen = !leftSidebar.classList.contains('-translate-x-full');
|
| 156 |
-
|
| 157 |
-
if (isOpen) {
|
| 158 |
-
// Close sidebar
|
| 159 |
-
leftSidebar.classList.add('-translate-x-full');
|
| 160 |
-
mainContentEl.style.marginLeft = '0';
|
| 161 |
-
leftSidebarBg.classList.add('hidden'); // Hide the left sidebar background
|
| 162 |
-
updatePageBackgroundPosition(); // Update page background position immediately on close
|
| 163 |
-
} else {
|
| 164 |
-
// Open sidebar - initially hide its background
|
| 165 |
-
leftSidebarBg.classList.add('hidden'); // Ensure it's hidden before animation starts
|
| 166 |
-
|
| 167 |
-
leftSidebar.classList.remove('-translate-x-full');
|
| 168 |
-
mainContentEl.style.marginLeft = '256px';
|
| 169 |
-
|
| 170 |
-
// Wait for transition to end before updating background position AND showing sidebar background
|
| 171 |
-
const handleTransitionEnd = () => {
|
| 172 |
-
leftSidebarBg.classList.remove('hidden'); // Now show the left sidebar background
|
| 173 |
-
updatePageBackgroundPosition();
|
| 174 |
-
leftSidebar.removeEventListener('transitionend', handleTransitionEnd);
|
| 175 |
-
};
|
| 176 |
-
leftSidebar.addEventListener('transitionend', handleTransitionEnd);
|
| 177 |
-
}
|
| 178 |
-
}
|
| 179 |
-
|
| 180 |
-
if (sidebarToggle) sidebarToggle.addEventListener('click', toggleLeftSidebar)
|
| 181 |
|
| 182 |
function toggleSearch() {
|
| 183 |
const isOpen = !searchSidebar.classList.contains('translate-x-full');
|
| 184 |
-
const leftSidebarOpen = !leftSidebar.classList.contains('-translate-x-full');
|
| 185 |
const rightSidebarBg = document.getElementById('right-sidebar-background');
|
| 186 |
|
| 187 |
if (isOpen) {
|
| 188 |
searchSidebar.classList.add('translate-x-full');
|
| 189 |
rightSidebarBg.classList.add('hidden');
|
| 190 |
-
|
| 191 |
-
mainContent.style.marginLeft = '256px';
|
| 192 |
-
mainContent.classList.remove('mr-80');
|
| 193 |
-
} else {
|
| 194 |
-
mainContent.style.marginLeft = '0';
|
| 195 |
-
mainContent.classList.remove('mr-80');
|
| 196 |
-
}
|
| 197 |
overlay.classList.add('hidden');
|
| 198 |
} else {
|
| 199 |
searchSidebar.classList.remove('translate-x-full');
|
| 200 |
rightSidebarBg.classList.remove('hidden');
|
| 201 |
-
|
| 202 |
-
mainContent.style.marginLeft = '256px';
|
| 203 |
-
mainContent.classList.add('mr-80');
|
| 204 |
-
} else {
|
| 205 |
-
mainContent.style.marginLeft = '0';
|
| 206 |
-
mainContent.classList.add('mr-80');
|
| 207 |
-
}
|
| 208 |
overlay.classList.remove('hidden');
|
| 209 |
}
|
| 210 |
}
|
|
@@ -213,34 +167,4 @@ document.addEventListener('DOMContentLoaded', async function() { // Mark as asyn
|
|
| 213 |
if (searchClose) searchClose.addEventListener('click', toggleSearch);
|
| 214 |
if (overlay) overlay.addEventListener('click', toggleSearch);
|
| 215 |
|
| 216 |
-
// Scroll spy for left navigation
|
| 217 |
-
const sections = document.querySelectorAll('section[id], div[id]');
|
| 218 |
-
const navLinks = document.querySelectorAll('.page-nav-link');
|
| 219 |
-
|
| 220 |
-
function updateActiveNavigation() {
|
| 221 |
-
let current = '';
|
| 222 |
-
const scrollPos = window.scrollY + 150;
|
| 223 |
-
|
| 224 |
-
sections.forEach(section => {
|
| 225 |
-
const sectionTop = section.offsetTop;
|
| 226 |
-
const sectionHeight = section.offsetHeight;
|
| 227 |
-
|
| 228 |
-
if (scrollPos >= sectionTop && scrollPos < sectionTop + sectionHeight) {
|
| 229 |
-
current = section.getAttribute('id');
|
| 230 |
-
}
|
| 231 |
-
});
|
| 232 |
-
|
| 233 |
-
navLinks.forEach(link => {
|
| 234 |
-
link.classList.remove('text-blue-600', 'bg-blue-50');
|
| 235 |
-
link.classList.add('text-gray-700');
|
| 236 |
-
|
| 237 |
-
if (link.getAttribute('href') === `#${current}`) {
|
| 238 |
-
link.classList.remove('text-gray-700');
|
| 239 |
-
link.classList.add('text-blue-600', 'bg-blue-50');
|
| 240 |
-
}
|
| 241 |
-
});
|
| 242 |
-
}
|
| 243 |
-
|
| 244 |
-
window.addEventListener('scroll', updateActiveNavigation);
|
| 245 |
-
updateActiveNavigation(); // Initial call
|
| 246 |
});
|
|
|
|
| 26 |
<div class="flex-shrink-0">
|
| 27 |
<div class="w-14 h-14 rounded-full overflow-hidden bg-gradient-to-br from-${color}-400 to-${color}-600 flex items-center justify-center relative">
|
| 28 |
<img
|
| 29 |
+
src="/images/${hfUsername}.jpeg"
|
| 30 |
alt="${name}"
|
| 31 |
class="w-full h-full object-cover"
|
| 32 |
onerror="this.style.display='none'; this.nextElementSibling.style.display='flex';"
|
|
|
|
| 139 |
// No need to call initializeTeamMembers, initializeHomeAreaCards, etc. here
|
| 140 |
// as they will be called by the router when loading the home page
|
| 141 |
|
| 142 |
+
// Search sidebar toggle functionality
|
| 143 |
const searchToggle = document.getElementById('search-toggle');
|
| 144 |
const searchSidebar = document.getElementById('search-sidebar');
|
| 145 |
const searchClose = document.getElementById('search-close');
|
| 146 |
const mainContent = document.getElementById('main-content');
|
| 147 |
const overlay = document.getElementById('sidebar-overlay');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
function toggleSearch() {
|
| 150 |
const isOpen = !searchSidebar.classList.contains('translate-x-full');
|
|
|
|
| 151 |
const rightSidebarBg = document.getElementById('right-sidebar-background');
|
| 152 |
|
| 153 |
if (isOpen) {
|
| 154 |
searchSidebar.classList.add('translate-x-full');
|
| 155 |
rightSidebarBg.classList.add('hidden');
|
| 156 |
+
mainContent.classList.remove('mr-80');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
overlay.classList.add('hidden');
|
| 158 |
} else {
|
| 159 |
searchSidebar.classList.remove('translate-x-full');
|
| 160 |
rightSidebarBg.classList.remove('hidden');
|
| 161 |
+
mainContent.classList.add('mr-80');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
overlay.classList.remove('hidden');
|
| 163 |
}
|
| 164 |
}
|
|
|
|
| 167 |
if (searchClose) searchClose.addEventListener('click', toggleSearch);
|
| 168 |
if (overlay) overlay.addEventListener('click', toggleSearch);
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
});
|