Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 3efe3a4dca37eff51611e9afc60baaf8bb6b3af6
parent 47b6cd70cf1f9ec6731622c968eb4e635a237ba0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 13:20:01 -0500

goals: a back card is never cut on its right, and a goal may say the weight he set it from

A back card in the shelf's fan cut its words on the right with an ellipsis
("LOSE 1..." for LOSE 100), and the right end is what tells one goal from
another. Its words and date now end at the card's right edge, sized to fit
the strip that shows when they can (backTextSize, 24 down to 17 px); past
that their LEFT goes under the card in front. The x-n badge keeps the top of
the strip to itself.

deck.goals.base (default off): each loss goal also says the weight he had
stated when he set it, "LOSE 100 (FROM 346.7)", its qualifier kept -- the
slice's own goal.base, the one the gauge reckons its target from
(measure-slice.mjs goalBase). No base, none shown. On the front card a line
under the goal; on a back card a line of its own, right-aligned. In the
module's UI row and knobs.md.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mumtool/docs/knobs.md | 3++-
Mumtool/report-to-video/chrome-measure-extras.mjs | 40+++++++++++++++++++++++++++++++++-------
Mumtool/report-to-video/measure-extras.mjs | 18+++++++++++++++++-
Mumtool/report-to-video/modules/goals.mjs | 4+++-
Mumtool/report-to-video/modules/measure-extras-settings.mjs | 6++++--
Mumtool/report-to-video/shelf.test.mjs | 81++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
6 files changed, 137 insertions(+), 15 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -2392,10 +2392,11 @@ A sticky note per goal on a pile in a corner of the footage box, read off the sc | Knob | Range · default | From a terminal | |---|---|---| -| `deck.goals` | `true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown}` · default on with a measure slice | `umtool look <p> deck.goals=false` | +| `deck.goals` | `true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown, base}` · default on with a measure slice | `umtool look <p> deck.goals=false` | | `deck.goals.position`, `.x`/`.y`, `.scale` | `top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1 | `umtool look <p> deck.goals.position=bottom-left` | | `deck.goals.position=shelf` | its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- ordered by the dial's goal board (measure-goals.mjs `goalsAt(goalBoard(schedule.measure), t)`, so the shelf and the dial always agree): its headline -- the closest goal in force -- in front with "+N more" for the others in force, the rest by recency; a goal the board misses struck in red, MISSED on it, for the dial's 6 s; with no goal in force, the newest in front; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial | `umtool look <p> deck.shelf.items='["diet","goals"]' deck.goals.position=shelf` | | `deck.goals.max`, `.color`, `.countdown` | 1–8 notes · #hex paper · bool · default 4, the palette's amber, `true` | `umtool look <p> deck.goals.max=6` | +| `deck.goals.base` | bool · default `false`: each note also says the weight he had stated when he set the goal -- "LOSE 100 (FROM 346.7)", its qualifier kept ("(FROM ≈390)") -- the slice's own base for that goal, the one the gauge reckons its target from (measure-slice.mjs `goalBase`: the start of the run open when he set it, else the latest weight he gave by the goal's date, stated or remembered). A goal with no base (no weight by then, a target goal such as "250 LB", a base the scale's foot refuses) shows none -- never one made up. On a back card it is a line of its own, right-aligned like the label | `umtool look <p> deck.goals.base=true` | | `deck.goals.hold`, `.finale` | 0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide` | `umtool look <p> deck.goals.hold=0` | | `deck.goals.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.goals.onPosts=hide` | | `deck.goals.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.goals.position=shelf` | diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs @@ -236,7 +236,8 @@ export function goalsHtml(schedule, render, opts = {}) { : ""; const count = n.count > 1 ? `<div class="ct" data-k="${k}c">×${n.count}</div>` : ""; const shade = n.depth ? `<div class="sh" style="opacity:${r4(Math.min(0.5, 0.14 * n.depth))}"></div>` : ""; - return `<div class="note${dl ? " due" : ""}" data-k="${k}" style="z-index:${20 - n.depth}"><div class="tape"></div><div class="nh">Goal${n.date ? ` · ${esc(monthYear(n.date))}` : ""}</div><div class="nt">${esc(n.text)}</div>${dl}${count}${shade}</div>`; + const fr = n.base ? `<div class="fr">${esc(n.base)}</div>` : ""; + return `<div class="note${dl ? " due" : ""}${fr ? " based" : ""}" data-k="${k}" style="z-index:${20 - n.depth}"><div class="tape"></div><div class="nh">Goal${n.date ? ` · ${esc(monthYear(n.date))}` : ""}</div><div class="nt">${esc(n.text)}</div>${fr}${dl}${count}${shade}</div>`; }).join(""); const html = `<div class="st" data-k="s${j}">${notes}<div class="hd"><span class="hn">${st.goalsSet}</span> goal${st.goalsSet === 1 ? "" : "s"} set</div></div>`; items.push({ key: `s${j}`, gate: [`s${j}`, "autoAlpha"], html }); @@ -256,6 +257,9 @@ export function goalsHtml(schedule, render, opts = {}) { text-transform: uppercase; color: rgba(42, 28, 6, 0.62); } .nt { font-family: ${DISPLAY}; font-size: ${px(54)}px; line-height: ${px(58)}px; white-space: nowrap; letter-spacing: 0.01em; } .due .nt { font-size: ${px(44)}px; line-height: ${px(48)}px; } + .based .nt { font-size: ${px(46)}px; line-height: ${px(50)}px; } + .based.due .nt { font-size: ${px(38)}px; line-height: ${px(41)}px; } + .fr { font-family: ${DISPLAY}; font-size: ${px(22)}px; line-height: ${px(25)}px; color: rgba(42, 28, 6, 0.78); white-space: nowrap; letter-spacing: 0.02em; } .dl { font-family: 'DeckSansBold', sans-serif; font-size: ${px(19)}px; line-height: ${px(23)}px; color: #7d150c; white-space: nowrap; } .dl2 { font-family: 'DeckSansBold', sans-serif; font-size: ${px(18)}px; line-height: ${px(22)}px; color: rgba(42, 28, 6, 0.8); white-space: nowrap; } /* The count sits in the note's top strip: what shows of a note further down the pile. */ @@ -273,6 +277,19 @@ export function goalsHtml(schedule, render, opts = {}) { return { html: page("goals", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; } +/** A back card's padding (design px): its sides and foot, and the top it leaves to the ×n badge. */ +export const GOALS_BACK = Object.freeze({ pad: 8, top: 30, max: 24, min: 17 }); + +/** + * A back card's words a size that fits `room` (design px, the strip that shows) when they can -- the display face + * at ~0.5 em a letter, 24 px at most -- and 17 px at the least: below that they keep their size, right-aligned, and + * their left goes under the card in front. + */ +export function backTextSize(text, room) { + const n = Math.max(1, [...String(text)].length); + return Math.max(GOALS_BACK.min, Math.min(GOALS_BACK.max, Math.floor(room / (0.5 * n)))); +} + /** * The goal stack ON THE SHELF (`goals.position: "shelf"`): the count of goals * set in a column at the left, then the notes -- the same paper, tape, shadow @@ -294,6 +311,8 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) { const room = geo.width / F.k - G.count - G.gap - G.card; const step = max > 1 ? Math.max(G.back, Math.min(G.card + G.step, room / (max - 1))) : 0; const backs = step < G.card; + // The strip of a back card that shows beside the card in front (design px), less its padding. + const strip = Math.min(step, G.card) - 14 - 2 * GOALS_BACK.pad; const place = (note, depth) => ({ x: px(G.count + G.gap + depth * step), y: Math.round(px(6) + note.dx * 0.15 * F.k + (depth ? px(1) : 0)), @@ -348,9 +367,13 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) { const more = n.depth === 0 && st.headline && Number.isFinite(st.active) && st.active > 1 ? `<div class="mo">+${st.active - 1} more</div>` : ""; const front = n.depth === 0 || !backs; const crossing = backs && n.prev === 0 && n.depth > 0; - const face = `<div class="nf"${crossing ? ` data-k="${k}f"` : ""} style="opacity:${front || crossing ? 1 : 0}"><div class="nh">Goal${n.date ? ` · ${esc(monthYear(n.date))}` : ""}</div><div class="nt">${esc(n.text)}</div>${dl}</div>`; + const fr = n.base ? `<div class="fr">${esc(n.base)}</div>` : ""; + const face = `<div class="nf${fr ? " based" : ""}"${crossing ? ` data-k="${k}f"` : ""} style="opacity:${front || crossing ? 1 : 0}"><div class="nh">Goal${n.date ? ` · ${esc(monthYear(n.date))}` : ""}</div><div class="nt">${esc(n.text)}</div>${fr}${dl}</div>`; + // A BACK CARD's words end at its right edge and are never cut there (11 Nov): the right end is what tells one + // goal from another ("LOSE 1…" read as any of three). Sized to fit the strip that shows when they can + // (backTextSize); when they cannot, it is their LEFT that goes under the card in front. const back = backs && n.depth > 0 - ? `<div class="nb"${crossing ? ` data-k="${k}b"` : ""} style="opacity:${crossing ? 0 : 1}"><div class="bt">${esc(n.text)}</div>${n.date ? `<div class="bh">${esc(monthYear(n.date))}</div>` : ""}</div>` + ? `<div class="nb"${crossing ? ` data-k="${k}b"` : ""} style="opacity:${crossing ? 0 : 1}"><div class="bt" style="font-size:${px(backTextSize(n.text, strip))}px">${esc(n.text)}</div>${n.base ? `<div class="bf">${esc(n.base)}</div>` : ""}${n.date ? `<div class="bh">${esc(monthYear(n.date))}</div>` : ""}</div>` : ""; // Missed (the board's, held as the dial holds it): struck in red, MISSED on it. const miss = st.missed?.includes(n.key) ? `<div class="mx"></div><div class="ms">Missed</div>` : ""; @@ -374,16 +397,19 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) { .tape { position: absolute; left: 50%; top: ${px(-6)}px; width: ${px(70)}px; height: ${px(18)}px; margin-left: ${px(-35)}px; background: rgba(255, 255, 255, 0.38); transform: rotate(-3deg); } .nf { position: absolute; inset: 0; padding: ${px(8)}px ${px(14)}px; display: flex; flex-direction: column; justify-content: center; gap: ${px(1)}px; overflow: hidden; } - .nb { position: absolute; right: 0; top: 0; bottom: 0; width: ${px(Math.min(step, G.card) - 14)}px; padding: 0 ${px(6)}px; - display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; } + .nb { position: absolute; left: 0; right: 0; top: 0; bottom: 0; padding: ${px(GOALS_BACK.top)}px ${px(GOALS_BACK.pad)}px ${px(GOALS_BACK.pad)}px; + display: flex; flex-direction: column; justify-content: center; align-items: flex-end; text-align: right; overflow: hidden; } .nh { font-family: 'DeckSansBold', sans-serif; font-size: ${px(13)}px; line-height: ${px(16)}px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(42, 28, 6, 0.62); white-space: nowrap; } .nt { font-family: ${DISPLAY}; font-size: ${px(40)}px; line-height: ${px(44)}px; white-space: nowrap; letter-spacing: 0.01em; } .dl { font-family: 'DeckSansBold', sans-serif; font-size: ${px(13)}px; line-height: ${px(16)}px; color: #7d150c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } - .bt { font-family: ${DISPLAY}; font-size: ${px(24)}px; line-height: ${px(27)}px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; } + .bt { font-family: ${DISPLAY}; line-height: 1.12; white-space: nowrap; flex: none; } + .bf { font-family: ${DISPLAY}; font-size: ${px(15)}px; line-height: ${px(18)}px; color: rgba(42, 28, 6, 0.78); white-space: nowrap; flex: none; } .bh { font-family: 'DeckSansBold', sans-serif; font-size: ${px(12)}px; line-height: ${px(15)}px; letter-spacing: 0.1em; text-transform: uppercase; - color: rgba(42, 28, 6, 0.62); white-space: nowrap; } + color: rgba(42, 28, 6, 0.62); white-space: nowrap; flex: none; } + .fr { font-family: ${DISPLAY}; font-size: ${px(18)}px; line-height: ${px(20)}px; color: rgba(42, 28, 6, 0.78); white-space: nowrap; letter-spacing: 0.02em; } + .nf.based .nt { font-size: ${px(36)}px; line-height: ${px(38)}px; } .mo { position: absolute; right: ${px(8)}px; bottom: ${px(6)}px; padding: 0 ${px(7)}px; height: ${px(20)}px; border-radius: ${px(10)}px; background: rgba(42, 28, 6, 0.85); color: ${paper}; font-family: 'DeckSansBold', sans-serif; font-size: ${px(12)}px; line-height: ${px(20)}px; } .mx { position: absolute; left: ${px(6)}px; right: ${px(6)}px; top: 50%; height: ${px(4)}px; margin-top: ${px(-2)}px; background: ${MEASURE_RED}; diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -216,6 +216,18 @@ export function goalText(e, unit = "lb") { } /** + * A goal's base as its note writes it -- "(FROM 346.7)", "(FROM ≈390)" -- from the + * slice's `goal.base` ({ value, row }), the qualifier its row carries; null + * when there is none. + */ +export function goalBaseText(base, m) { + if (!base || !Number.isFinite(base.value)) return null; + const row = [...(m?.events ?? []), ...(m?.hidden ?? [])].find((e) => e.row === base.row); + const q = typeof row?.qualifier === "string" && /^[≈<>]$/.test(row.qualifier) ? row.qualifier : ""; + return `(FROM ${q}${weightText(base.value)})`; +} + +/** * The pile's states: one per goal event, `{ at, top, goalsSet, notes }` -- * `notes` back to front (the last is the one that just landed, `top` its key), * each `{ key, text, count, date, deadline, deadlineDate, days, target, rot, @@ -255,6 +267,10 @@ export function goalStates(schedule, render) { const target = s?.goal && s.goal.row === e.row && Number.isFinite(s.goal.value) ? s.goal.value : e.kind === "goal" && Number.isFinite(e.value) ? e.value : null; note.target = target; + // The weight he had stated when he set it (`goals.base`): the slice's own base for this goal -- the weight the + // gauge's target is reckoned from (measure-slice.mjs goalBase: the run's start, else the latest weight he gave by + // the goal's date) -- with its row's qualifier. None resolved, none shown: never one made up here. + note.base = cfg.base && s?.goal?.row === e.row ? goalBaseText(s.goal.base, m) : null; order = [...order.filter((k) => k !== key), key]; const shown = order.slice(-cfg.max); const depth = new Map(shown.map((k, i) => [k, shown.length - 1 - i])); @@ -267,7 +283,7 @@ export function goalStates(schedule, render) { const x = notes.get(k); return { key: k, id: x.id, text: x.text, count: x.count, date: x.date, deadline: x.deadline, - deadlineDate: x.deadlineDate, days: x.days, target: x.target, rot: x.rot, dx: x.dx, + deadlineDate: x.deadlineDate, days: x.days, target: x.target, base: x.base ?? null, rot: x.rot, dx: x.dx, depth: depth.get(k), prev: k === key ? null : prevDepth.get(k) ?? null, }; }), diff --git a/umtool/report-to-video/modules/goals.mjs b/umtool/report-to-video/modules/goals.mjs @@ -22,14 +22,16 @@ export default measureExtraModule({ { key: "max", type: "number", min: MEASURE_LIMITS.max[0], max: MEASURE_LIMITS.max[1], label: "Notes shown", default: 4 }, { key: "color", type: "color", label: "Paper (default the palette's amber)" }, { key: "countdown", type: "boolean", label: "Count a deadline down to the render date", default: true }, + { key: "base", type: "boolean", label: "Say the weight he had stated when he set it", default: false }, ], docs: { intro: "A sticky note per goal on a pile in a corner of the footage box, read off the schedule's `measure` slice (`render.chrome.deck.goals`, measure-extras.mjs): each goal or goalLoss event drops one, turned a little, onto the pile; the same goal in the same words (\"lose 100\") merges into its note with a count (\"×8\") and comes to the front; `max` notes show, the newest in front, with the goals set so far under them. A goal with a `deadline` counts down to `measure.asOfRender` (\"by Christmas · 50 days left · needs 226.5\"): Christmas is the next 25 Dec from the day he said it, \"next year\" a year on, a named year that year; words that name no date (\"by my birthday\") keep their label and no countdown. On whenever the cut has a measure slice with a goal on camera; `false` turns it off. Up for `hold` seconds after each goal (default 20), the pile as it stands each time. The four measure extras sit at anchors of the footage box by default, clear of the instrument panel's right column and of the top-left, where the streams' face cam most often is (the diet badge bottom-left, the goal stack bottom-right, the moving start top-right, the promise clock top-centre); `position` or `x`/`y` move one.", rows: [ - ["`deck.goals`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown}` · default on with a measure slice", "`umtool look <p> deck.goals=false`"], + ["`deck.goals`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown, base}` · default on with a measure slice", "`umtool look <p> deck.goals=false`"], ["`deck.goals.position`, `.x`/`.y`, `.scale`", "`top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1", "`umtool look <p> deck.goals.position=bottom-left`"], ["`deck.goals.position=shelf`", "its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- ordered by the dial's goal board (measure-goals.mjs \`goalsAt(goalBoard(schedule.measure), t)\`, so the shelf and the dial always agree): its headline -- the closest goal in force -- in front with \"+N more\" for the others in force, the rest by recency; a goal the board misses struck in red, MISSED on it, for the dial's 6 s; with no goal in force, the newest in front; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial", "`umtool look <p> deck.shelf.items='[\"diet\",\"goals\"]' deck.goals.position=shelf`"], ["`deck.goals.max`, `.color`, `.countdown`", "1–8 notes · #hex paper · bool · default 4, the palette's amber, `true`", "`umtool look <p> deck.goals.max=6`"], + ["`deck.goals.base`", "bool · default `false`: each note also says the weight he had stated when he set the goal -- \"LOSE 100 (FROM 346.7)\", its qualifier kept (\"(FROM ≈390)\") -- the slice's own base for that goal, the one the gauge reckons its target from (measure-slice.mjs `goalBase`: the start of the run open when he set it, else the latest weight he gave by the goal's date, stated or remembered). A goal with no base (no weight by then, a target goal such as \"250 LB\", a base the scale's foot refuses) shows none -- never one made up. On a back card it is a line of its own, right-aligned like the label", "`umtool look <p> deck.goals.base=true`"], ["`deck.goals.hold`, `.finale`", "0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide`", "`umtool look <p> deck.goals.hold=0`"], ], }, diff --git a/umtool/report-to-video/modules/measure-extras-settings.mjs b/umtool/report-to-video/modules/measure-extras-settings.mjs @@ -6,7 +6,7 @@ // SETTINGS), so it imports only instruments.mjs (a leaf too: whether the // instruments' column is on decides two defaults here). // -// render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown } +// render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown, base } // render.chrome.deck.peak { show, position, x, y, scale, hold, finale, title, color, values } // render.chrome.deck.promise { show, position, x, y, scale, hold, finale, label, verb, kept, broken, checks, speakers, claimVerb, claimColor } // render.chrome.deck.diet { show, position, x, y, scale, hold, finale, colors, labels, form, tags, overlap, days } @@ -122,7 +122,8 @@ export const MEASURE_DEFAULTS = Object.freeze({ // The sticky notes pile in the bottom-right corner, up for `hold` seconds // after each goal; `max` notes show, the newest in front; `color` is the // paper (default the palette's amber). - goals: Object.freeze({ ...COMMON, position: "bottom-right", hold: 20, max: 4, color: null, countdown: true }), + // `base`: each note also says the weight he had stated when he set it, "(FROM 346.7)" (the slice's goal base). + goals: Object.freeze({ ...COMMON, position: "bottom-right", hold: 20, max: 4, color: null, countdown: true, base: false }), // The moving start: up for `hold` seconds after each retelling. peak: Object.freeze({ ...COMMON, position: "top-right", hold: 12, title: "The start keeps moving", color: null, values: "drift" }), // The promise clock: up from the promise on, through the finale. @@ -262,6 +263,7 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`, } color(v.color, `${where}.color`, errors); if (v.countdown !== undefined && typeof v.countdown !== "boolean") errors.push(`${where}.countdown must be true or false`); + if (v.base !== undefined && typeof v.base !== "boolean") errors.push(`${where}.base must be true or false`); } if (id === "peak") { text(v.title, L.text, `${where}.title`, errors, { nullable: false }); diff --git a/umtool/report-to-video/shelf.test.mjs b/umtool/report-to-video/shelf.test.mjs @@ -10,11 +10,11 @@ import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; -import { dietHtml, goalsHtml, shelfGoalStates, tagWords, tagWordSize } from "./chrome-measure-extras.mjs"; +import { backTextSize, dietHtml, GOALS_BACK, goalsHtml, shelfGoalStates, tagWords, tagWordSize } from "./chrome-measure-extras.mjs"; import { goalBoard, goalsAt } from "./measure-goals.mjs"; import { shelfHtml, shelfNoteGeometry } from "./chrome-shelf.mjs"; import { deckGeometry, entryShelfNotes, estimateSchedule, instrumentsGeometry, parseShelfNote, validateChrome } from "./deck.mjs"; -import { dietDays, dietStates, goalStates, dietTagsBox, GOALS_SHELF, goalsShelfWidth, measureExtraGeometry, measurePlacements, shelfLayout, streakStates } from "./measure-extras.mjs"; +import { dietDays, dietStates, goalBaseText, goalStates, dietTagsBox, GOALS_SHELF, goalsShelfWidth, measureExtraGeometry, measurePlacements, shelfLayout, streakStates } from "./measure-extras.mjs"; import { slotRect } from "./modules/layout.mjs"; import { moduleById, moduleProblems, scheduleSlices } from "./modules/index.mjs"; import { resolveMeasureExtra, validateMeasureExtra } from "./modules/measure-extras-settings.mjs"; @@ -258,7 +258,7 @@ test("goals on the shelf: the count and the fanned notes, the fan taking the she const { html, items } = goalsHtml(schedule(), r, { fonts: {} }); assert.match(html, /<div class="gc"><div class="gn" data-k="s0\.c">1<\/div><div class="gl">goal set<\/div><\/div>/); assert.match(html, /class="note" data-k="s\d+\.n\d+" style="z-index:19"><div class="tape"><\/div><div class="nf"/); - assert.match(html, /<div class="nb"[^>]*><div class="bt">LOSE 100<\/div>/, "an older note shows its words beside the one in front"); + assert.match(html, /<div class="nb"[^>]*><div class="bt"[^>]*>LOSE 100<\/div>/, "an older note shows its words beside the one in front"); // A block per state of the fan: each goal he sets, and each second the goal board alone changes (shelfGoalStates). assert.equal(items.length, shelfGoalStates(schedule(), goalStates(schedule(), r)).length); // Off the shelf: the pile in the footage, as it was. @@ -286,3 +286,78 @@ test("goals on the shelf: the dial's goal board orders the fan -- its headline i const { html } = goalsHtml(sched, r, { fonts: {} }); assert.match(html, new RegExp(`<div class="mo">\\+${end.active.length - 1} more</div>`)); }); + +// --------------------------------------------------------------------------- +// A BACK CARD (operator, 11 Nov): "LOSE 1…" for "LOSE 100" -- the right end is what tells one goal from another, so a +// back card is never cut on the right: its words end at the card's right edge and their LEFT goes under the card in +// front. And a goal may say the weight he had stated when he set it, "LOSE 100 (FROM 346.7)" (`goals.base`). +// --------------------------------------------------------------------------- + +/** The page's CSS rule for `sel`, as written. */ +const ruleOf = (html, sel) => new RegExp(`\\n\\s*\\${sel} \\{([^}]*)\\}`).exec(html)?.[1] ?? ""; + +test("a back card's words are right-aligned to its right edge and never cut with an ellipsis -- for 2, 3, 4 and 8 notes", () => { + for (const max of [2, 3, 4, 8]) { + const r = renderOf({ ...FAN, goals: { position: "shelf", max } }); + const { html } = goalsHtml(schedule(), r, { fonts: {} }); + if (!/class="nb"/.test(html)) continue; // room for every note side by side: no back strips at all + const nb = ruleOf(html, ".nb"), bt = ruleOf(html, ".bt"), bh = ruleOf(html, ".bh"); + assert.match(nb, /align-items: flex-end/, `${max}: the words end at the right`); + assert.match(nb, /text-align: right/); + assert.match(nb, /left: 0; right: 0/, `${max}: the strip is the card's whole width, so an overflow goes LEFT, under the card in front`); + for (const [name, rule] of [["bt", bt], ["bh", bh]]) { + assert.doesNotMatch(rule, /ellipsis|max-width/, `${max}: .${name} is never cut on the right`); + } + // The ×n badge has the top of the strip to itself: the words start under it. + const padTop = Number(/padding: ([\d.]+)px/.exec(nb)[1]); + const ct = ruleOf(html, ".ct"); + const badgeFoot = Number(/top: ([\d.]+)px/.exec(ct)[1]) + Number(/height: ([\d.]+)px/.exec(ct)[1]); + assert.ok(badgeFoot <= padTop, `${max}: the ×n badge (to ${badgeFoot} px) is above the words (from ${padTop} px)`); + } + // Sized to fit the strip when they can, 17 px at the least; past that the left goes under. + assert.equal(backTextSize("LOSE 40", 80), 22); + assert.equal(backTextSize("LOSE 100", 80), 20); + assert.equal(backTextSize("LOSE 100 LB OR SO", 80), GOALS_BACK.min); + assert.equal(backTextSize("X", 300), GOALS_BACK.max); +}); + +test("goals.base: off by default; on, each loss goal says the weight the slice reckons it from, its qualifier kept, never one made up", () => { + assert.deepEqual(validateMeasureExtra("goals", { base: true }), []); + assert.match(validateMeasureExtra("goals", { base: "yes" }).join(), /base must be true or false/); + const off = goalStates(schedule(), renderOf(FAN)); + assert.ok(off.every((st) => st.notes.every((n) => n.base === null)), "off: no base"); + const r = renderOf({ ...FAN, goals: { position: "shelf", base: true } }); + // The slice's bases (measure-slice.mjs goalBase; the fixture predates them): w06 from a stated 346.7, w13 from a + // remembered ≈390, every other goal none. + const m = clone(MEASURE); + m.events.push({ t: null, row: "wb1", kind: "stated", value: 346.7, qualifier: null }, { t: null, row: "wb2", kind: "remembered", value: 390, qualifier: "≈" }); + for (const st of m.state) { + if (st.goal?.row === "w06") st.goal.base = { value: 346.7, row: "wb1", from: "stated" }; + if (st.goal?.row === "w13") st.goal.base = { value: 390, row: "wb2", from: "remembered" }; + } + const sched = schedule({ measure: m }); + const states = goalStates(sched, r); + // Each note's base is its own goal's state's `goal.base` -- the gauge's -- or none. + let withBase = 0; + for (const st of states) { + const e = m.events.find((x) => x.t === st.at && (x.kind === "goal" || x.kind === "goalLoss")); + const s = [...m.state].reverse().find((x) => x.t <= st.at + 1e-9 && x.goal?.row === e.row); + const top = st.notes.find((n) => n.key === st.top); + const want = s?.goal?.base ? goalBaseText(s.goal.base, m) : null; + assert.equal(top.base, want, `${e.row}: the slice's base or none`); + if (want) withBase += 1; + } + assert.equal(withBase, 2); + assert.ok(states.some((st) => st.notes.some((n) => n.base === "(FROM ≈390)"))); + // The words: "(FROM 346.7)", a qualifier kept, nothing for no base. + const mm = { events: [{ row: "w21", qualifier: "≈" }, { row: "w7", qualifier: null }] }; + assert.equal(goalBaseText({ value: 346.7, row: "w7" }, mm), "(FROM 346.7)"); + assert.equal(goalBaseText({ value: 390, row: "w21" }, mm), "(FROM ≈390)"); + assert.equal(goalBaseText(null, mm), null); + // Drawn on the front card under the goal, and on a back card as a line of its own, right-aligned with the words. + const { html } = goalsHtml(sched, r, { fonts: {} }); + assert.match(html, /<div class="nt">[^<]+<\/div><div class="fr">\(FROM [≈<>]?[\d.]+\)<\/div>/); + assert.match(html, /<div class="bt"[^>]*>[^<]+<\/div><div class="bf">\(FROM [≈<>]?[\d.]+\)<\/div>/); + // Off: none of it. + assert.doesNotMatch(goalsHtml(schedule(), renderOf(FAN), { fonts: {} }).html, /class="(fr|bf)"/); +});