Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Let a deck set its own morph tempo, and demo it honestly

nyblnet74790dfa08e2
diff --git a/scripts/build-code-obvious.mjs b/scripts/build-code-obvious.mjs
new file mode 100644
index 00000000..a7fbe18c
--- /dev/null
+++ b/scripts/build-code-obvious.mjs
@@ -0,0 +1,121 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// A deliberately UNMISSABLE code-morph demo. DEMO BUILD, not for release.
+//
+// The matrix deck was correct and unconvincing: a one-line swap travels about
+// 40px, and at the default 0.65s morph with a power2.inOut ease that reads as
+// a blink. This deck is the opposite extreme — long journeys, a slow beat, a
+// big typeface — so the only question it asks is "does the text travel", not
+// "can you catch it".
+
+import { readFileSync, writeFileSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const root = join(dirname(fileURLToPath(import.meta.url)), '..')
+const shellPath = join(root, 'slides/dist-single/Bento_Slides.bento.html')
+const out = join(root, 'slides/dist-single/Code_Obvious_Demo.bento.html')
+
+const STAMP = process.env.STAMP || new Date().toISOString().slice(11, 16)
+const INK = '#0D1B2E', PAPER = '#F2F0EA', MIST = '#8FA0B4', ACCENT = '#FF9E8A'
+
+let uid = 0
+const id = (p) => `${p}-${uid++}`
+
+const text = (html, x, y, w, h, o = {}) => ({
+ id: id('t'), type: 'text', x, y, w, h, rotation: 0, opacity: 1,
+ html, fontSize: o.size ?? 26, fontFamily: 'Instrument Sans, Helvetica Neue, sans-serif',
+ fontWeight: o.weight ?? 400, color: o.color ?? PAPER,
+ align: o.align ?? 'left', valign: 'top', lineHeight: 1.35,
+})
+
+const code = (content, o = {}) => ({
+ id: id('c'), type: 'code', morphId: o.group ?? 'walkthrough',
+ x: 96, y: 200, w: 1088, h: 460, rotation: 0, opacity: 1,
+ content, lang: o.lang ?? 'ts', color: '#DCE3EC',
+ fontSize: o.size ?? 34, lineHeight: 1.55,
+})
+
+const slide = (elements, o = {}) => ({
+ id: id('s'), name: o.name ?? '', background: o.bg ?? INK,
+ transition: o.transition ?? 'morph', notes: o.notes ?? '', elements,
+})
+const heading = (s) => text(s, 96, 90, 1088, 60, { size: 36, weight: 700 })
+const sub = (s) => text(s, 96, 138, 1088, 40, { size: 20, color: MIST })
+
+// ONE line travels the full height of the block, twice over. Nothing is added
+// or removed, so every token on screen is a token that must move.
+const LONG_A = `function pipeline() {
+ FIRST()
+ b()
+ c()
+ d()
+ e()
+ f()
+ g()
+}`
+const LONG_B = `function pipeline() {
+ b()
+ c()
+ d()
+ e()
+ f()
+ g()
+ FIRST()
+}`
+
+// A whole block slides down to make room — big, simultaneous travel.
+const ROOM_A = `function boot() {
+ mount()
+ paint()
+}`
+const ROOM_B = `function boot() {
+ checkLicence()
+ loadFonts()
+ warmCaches()
+ mount()
+ paint()
+}`
+
+const doc = {
+ format: 'bento/slides', version: 1,
+ docId: 'code-obvious-demo-0001',
+ title: `Does the code travel? (build ${STAMP})`,
+ size: { width: 1280, height: 720 },
+ theme: { background: INK, color: PAPER, accent: ACCENT, fontFamily: 'Instrument Sans, Helvetica Neue, sans-serif' },
+ // THE POINT OF THIS BUILD: a slow, readable morph.
+ present: { controls: false, morphSeconds: 2.2 },
+ slides: [
+ slide([
+ text('Does the code travel?', 96, 250, 1088, 90, { size: 68, weight: 700 }),
+ text('Two moves, both deliberately huge, at a 2.2s morph.', 96, 350, 1000, 50, { size: 24, color: MIST }),
+ text(`build ${STAMP} — press → four times`, 96, 415, 1000, 40, { size: 19, color: ACCENT }),
+ ], { transition: 'fade', name: 'Title' }),
+
+ slide([heading('1. One line, the whole way down'),
+ sub('FIRST() is at the top — watch it, and only it, travel'), code(LONG_A)],
+ { name: 'long-before' }),
+ slide([heading('1. One line, the whole way down'),
+ sub('everything else shuffles up one row to let it past'), code(LONG_B)],
+ { name: 'long-after', notes: 'FIRST() travels ~6 line-heights. Nothing fades.' }),
+
+ slide([heading('2. Making room'),
+ sub('two lines here — three more are about to arrive above them'), code(ROOM_A, { group: 'room' })],
+ { name: 'room-before' }),
+ slide([heading('2. Making room'),
+ sub('mount() and paint() slide down; the new work fades in behind them'), code(ROOM_B, { group: 'room' })],
+ { name: 'room-after', notes: 'Travel and fade in one beat.' }),
+ ],
+ modified: new Date().toISOString(),
+}
+
+const shell = readFileSync(shellPath, 'utf8')
+const open = '<script type="application/bento+json" id="bento-doc">'
+const i = shell.indexOf(open)
+if (i < 0) throw new Error('no #bento-doc block in the shell')
+const j = shell.indexOf('</scr' + 'ipt>', i)
+const json = JSON.stringify(doc).replace(/</g, '\\u003c')
+writeFileSync(out, shell.slice(0, i + open.length) + json + shell.slice(j))
+console.log(`wrote ${out}`)
+console.log(` build stamp ${STAMP}, morphSeconds ${doc.present.morphSeconds}`)
diff --git a/slides/src/model.ts b/slides/src/model.ts
index f0f7f4f5..1f5f473f 100644
--- a/slides/src/model.ts
+++ b/slides/src/model.ts
@@ -437,6 +437,14 @@ export interface BentoDoc {
slideNumber?: boolean
controls?: boolean
progress?: boolean
+ /**
+ * Seconds a morph transition takes. Absent = 0.65, which is tuned for the
+ * usual case: a title sliding, a shape growing, distances of hundreds of
+ * pixels. Code token morphs move a single line-height — about 40px — and at
+ * the default that reads as a blink rather than as travel, so a deck built
+ * around them wants a slower beat. Clamped on read.
+ */
+ morphSeconds?: number
}
/** shared assets (raw SVG markup or data URIs), referenced by key */
assets?: Record<string, string>
diff --git a/slides/src/present.ts b/slides/src/present.ts
index 2fbf9676..136cfcd1 100644
--- a/slides/src/present.ts
+++ b/slides/src/present.ts
@@ -15,7 +15,9 @@ import { paintSpeaker, setSpeakerWindow, speakerIdleBody, speakerWindow } from '
import { t } from './i18n'
import { lsGet, lsSet } from '../../kernel/src/storage.ts'
-const MORPH_DURATION = 0.65
+const MORPH_DURATION_DEFAULT = 0.65
+/** Set per-deck by doc.present.morphSeconds; clamped to something sane. */
+let MORPH_DURATION = MORPH_DURATION_DEFAULT
const MORPH_EASE = 'power2.inOut'
export interface PresentSession {
@@ -28,6 +30,8 @@ export function startPresentation(
onExit: (lastIndex: number) => void,
opts: { fullscreen?: boolean } = {},
): PresentSession {
+ MORPH_DURATION = Math.min(6, Math.max(0.1, doc.present?.morphSeconds ?? MORPH_DURATION_DEFAULT))
+
const overlay = document.createElement('div')
overlay.className = 'bento-present-overlay'
overlay.style.setProperty('--bento-accent', doc.theme.accent)