feat(ui): render the Scene panel's shot list and scene options as components

SceneShotList and SceneOptions render the project from a gev-scenes
store instead of scenePresentation building rows with createElement.
SceneControls stays the owner: it publishes the director's state and
attaches the row actions, and a late destroy cannot detach a newer
owner. Rows keep their identity across selection; a rename keeps its
typed text across republishing and ends with its row. The select still
changes its choice only when its options are rendered.

Vue keeps whitespace in every component, so Prettier formats single-file
components with strict whitespace sensitivity, and the test loader parses
templates with the same options as the browser build. The i18n check
reads view text without its interpolations, whose t() calls are scanned
with the sources.
This commit is contained in:
Sameh Khamis committed 2026-10-30 18:13:11 -07:00
1 parent 6802c9c8b0
commit d9fdcfc641
13 files changed
+518 -306

No files matched your search

+26 -125
View File
@@ -1,6 +1,6 @@
/** Scene panel elements and text-only project presentation. */
/** Scene panel elements and text-only project presentation; the shot list
* and scene options are the SceneShotList and SceneOptions views. */
import { formatNumber, msg, t } from '../i18n/index.js';
import { createActionButton } from './actionButton.js';
// Labels for what a shot stores; anything else shows as stored. Style names
// match STYLE_STATUS_LABELS in visualPresets.js, which this package cannot
@@ -29,7 +29,6 @@ export function sceneElements(root = document) {
delete: 'scene-delete-btn',
capture: 'scene-capture-btn',
update: 'scene-update-shot-btn',
shots: 'scene-shot-list',
start: 'scene-start-btn',
stop: 'scene-stop-btn',
next: 'scene-next-btn',
@@ -46,129 +45,31 @@ export function sceneElements(root = document) {
);
}
export function renderSceneOptions(element, { scenes, selectedSceneId }) {
if (!element) return;
element.textContent = '';
for (const scene of scenes) {
const option = document.createElement('option');
option.value = scene.id;
option.textContent = scene.title;
element.appendChild(option);
}
if (selectedSceneId) element.value = selectedSceneId;
}
export function renderSceneShots(
element,
state,
{ listen, select, rename, load, remove },
) {
if (!element) return;
const scene = state.scenes.find((item) => item.id === state.selectedSceneId);
element.textContent = '';
if (!scene || scene.shots.length === 0) {
const empty = document.createElement('div');
empty.className = 'scene-shot-empty';
empty.textContent = t(
'No shots yet. Use CAPTURE SHOT to save current look.',
);
element.appendChild(empty);
return;
}
for (const shot of scene.shots) {
// Built-in titles arrive localized as displayTitle; the stored title
// stays English, so a rename happens only when the shown text changes.
const shownTitle = shot.displayTitle || shot.title;
const row = document.createElement('div');
row.className = 'scene-shot-row';
row.dataset.sceneShotId = shot.id;
row.classList.toggle('active', shot.id === state.selectedShotId);
const top = document.createElement('div');
top.className = 'scene-shot-top';
const label = document.createElement('div');
label.className = 'scene-shot-label';
label.textContent = shownTitle;
label.title = t('Double-click to rename');
listen(label, 'click', () => select(shot.id));
listen(label, 'dblclick', () => {
if (label.children.length) return;
const input = document.createElement('input');
input.type = 'text';
input.className = 'scene-shot-rename';
input.setAttribute('aria-label', t('Shot name'));
input.value = shownTitle;
let finished = false;
const finish = (save) => {
if (finished) return;
finished = true;
const title = input.value.trim();
label.textContent = shownTitle;
if (save && title && title !== shownTitle)
rename(scene.id, shot.id, title);
};
listen(input, 'keydown', (event) => {
event.stopPropagation();
if (event.key === 'Enter' || event.key === 'Escape') {
event.preventDefault();
finish(event.key === 'Enter');
}
});
listen(input, 'blur', () => finish(true));
label.textContent = '';
label.appendChild(input);
input.focus();
input.select();
/**
* A shot's summary line: its style, detection mode and timing.
* @param {object} shot
* @returns {string}
*/
export function describeShot(shot) {
const mode = shot.visual?.detection?.mode || 'OFF';
const style = shot.visual?.style || 'normal';
const styleLabel = STYLE_LABELS[style]
? t(STYLE_LABELS[style])
: style.toUpperCase();
const modeLabel = DETECTION_MODE_LABELS[mode]
? t(DETECTION_MODE_LABELS[mode])
: mode;
const seconds = (value) =>
formatNumber(value, {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
const actions = document.createElement('div');
actions.className = 'scene-shot-actions';
const loadButton = createActionButton({
label: t('LOAD'),
className: 'scene-shot-btn',
size: 'compact',
});
listen(loadButton, 'click', () => load(scene.id, shot.id));
const deleteButton = createActionButton({
label: t('DEL'),
className: 'scene-shot-btn scene-shot-danger',
size: 'compact',
variant: 'danger',
});
listen(deleteButton, 'click', () => remove(scene.id, shot.id));
actions.appendChild(loadButton);
actions.appendChild(deleteButton);
top.appendChild(label);
top.appendChild(actions);
const meta = document.createElement('div');
meta.className = 'scene-shot-meta';
const mode = shot.visual?.detection?.mode || 'OFF';
const style = shot.visual?.style || 'normal';
const styleLabel = STYLE_LABELS[style]
? t(STYLE_LABELS[style])
: style.toUpperCase();
const modeLabel = DETECTION_MODE_LABELS[mode]
? t(DETECTION_MODE_LABELS[mode])
: mode;
const seconds = (value) =>
formatNumber(value, {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
// English keeps its compact "4.0s + 0.9s"; other languages space the unit.
const timing = t('{duration}s + {hold}s', {
duration: seconds(shot.durationSec),
hold: seconds(shot.holdSec),
});
meta.textContent = `${styleLabel} · ${modeLabel} · ${timing}`;
row.appendChild(top);
row.appendChild(meta);
element.appendChild(row);
}
}
export function presentSceneSelection(element, selectedShotId) {
for (const row of element?.children || []) {
row.classList.toggle('active', row.dataset.sceneShotId === selectedShotId);
}
// English keeps its compact "4.0s + 0.9s"; other languages space the unit.
const timing = t('{duration}s + {hold}s', {
duration: seconds(shot.durationSec),
hold: seconds(shot.holdSec),
});
return `${styleLabel} · ${modeLabel} · ${timing}`;
}
/**