Files
feedBack/static/v3/onboarding-tour.js
T
612b1f2e0d
ship-ci / ci (push) Waiting to run
feat(v3): choose handedness in the instrument selector + onboarding (give lefties a break) (#793)
* feat(v3): add a handedness (left-handed) choice to the instrument selector + onboarding

Left-handed players could already mirror the highway, but only via a buried
Settings toggle they had to find AFTER setup -- so a lefty went through the tour,
the tuner and calibration all right-handed first (community callout).

Add a "Handedness: Right / Left" row to the v3 instrument badge popover, alongside
Instrument / Strings / Tuning (all player-orientation choices). It writes the same
lefty preference -- highway.setLefty when a live highway exists (flips it
immediately + persists), else the 'lefty' localStorage key the highway reads on
init -- and keeps the Settings "Left-handed" checkbox in sync. The first-run
tour's "Choose your instrument" step, which runs before the tuner/audio-
calibration steps, now calls it out so lefties flip it up front.

Frontend-only, additive. Full core JS suite green (938). Tests:
tests/js/badges_handedness.test.js.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UR2Cr7GEu3yMY7SrfxH6c1

* docs: split the spliced Handedness/Colorblind CHANGELOG entries

A rebase pasted the Handedness bullet over the Colorblind preset entry's bold
lead, merging two unrelated Added entries into one run-on bullet. Restore them
as two separate bullets.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: byrongamatos <xasiklas@gmail.com>
2026-07-05 23:50:30 +02:00

145 lines
7.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* fee[dB]ack v0.3.0 — first-run home tour.
*
* Registers a spotlight tour over the home-page cards with the shared tour
* engine (window.feedBackTour / Shepherd) and auto-runs it once, the first
* time the user lands on the home page after completing onboarding. It stays
* replayable forever from the per-screen "?" tour menu (registered with
* screens: ['v3-home']).
*
* Anchors (all stable, on-screen while #v3-home is active):
* #v3-hero hero / Start Playing (dashboard.js)
* [data-tour="continue"] continue / pick a song (dashboard.js, 3 variants)
* #v3-instrument-wrap instrument selector badge (badges.js, topbar)
* #v3-tuner-wrap tuner badge (badges.js, topbar)
* #v3-audio-routing audio routing card (dashboard.js)
* [data-v3-open-profile] profile badge (profile.js, topbar)
* #v3-nav left sidebar navigation (index.html)
*/
(function () {
'use strict';
var TOUR_ID = 'home-onboarding';
// Each step dims the page and spotlights one element (shape: 'spotlight').
// waitFor blocks the step until its target exists, so the async dashboard
// re-render kicked off by 'v3:profile-updated' can't race the first step.
function buildSteps() {
return [
{
id: 'hero', shape: 'spotlight', position: 'bottom',
selector: '#v3-hero', waitFor: '#v3-hero',
title: 'Welcome to fee[dB]ack',
content: 'This is your home base. Hit Start Playing to drop straight into a song from your library.',
},
{
id: 'continue', shape: 'spotlight', position: 'left',
selector: '[data-tour="continue"]', waitFor: '[data-tour="continue"]',
title: 'Pick up where you left off',
content: 'Your last song resumes right here in one click. Before youve played anything, its a quick random pick to get you going.',
},
{
id: 'instrument', shape: 'spotlight', position: 'bottom',
selector: '#v3-instrument-wrap', waitFor: '#v3-instrument-wrap',
title: 'Choose your instrument',
content: 'Set your instrument, string count and tuning here — and if you play left-handed, flip Handedness to Left so the whole highway mirrors. The highway, tuner and scoring all adapt to this selection.',
},
{
id: 'tuner', shape: 'spotlight', position: 'bottom',
selector: '#v3-tuner-wrap', waitFor: '#v3-tuner-wrap',
title: 'Tune up first',
content: 'Open the tuner and match each string until the meter centers — accurate tuning means accurate scoring.',
},
{
id: 'audio', shape: 'spotlight', position: 'top',
selector: '#v3-audio-routing', waitFor: '#v3-audio-routing',
title: 'Your signal path',
content: 'Input → amp / NAM / IR → output, at a glance. Set up and monitor your gear from this card.',
},
{
id: 'profile', shape: 'spotlight', position: 'bottom',
selector: '[data-v3-open-profile]', waitFor: '[data-v3-open-profile]',
title: 'Track your progress',
content: 'Your profile, avatar and rank live here. Watch your accuracy climb and level up as you play.',
},
{
id: 'nav', shape: 'spotlight', position: 'right',
selector: '#v3-nav', waitFor: '#v3-nav',
title: 'Find everything here',
content: 'Browse your full library, lessons and plugins anytime. You can replay this tour from the ? button in the corner.',
},
];
}
function register() {
var t = window.feedBackTour;
if (!t || typeof t.register !== 'function') return false;
t.register(TOUR_ID, {
name: 'Welcome tour', // label in the "?" tour menu
screens: ['v3-home'], // relevant only on the home screen
autoPrompt: false, // we auto-run it from onboarding; no toast nag
buildSteps: buildSteps,
});
return true;
}
// Auto-run once after a genuine onboarding completion. profile.js gates the
// call on !editing (a profile edit must not relaunch it); we additionally
// honour the engine's own seen/dismissed state so it never repeats and a
// dismissal isn't nagged. Stays replayable from the "?" menu either way.
function startFirstRun() {
var t = window.feedBackTour;
if (!t || typeof t.start !== 'function') return;
try {
if (t.hasSeen(TOUR_ID) || t.hasDismissed(TOUR_ID)) return;
} catch (e) { /* private mode — fall through and attempt once */ }
// Make sure the home screen is in view so the spotlight targets exist.
if (typeof window.showScreen === 'function') {
try { window.showScreen('v3-home'); } catch (e) { /* best-effort */ }
}
// Wait for the dashboard to finish (re)rendering #v3-home before
// attaching Shepherd. Starting after a single animation frame can latch
// onto the pre-render #v3-hero / [data-tour] nodes that the async render
// then replaces, breaking the tour. Listen for the render-complete
// event; fall back on a timeout in case the render already finished
// (no event coming) or never fires.
var started = false;
var go = function () {
if (started) return;
started = true;
try { document.removeEventListener('v3:dashboard-rendered', go); } catch (e) { /* */ }
try { t.start(TOUR_ID); } catch (e) { /* degrade */ }
};
try { document.addEventListener('v3:dashboard-rendered', go, { once: true }); } catch (e) { /* */ }
setTimeout(go, 1200);
}
// Onboarding paths that navigate straight to the player ("Play it now")
// can't start the tour immediately — there is no home screen to spotlight
// yet. Arm it to run the first time the user lands back on v3-home.
function armPendingFirstRun() {
var t = window.feedBackTour;
if (!t || typeof t.start !== 'function') return;
try {
if (t.hasSeen(TOUR_ID) || t.hasDismissed(TOUR_ID)) return;
} catch (e) { /* private mode — fall through */ }
var sm = window.feedBack;
if (!sm || typeof sm.on !== 'function') return;
var onScreen = function (e) {
if (!(e && e.detail && e.detail.id === 'v3-home')) return;
try { if (typeof sm.off === 'function') sm.off('screen:changed', onScreen); } catch (_) { /* */ }
startFirstRun();
};
sm.on('screen:changed', onScreen);
}
window.v3OnboardingTour = { startFirstRun: startFirstRun, armPendingFirstRun: armPendingFirstRun };
// tour-engine.js assigns window.feedBackTour at script-eval time, so if it
// is loaded before us register() succeeds immediately; otherwise retry once
// the DOM (and the engine) are ready.
if (!register()) {
document.addEventListener('DOMContentLoaded', register, { once: true });
}
})();