Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions site/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
}
var hasProgress = !!window.AIFSProgress;
var html = '';
var nextMarked = false;
grid.classList.add('phase-cards');
for (var i = 0; i < PHASES.length; i++) {
var p = PHASES[i];
var total = p.lessons.length;
Expand All @@ -151,13 +153,25 @@
}
var count = done > 0 ? done + ' / ' + total : total + (total === 1 ? ' lesson' : ' lessons');
var statusClass = escapeHtml(String(p.status || 'planned').replace(/ /g, '-'));
var roman = toRoman(p.id);
var num = String(p.id).padStart(2, '0');
html += '<div class="toc-row" data-phase="' + i + '" role="button" tabindex="0" aria-haspopup="dialog" aria-label="Open Phase ' + num + ': ' + escapeHtml(p.name) + '">';
html += '<span class="toc-num" dir="ltr">' + roman + '.</span>';
html += '<div><span class="toc-status ' + statusClass + '"></span><span class="toc-name">' + escapeHtml(p.name) + '</span></div>';
html += '<span class="toc-meta">' + count + '</span>';
html += '<span class="toc-meta">' + num + '</span>';
var finished = total > 0 && done >= total;
var isNext = !finished && !nextMarked && total > 0;
if (isNext) nextMarked = true;
var action = 'Not started';
if (finished) action = 'Done';
else if (done > 0) action = 'Continue';
else if (isNext) action = 'Start here';
var percent = total > 0 ? Math.round(done / total * 100) : 0;
var cardClass = 'phase-card';
if (isNext) cardClass += ' is-next';
if (done > 0 && !finished) cardClass += ' is-started';
if (finished) cardClass += ' is-done';
html += '<div class="' + cardClass + '" data-phase="' + i + '" role="button" tabindex="0" aria-haspopup="dialog" aria-label="Open Phase ' + num + ': ' + escapeHtml(p.name) + '">';
html += '<div class="phase-card-top"><span class="phase-card-num" dir="ltr">Phase ' + num + '</span><span class="toc-status ' + statusClass + '"></span></div>';
html += '<h3 class="phase-card-name">' + escapeHtml(p.name) + '</h3>';
html += '<p class="phase-card-desc">' + escapeHtml(p.desc || '') + '</p>';
html += '<div class="phase-card-bar" aria-hidden="true"><span style="width:' + percent + '%"></span></div>';
html += '<div class="phase-card-foot"><span class="phase-card-count">' + count + '</span><span class="phase-card-action">' + action + '</span></div>';
html += '</div>';
}
grid.innerHTML = html;
Expand Down
41 changes: 39 additions & 2 deletions site/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
var UI_I18N_VERSION = '20261010a';
var STAR_NUDGE_VERSION = '20261013a';
var THEME_MENU_VERSION = '20261029a';
var COMPACT_HEADER_QUERY = '(max-width: 1180px)';
var PRIORITY_LABELS = ['catalog', 'learning paths', 'projects', 'practice', 'interviews'];
var COMPACT_PRIORITY_COUNT = 3;
var TAB_ITEMS = [
{ href: 'catalog.html', label: 'Learn', icon: 'M3 4h7v16H3zM14 4h7v16h-7z' },
{ href: 'learning-paths.html', label: 'Paths', icon: 'M5 19V9M5 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM19 5v10M19 19a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM5 19h8a6 6 0 0 0 6-6' },
{ href: '/practice', label: 'Practice', icon: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8z' },
{ href: 'projects.html', label: 'Projects', icon: 'M4 20l6-6M14 4l6 6-8 8-6-6z' },
{ href: 'roadmap.html', label: 'Progress', icon: 'M4 20V10M10 20V4M16 20v-7M22 20H2' }
];
var navId = 0;

function isStaticPreview(locationValue) {
Expand Down Expand Up @@ -329,7 +339,7 @@
});
routeLinks.forEach(function (link) {
var label = link.textContent.trim().toLowerCase();
if (label !== 'contents' && label !== 'catalog' && label !== 'learning paths') return;
if (PRIORITY_LABELS.indexOf(label) < 0) return;
var marker = document.createComment('header-priority-' + label);
nav.insertBefore(marker, link);
priorityEntries.push({ link: link, marker: marker });
Expand All @@ -352,6 +362,7 @@
return child.classList && child.classList.contains('search-toggle');
});
var narrow = window.matchMedia ? window.matchMedia(NARROW_HEADER_QUERY) : null;
var compact = window.matchMedia ? window.matchMedia(COMPACT_HEADER_QUERY) : null;
var open = false;

function isMovableTool(child) {
Expand All @@ -375,8 +386,11 @@
}

function movePriorityLinksOut() {
var limit = compact && compact.matches ? COMPACT_PRIORITY_COUNT : priorityEntries.length;
for (var i = 0; i < priorityEntries.length; i++) {
priorityNav.appendChild(priorityEntries[i].link);
var entry = priorityEntries[i];
if (i < limit) priorityNav.appendChild(entry.link);
else nav.insertBefore(entry.link, entry.marker.nextSibling);
}
priorityNav.hidden = priorityEntries.length === 0;
}
Expand Down Expand Up @@ -437,6 +451,7 @@
if (typeof narrow.addEventListener === 'function') narrow.addEventListener('change', syncLayout);
else if (typeof narrow.addListener === 'function') narrow.addListener(syncLayout);
}
if (compact && typeof compact.addEventListener === 'function') compact.addEventListener('change', syncLayout);

if (typeof MutationObserver === 'function') {
var observer = new MutationObserver(function (mutations) {
Expand Down Expand Up @@ -535,8 +550,30 @@
});
}

function setupTabBar() {
if (document.querySelector('.site-tabbar') || !document.querySelector('.site-header')) return;
if (document.documentElement.hasAttribute('data-poster') || pageFile(location.href) === 'lesson.html') return;
var bar = document.createElement('nav');
bar.className = 'site-tabbar';
bar.setAttribute('aria-label', 'Sections');
var current = pageFile(location.href);
var html = '';
for (var i = 0; i < TAB_ITEMS.length; i++) {
var item = TAB_ITEMS[i];
var active = pageFile(item.href) === current || (item.href.charAt(0) === '/' && location.pathname.indexOf(item.href) === 0);
html += '<a href="' + item.href + '"' + (active ? ' aria-current="page"' : '') + '>'
+ '<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" aria-hidden="true"><path d="' + item.icon + '"/></svg>'
+ '<span>' + item.label + '</span></a>';
}
bar.innerHTML = html;
adaptRouteTree(bar);
document.body.appendChild(bar);
document.body.classList.add('has-site-tabbar');
}

function load() {
setupBanner();
setupTabBar();
var headers = document.querySelectorAll('.site-header');
for (var i = 0; i < headers.length; i++) setupNavigation(headers[i]);
var footers = document.querySelectorAll('.footer-links');
Expand Down
Loading
Loading