A UX pass over the workspace, and two defects it turned up
Walking the site as a student (desktop, a phone-width screen, dark) found these. Each is small; together they are what got in the way. Defects: - Opening a problem in the Bridge saved the generated Mojo over the exercise's own program. The workspace fills every pane's editor as it opens, the editor reported that as typing, and the Bridge's read-only Mojo pane holds the generated text. Developer then showed generated Mojo labeled "your edits", and the problem counted as edited. The value setter now marks its change as a load, the change listener leaves loads out, and a Bridge session refuses a Mojo edit. - A page opened at #/#problems or #/#reference stopped about 45px past the heading: the fonts arrived after the place was computed. A page built this moment goes straight to its section and finds it again when the fonts are in; a page already on screen still scrolls there. The workspace: - With no run to step, the Run view said "Nothing to run yet." It and the stepper now give one reason (src/core/norun.ts): how many problems the stepped pane has and the first with its line, with a button to the line and the Problems list; or that the pane is empty. - In the Bridge the dock starts at about a quarter of the height (it holds a call, a line of output, a short list), so the code and the run get the room. Developer keeps a third for the compiler's answer. A double-click on a divider returns to the area's default, not to the student's last position. - The reason a pane is not in step wraps instead of ending in an ellipsis, and a button in the pane's head keeps its words on one line. - A problem that does not exist keeps the site's navigation and links the problem list. - Help, the theme switch and the stepper's first, back, step and last buttons have names a screen reader can say. A phone-width screen: - The toolbar is three rows in every area and on every tab (it was four or five): the mark, the area, help and the theme; the problem, Versions and Reset; the actions. About 30px more of the code shows. An embedded workspace keeps its own toolbar. - The Share dialog puts each row's name above what it holds (a note had been squeezed to a word per line), and the Versions menu opens across the screen instead of running off its right edge. - The stepper's speed label stays with its slider. Checked by hand, in headless Chromium at 1440x900, 1366x768, 390x844 and 320x640, light and dark: each state above before and after; the editor has line numbers and highlighting; the stepper steps; embeds (playground, trace, Developer) are unchanged; 31 smoke scenarios clean but the ones that err on purpose.
This commit is contained in:
14 files changed
+302
-39
No files matched your search
+25
-9
@@ -124,6 +124,13 @@ const LINK_TEXT: Record<'authored' | 'sync' | 'authority', string> = {
|
||||
};
|
||||
|
||||
/** The line comment each pane toggles with Ctrl+/ (Cmd+/). */
|
||||
/**
|
||||
* How much of the workspace's height the code and the inspect panel get before the student moves the divider; the
|
||||
* dock under them gets the rest. In the Bridge the dock holds a call, a line or two of output, or a short list of
|
||||
* problems, so it starts at about a quarter. In Developer it holds the real compiler's answer and its listing, so
|
||||
* it starts at about a third (styles.css has the Bridge's number for the first paint).
|
||||
*/
|
||||
const DEFAULT_DOCK: Partial<Record<AreaId, number>> = { bridge: 0.76, dev: 0.68 };
|
||||
const LINE_COMMENTS: Partial<Record<LangId, string>> = { pseudo: '//', mojo: MOJO_LINE_COMMENT, asm: ';' };
|
||||
|
||||
/** A row's tabs as one tablist with nothing else in it; `display: contents`, so the row lays out as before. */
|
||||
@@ -236,7 +243,7 @@ export class Shell {
|
||||
|
||||
this.main = el('div', { class: 'main' + (this.boardMode ? ' main-board' : '') });
|
||||
const split = splitter({
|
||||
container: this.main, axis: 'x', initial: lay.split ?? (this.boardMode ? 0.46 : 0.54), min: 0.25, max: 0.8,
|
||||
container: this.main, axis: 'x', initial: this.boardMode ? 0.46 : 0.54, start: lay.split, min: 0.25, max: 0.8,
|
||||
apply: (f) => this.main.style.setProperty('--split', `${(f * 100).toFixed(2)}%`),
|
||||
onChange: (f) => session.setLayout({ split: f }),
|
||||
});
|
||||
@@ -248,14 +255,14 @@ export class Shell {
|
||||
if (this.boardMode) add(this.workspace, this.main);
|
||||
else {
|
||||
const dockBar = splitter({
|
||||
container: this.workspace, axis: 'y', initial: lay.dock ?? 0.68, min: 0.3, max: 0.9,
|
||||
container: this.workspace, axis: 'y', initial: DEFAULT_DOCK[area.id] ?? 0.72, start: lay.dock, min: 0.3, max: 0.9,
|
||||
apply: (f) => this.workspace.style.setProperty('--dock', `${(f * 100).toFixed(2)}%`),
|
||||
onChange: (f) => session.setLayout({ dock: f }),
|
||||
});
|
||||
add(this.workspace, this.main, dockBar, this.dock);
|
||||
}
|
||||
this.workspace.dataset.narrow = this.narrow;
|
||||
this.root = el('div', { class: 'shell' }, this.toolbar, this.banner, this.workspace);
|
||||
this.root = el('div', { class: 'shell' + (this.embed ? ' shell-embed' : '') }, this.toolbar, this.banner, this.workspace);
|
||||
this.renderBanner();
|
||||
|
||||
for (const lang of LANG_ORDER) this.editors.set(lang, this.makeEditor(lang));
|
||||
@@ -714,7 +721,11 @@ export class Shell {
|
||||
const hooks = this.hooks();
|
||||
const gotoStep = (t: number) => { this.session.setT(t); this.stepper?.goto(t); this.showInspect('trace'); };
|
||||
switch (view) {
|
||||
case 'trace': this.inspectOff = runView(this.session, host, { goto: (t) => { this.session.setT(t); this.stepper?.goto(t); }, follow: () => this.session.layout().follow ?? null, setFollow: (follow) => this.session.setLayout({ follow }) }); break;
|
||||
case 'trace': this.inspectOff = runView(this.session, host, {
|
||||
goto: (t) => { this.session.setT(t); this.stepper?.goto(t); }, follow: () => this.session.layout().follow ?? null, setFollow: (follow) => this.session.setLayout({ follow }),
|
||||
// the line first, then the list: on a phone-width screen the last one asked for is the part that shows
|
||||
problems: (lang, line) => { if (line) hooks.reveal(lang, line); this.showDock('problems', true); },
|
||||
}); break;
|
||||
case 'proof': this.inspectOff = proofView(this.session, host, hooks); break;
|
||||
case 'tests': this.inspectOff = testsView(this.session, host, { ...hooks, stepThrough: (call) => { this.session.setCall(call); this.renderSetup(); this.stepper?.goto(0); this.showInspect('trace'); } }); break;
|
||||
case 'life': this.inspectOff = lifetimesView(this.session, host, { goto: gotoStep }); break;
|
||||
@@ -800,7 +811,7 @@ export class Shell {
|
||||
const open = el('a', { class: 'brand', href: '#', target: '_blank', rel: 'noopener', title: 'Open this example, as it is now, in Programming+' }, el('span', { class: 'brand-mark' }, 'P+'), 'Programming+ ↗');
|
||||
void encodeState(s).then((blob) => { open.href = `${location.href.split('#')[0]}${routeFor({ kind: 'shared', area: this.area.id, blob })}`; });
|
||||
add(this.toolbar, open, el('span', { class: 'embed-name' }, s.title || PROBLEMS.find((p) => p.id === s.problem)?.title || 'Example'), this.areaSwitch() ?? this.areaName());
|
||||
} else add(this.toolbar, el('a', { class: 'brand', href: '#/' }, el('span', { class: 'brand-mark' }, 'P+'), 'Programming+'), this.areaSwitch() ?? this.areaName(), select, this.versionsControl());
|
||||
} else add(this.toolbar, el('a', { class: 'brand', href: '#/', title: 'Programming+: the home page' }, el('span', { class: 'brand-mark' }, 'P+'), el('span', { class: 'brand-name' }, 'Programming+')), this.areaSwitch() ?? this.areaName(), select, this.versionsControl());
|
||||
const lang = s.lang;
|
||||
const primary = lang === 'mojo'
|
||||
? button(this.session.compiling ? 'Compiling…' : '▶ Compile & run', () => void this.compileNow(), { class: 'btn btn-primary', disabled: !!this.session.compiling, title: `Build and run the Mojo pane with the real Mojo ${MOJO_VERSION} compiler: sends the program and its input to godbolt.org (Ctrl+Enter)` })
|
||||
@@ -811,11 +822,16 @@ export class Shell {
|
||||
button('Share', () => this.share(), { class: 'btn', title: 'Link, embed code, or a file' }),
|
||||
this.embed ? null : button('Open…', () => this.openFile(), { class: 'btn', title: 'Load a saved .pplus.json file' }),
|
||||
this.embed ? (this.embed.reset && this.embed.edited?.() ? button('Reset', () => { if (confirm('Discard your changes to this example and show the original again?')) this.embed!.reset!(); }, { class: 'btn btn-quiet', title: 'Your changes here are saved in this browser. Reset shows the original example again.' }) : null) :
|
||||
s.problem ? button('Reset', () => this.resetProblem(), { class: 'btn btn-quiet', title: 'Show the problem as written. Your work is saved as a version first, so Reset can be undone from the Versions menu.' }) : null,
|
||||
s.problem ? button('Reset', () => this.resetProblem(), { class: 'btn btn-quiet tool-reset', title: 'Show the problem as written. Your work is saved as a version first, so Reset can be undone from the Versions menu.' }) : null,
|
||||
!this.embed && (PRACTICE_AREAS as readonly string[]).includes(this.area.id)
|
||||
? button(practicesOn(this.area.id) ? 'Best practices: on' : 'Best practices: off', () => setPracticesOn(this.area.id, !practicesOn(this.area.id)), { class: `btn btn-quiet${practicesOn(this.area.id) ? ' btn-on' : ''}`, 'aria-pressed': practicesOn(this.area.id), title: 'Notes on how a Mojo programmer would write the Mojo here. Off until you turn it on; each area remembers its own choice in this browser.' }) : null,
|
||||
button('?', () => this.helpDialog(), { class: 'btn btn-quiet icon-btn', title: 'Keyboard shortcuts and how the panes fit together' }),
|
||||
button(effectiveTheme() === 'dark' ? '☀' : '☾', (e) => { cycleTheme(); (e.target as HTMLButtonElement).textContent = effectiveTheme() === 'dark' ? '☀' : '☾'; }, { class: 'btn btn-quiet icon-btn', title: 'Switch between light and dark' }),
|
||||
? (() => {
|
||||
// a toggle: its name is what it switches (aria-pressed says which way), and a small phone gets the short form
|
||||
const b = button('', () => setPracticesOn(this.area.id, !practicesOn(this.area.id)), { class: `btn btn-quiet tool-practices${practicesOn(this.area.id) ? ' btn-on' : ''}`, 'aria-label': 'Best practices', 'aria-pressed': practicesOn(this.area.id), title: 'Notes on how a Mojo programmer would write the Mojo here. Off until you turn it on; each area remembers its own choice in this browser.' });
|
||||
add(b, el('span', { class: 'tool-wide' }, 'Best practices'), el('span', { class: 'tool-tight' }, 'Practices'), practicesOn(this.area.id) ? ': on' : ': off');
|
||||
return b;
|
||||
})() : null,
|
||||
button('?', () => this.helpDialog(), { class: 'btn btn-quiet icon-btn tool-help', 'aria-label': 'Help: keyboard shortcuts and how the panes fit together', title: 'Keyboard shortcuts and how the panes fit together' }),
|
||||
button(effectiveTheme() === 'dark' ? '☀' : '☾', (e) => { cycleTheme(); (e.target as HTMLButtonElement).textContent = effectiveTheme() === 'dark' ? '☀' : '☾'; }, { class: 'btn btn-quiet icon-btn', 'aria-label': 'Switch between light and dark', title: 'Switch between light and dark' }),
|
||||
this.narrowBar,
|
||||
);
|
||||
this.renderNarrowBar();
|
||||
|
||||
Reference in new issue
Block a user