Skip to content

Commit 61b6122

Browse files
Update lesson view
1 parent 877598b commit 61b6122

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

production/skilljar-theme-v3.0/views/lesson.mjs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ function setupLessonNav() {
343343
textContent: "← Previous",
344344
title: attrs.prev.title,
345345
onclick: (e) => e.stopPropagation(),
346+
dataset: { trackClick: attrs.prev.track || "" }, // TODO: keep an eye on this
346347
});
347-
if (attrs.prev.track) prevBtn.setAttribute("data-track-click", attrs.prev.track);
348348

349349
const nextBtn = el("a", {
350350
className: "lesson-btn next",
@@ -356,8 +356,18 @@ function setupLessonNav() {
356356
title: attrs.next.title,
357357
tabindex: 0,
358358
onclick: (e) => e.stopPropagation(),
359+
dataset: { trackClick: attrs.next.track || "" }, // TODO: keep an eye on this
360+
on: {
361+
click: (e) => goNext(e),
362+
mouseup: (e) => goNext(e),
363+
keydown: (e) => {
364+
const k = e.key;
365+
if (k === "Enter" || k === " " || k === "Spacebar" || k === "ArrowRight") {
366+
goNext(e);
367+
}
368+
},
369+
}
359370
});
360-
if (attrs.next.track) nextBtn.setAttribute("data-track-click", attrs.next.track);
361371

362372
// Add behavior: call onNextLessonClick just like Skilljar
363373
function goNext(e) {
@@ -369,31 +379,20 @@ function setupLessonNav() {
369379
window.location.href = attrs.next.href;
370380
}
371381
}
372-
nextBtn.addEventListener("click", goNext);
373-
nextBtn.addEventListener("mouseup", goNext);
374-
nextBtn.addEventListener("keydown", (e) => {
375-
const k = e.key;
376-
if (k === "Enter" || k === " " || k === "Spacebar" || k === "ArrowRight") {
377-
goNext(e);
378-
}
379-
});
380382

381383
// Disable/hide if missing
382384
if (!elems.footer.prev || !attrs.prev.href) {
383-
prevBtn.style.display = "none";
385+
setStyle(prevBtn, { display: "none" });
384386
}
385387
if (!elems.footer.next || !attrs.next.href) {
386-
nextBtn.style.display = "none";
388+
setStyle(nextBtn, { display: "none" });
387389
}
388390

389-
// 6) Build wrapper
390-
const btnWrapper = el("nav", {
391+
return el("nav", {
391392
className: "lesson-floater",
392393
role: "navigation",
393-
ariaLabel: "Lesson navigation",
394+
aria: { label: "Lesson navigation" },
394395
}, [prevBtn, nextBtn]);
395-
396-
return btnWrapper;
397396
}
398397

399398
/**
@@ -486,15 +485,20 @@ export function lessonView() {
486485

487486
// Build the nav toggle bar: use Skilljar's if present, otherwise create our own
488487
if (!CG.dom.local.nav.toggleWrapper) {
489-
const navBar = el("a", { id: "left-nav-button", href: "#" }, [
488+
const navBar = el("a", {
489+
id: "left-nav-button", href: "#", aria: {
490+
label: "Toggle course navigation",
491+
on: {
492+
click: (e) => {
493+
e.preventDefault();
494+
document.body.classList.toggle("cbp-spmenu-open");
495+
}
496+
}
497+
}
498+
}, [
490499
el("i", { className: "fa fa-bars" }),
491500
el("i", { className: "fa fa-times" }),
492501
]);
493-
navBar.setAttribute("aria-label", "Toggle course navigation");
494-
navBar.addEventListener("click", (e) => {
495-
e.preventDefault();
496-
document.body.classList.toggle("cbp-spmenu-open");
497-
});
498502
CG.dom.local.nav.toggleWrapper = navBar;
499503
}
500504

@@ -604,7 +608,7 @@ function buildNavCourseLink() {
604608
const href = CG.dom.local.nav.backBtn?.href;
605609
if (!title || !href) return;
606610

607-
const link = el("a", { className: "nav-course-link", href: sanitizeUrl(href) }, [
611+
const link = el("a", { className: "nav-course-link", href: sanitizeUrl(href), aria: { label: "Back to Course Description" } }, [
608612
el("span", { className: "nav-course-link-arrow", textContent: "←" }),
609613
el("span", { className: "nav-course-link-title", textContent: title }),
610614
]);

0 commit comments

Comments
 (0)