An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat: add animated bookshelf
yzrea32873a47b8
diff --git a/plan.md b/plan.mdindex 1b11b5a..c8e74bd 100644--- a/plan.md+++ b/plan.md@@ -1,14 +1,14 @@# AnimeBook 项目计划-> 状态:第 1–39 章已部署到 Cloudflare Pages(`https://math.diamonddoge.org/`);本地第 40 章首版完成,待用户审阅。下一阶段补齐全书章节,再系统检查动画;当前明确的反馈是开场旁白已有内容、主画面却留白,属于编排问题,具体章节待补充。+> 状态:第 1–39 章已部署到 Cloudflare Pages(`https://math.diamonddoge.org/`);本地 main 的第 1–68 章首版已完成,书架首版已实现,待用户审阅。下一阶段系统检查与打磨动画;当前明确的反馈是开场旁白已有内容、主画面却留白,属于编排问题,具体章节待补充。> 本文供后续参与项目的 agents 阅读和执行。明确标注的“候选”“建议”“待定”不等于已经获得用户确认。-> 当前阶段先完成计划,再讨论技术栈;不要仅凭本文直接开始搭建整站或批量制作课程。+> 当前阶段重点审阅全书与书架,检查动画编排;未确认的 Skill 封装和新书制作范围继续讨论。## 1. 项目目标以现有的预代数与代数 I 教材为参考,重新创作一本带有动画讲解、数学交互和自动判题的双语练习册,最终交付可部署到远程的静态站点。-当前数学书是网站的第一本作品。网站最终会收录多本书与动画作品,后续增加类似书架的入口:从书架选择一本书,进入其目录,再观看章节动画和参与交互。用户希望保留类似老 Flash 动画网站的观看与操作体验。制作能力按动画难度逐步发展,最终目标是面向历史书或文艺书、类似 Vox 表达方式的短纪录片;具体形式和制作阶段继续讨论。+当前数学书是网站的第一本作品。网站最终会收录多本书与动画作品,已增加类似书架的入口:从书架选择一本书,进入书本封面页、目录,再观看章节动画和参与交互。用户希望保留类似老 Flash 动画网站的观看与操作体验。制作能力按动画难度逐步发展,最终目标是面向历史书或文艺书、类似 Vox 表达方式的短纪录片;具体形式和制作阶段继续讨论。核心是做好数学教学动画:学生能看清一个概念、关系或计算过程如何逐步形成,并通过画面内的小测和整章练习验证理解。动画的组织、节奏和准确性优先于装饰、吉祥物和页面数量。@@ -18,6 +18,12 @@先以第一章验证完整教学体验,形成可复用的制作方法,再逐步扩展到其他章节。用户曾在大学线性代数内容上验证过 agent 制作纯 JavaScript 动画的能力,当时没有加入语音。用户认可 agent 自行处理动画的能力;本项目应围绕清楚的教学编排发挥这种能力,不预先要求复杂的动画框架。+### 1.1 书架首版(2026-10-02)++首页为公开书架,点击书封、标题或文字入口先进入书本身的封面页,再通过封面页打开目录,继续进入章节动画;不要跳过书封页。首版展示已有数学书,书架入口使用轻巧的下划线文字与箭头,不使用大块实底按钮。保留章节深链接和浏览器内的学习进度,继续阅读可直接到上次章节;从书封、目录可回到书架。网站不设登录、支付或访客在线创作系统,制作能力后续通过开源 Skill 分享。++书架样式与数据在 `site/lib/bookshelf.css` 和 `site/lib/bookshelf.js`,数学书的章节和单元数量由现有目录自动读取。入口不带 hash 时展示书架,`#book` 展示数学书封面,`#contents` / `#chNN` 展示目录;原有章节链接和引擎路径保持兼容。新书发布时增加独立目录及书架条目,不展示未制作的占位作品。+## 2. 已确定的要求| 项目 | 决定 |diff --git a/site/index.html b/site/index.htmlindex 8137e58..318374d 100644--- a/site/index.html+++ b/site/index.html@@ -3,7 +3,11 @@<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">-<title>Pre-Algebra and Algebra, Animated</title>+<title>AnimeBook — The animated bookshelf</title>+<meta name="description" content="A little library of books brought to life. Watch animated lessons, explore the ideas, and try them yourself.">+<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%231d2b27'/%3E%3Ctext x='32' y='45' text-anchor='middle' font-size='48' fill='%23f0b45a'%3E∞%3C/text%3E%3C/svg%3E">+<link rel="stylesheet" href="lib/bookshelf.css">+<script src="lib/bookshelf.js" defer></script><link rel="expect" href="#ch01" blocking="render"><style>:root {@@ -117,7 +121,25 @@ main#contents { padding-bottom: 80px; }}</style></head>-<body>+<body class="shelved">+<main id="shelf" aria-labelledby="shelf-title">+ <header class="shelf-top">+ <a class="shelf-brand" href="#" aria-label="AnimeBook bookshelf"><span class="brand-mark" aria-hidden="true">∞</span>AnimeBook<span class="brand-dot" aria-hidden="true"></span></a>+ <span class="shelf-top-note">A little library, brought to life.</span>+ </header>+ <section class="shelf-intro">+ <p class="shelf-eyebrow"><span aria-hidden="true"></span>The animated bookshelf</p>+ <h1 id="shelf-title">Good books.<br><em>In motion.</em></h1>+ <p>Ideas you can see, stories you can step into.<br>Pick a book. Let it come to life.</p>+ <svg class="intro-doodle" viewBox="0 0 180 130" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M25 86Q45 67 83 83V28Q48 10 25 26Z M83 83Q118 66 151 85V27Q118 9 83 28 M83 83V103 M18 100Q45 88 77 101 M90 101Q123 87 158 103"/><path class="doodle-line" pathLength="1" d="M37 39Q51 32 68 38 M37 51Q51 44 68 50 M98 37Q115 31 136 38 M99 50Q117 43 136 51"/><path d="M160 10V20 M155 15H165 M11 48V56 M7 52H15"/></g></svg>+ </section>+ <section class="shelf-collection" aria-labelledby="collection-title">+ <div class="collection-heading"><h2 id="collection-title">On the shelf</h2><span id="shelf-count"></span></div>+ <div id="shelf-books"></div>+ <noscript><p>Open <a href="ch01/">Chapter 1: Types of numbers</a>. JavaScript enables the bookshelf and interactive lessons.</p></noscript>+ </section>+ <footer class="shelf-footer"><span>Made to be watched. Built to be explored.</span><span>One book at a time.<span class="footer-star" aria-hidden="true">✳</span></span></footer>+</main><section id="cover"><div class="chalk" aria-hidden="true"><span style="left:7%;top:13%;--d:1.6">a + b = b + a</span>@@ -137,12 +159,14 @@ main#contents { padding-bottom: 80px; }<a class="btn quiet" id="resume" hidden></a></div><p class="meta" id="meta"></p>+ <a class="back-shelf cover-back" href="#">← Back to the bookshelf</a></section><main id="contents"><header class="top">- <a class="home" href="#" aria-label="Back to the cover"><svg class="mascot" id="guideSmall" width="52" height="36"></svg><strong>Pre-Algebra <i>&</i> Algebra</strong></a>+ <a class="home" href="#book" aria-label="Back to the cover"><svg class="mascot" id="guideSmall" width="52" height="36"></svg><strong>Pre-Algebra <i>&</i> Algebra</strong></a><span class="prog" id="prog"></span>+ <a class="back-shelf contents-back" href="#">← Bookshelf</a></header><div id="units"></div></main>@@ -214,18 +238,26 @@ for (const svg of document.querySelectorAll('svg.mascot')) {`<path d="M55 62Q60 67 65 62" ${ln} stroke-width="3.5"/></g></g>`;}-// Cover and contents share this page: an empty hash shows the cover, any other hash the contents.+// The bookshelf, book cover (#book), and contents (#contents or #chNN) share this page.// Lessons link back with #chNN, so the reader lands on the chapter they just left.const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;function show(animate) {- const open = location.hash.length > 1;+ const shelf = location.hash.length <= 1;+ const open = !shelf && location.hash !== '#book';const apply = () => {+ document.body.classList.toggle('shelved', shelf);document.body.classList.toggle('open', open);+ document.title = shelf ? 'AnimeBook — The animated bookshelf' : 'Pre-Algebra and Algebra, Animated';document.body.classList.toggle('stagger', animate && open);const here = open ? document.getElementById(location.hash.slice(1)) : null;document.querySelectorAll('.here').forEach(e => e.classList.remove('here'));if (here?.classList.contains('ch')) { here.scrollIntoView({ block: 'center' }); here.classList.add('here'); }else scrollTo(0, 0);+ if (animate) {+ const heading = document.querySelector(shelf ? '#shelf-title' : open ? '#contents .home' : '#cover h1');+ heading?.setAttribute('tabindex', '-1');+ heading?.focus({ preventScroll: true });+ }};if (animate && document.startViewTransition && !reduced) document.startViewTransition(apply).ready.catch(() => {}); // an interrupted transition just endselse apply();diff --git a/site/lib/bookshelf.css b/site/lib/bookshelf.cssnew file mode 100644index 0000000..5bef791--- /dev/null+++ b/site/lib/bookshelf.css@@ -0,0 +1,99 @@+/* The bookshelf lives beside the existing book, using the same chalk palette. */+body.shelved #cover, body:not(.shelved) #shelf { display: none; }+#shelf { max-width: 1200px; padding: 0 48px; margin: 0 auto; }+.shelf-top { display: flex; justify-content: space-between; align-items: center; min-height: 98px; border-bottom: 1px solid #ece8dc24; gap: 20px; }+.shelf-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-size: 20px; font-weight: 600; letter-spacing: -.6px; }+.brand-mark { font: 36px/.8 var(--book); color: var(--task); }+.brand-dot { width: 5px; height: 5px; background: var(--task); border-radius: 50%; align-self: flex-end; margin-bottom: 7px; margin-left: -4px; }+.shelf-top-note { font: italic 16px var(--book); color: var(--dim); }+.shelf-intro { padding: 65px 0 47px; position: relative; }+.shelf-eyebrow { display: flex; align-items: center; gap: 9px; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .19em; font-weight: 600; margin: 0 0 21px; }+.shelf-eyebrow span { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 12px #8fd6b035; }+#shelf-title { font: 400 clamp(52px, 6.4vw, 80px)/1.02 var(--book); letter-spacing: -.045em; margin: 0 0 23px; view-transition-name: none; }+#shelf-title em { color: var(--task); font-weight: 400; }+.shelf-intro > p:last-of-type { color: var(--dim); font-size: 17px; line-height: 1.65; margin: 0; }+.intro-doodle { position: absolute; width: 170px; right: 48px; top: 96px; color: var(--chalk); opacity: .3; rotate: -8deg; }+.doodle-line { stroke-dasharray: 1; animation: shelf-ink 1.6s ease-out .3s backwards; }+.collection-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; border-bottom: 1px solid #ece8dc24; padding-bottom: 15px; }+.collection-heading h2 { margin: 0; font: 400 24px/1.2 var(--book); }+#shelf-count { font-size: 12px; color: var(--dim); }+.shelf-book { display: grid; grid-template-columns: 43% 1fr; gap: 56px; padding: 51px 0 56px; align-items: center; }+.shelf-book + .shelf-book { border-top: 1px solid #ece8dc24; }+.book-display { position: relative; display: flex; justify-content: center; padding: 10px 20px 31px; perspective: 1100px; }+.book-object { display: block; position: relative; width: 255px; height: 336px; flex-shrink: 0; text-decoration: none; transform-style: preserve-3d; transform: rotateY(-14deg) rotateZ(-3deg); transition: transform .55s var(--ease); }+.book-object:hover, .book-object:focus-visible { transform: rotateY(-24deg) rotateZ(-1deg) translateY(-7px); }+.book-object:focus-visible { outline-offset: 12px; }+.book-front { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 28px 25px 22px; border: 1px solid #8bb39770; border-left: 11px solid #244333; border-radius: 3px 7px 7px 3px; background: linear-gradient(100deg, #1c3329, #345644 50%, #2e4c3c); box-shadow: inset 3px 0 4px #0c241c70, inset -1px 0 2px #92b49330, 17px 20px 24px #09171060; transform: translateZ(12px); overflow: hidden; }+.book-front::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 35%, #ffffe510 48%, transparent 60%); }+.book-pages { position: absolute; left: 8px; top: 3px; width: 100%; height: calc(100% - 6px); background: repeating-linear-gradient(0deg, #d0c9b4 0 1px, #e9e2ce 1px 3px); border-radius: 3px 8px 8px 3px; transform: translateZ(-9px); box-shadow: 14px 18px 25px #08110e70; }+.book-pages::after { content: ''; position: absolute; width: 20px; height: 100%; right: -1px; transform-origin: right center; transform: rotateY(90deg); background: repeating-linear-gradient(90deg, #cbc4ad 0 1px, #eee8d4 1px 3px); }+.book-series { color: #c6d7c7; font-size: 8px; font-weight: 600; letter-spacing: .19em; text-transform: uppercase; }+.book-cover-title { display: flex; flex-direction: column; margin-top: 22px; font: 400 31px/1.17 var(--book); letter-spacing: -.8px; color: #eeeade; }+.book-cover-title i { color: #f2c078; }+.book-picture { margin: 15px -11px 0; flex: 1; display: flex; align-items: center; }+.book-art { width: 100%; height: auto; overflow: visible; }+.book-curve { stroke-dasharray: 1; animation: shelf-ink 2s var(--ease) .5s backwards; }+.curve-point { animation: shelf-point 5s ease-in-out 2.5s infinite; }+.book-cover-bottom { font-size: 8px; letter-spacing: .18em; text-transform: uppercase; color: #c6d7c7; padding-top: 8px; border-top: 1px solid #c6d7c74a; }+.shelf-plank { position: absolute; bottom: 14px; left: 0; right: 0; height: 10px; background: linear-gradient(#536052, #303e33); border-radius: 3px; border-top: 1px solid #9ea8925e; box-shadow: 0 16px 24px #07100c55; }+.shelf-plank::before { content: ''; position: absolute; bottom: 10px; left: 6%; right: 6%; height: 28px; background: radial-gradient(ellipse, #07100c6e, transparent 70%); }+.book-category { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; font-size: 11px; letter-spacing: .15em; text-transform: uppercase; color: var(--good); }+.category-mark { border: 1px solid #8fd6b040; width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; letter-spacing: 0; border-radius: 50%; }+.book-info h3 { margin: 0 0 14px; font: 400 clamp(29px, 3vw, 38px)/1.15 var(--book); letter-spacing: -.02em; text-wrap: balance; }+.book-title-link { text-decoration: none; }+.book-title-link:hover { color: var(--task); }+.book-description { color: var(--dim); font-size: 16px; line-height: 1.65; max-width: 28em; margin: 0 0 15px; }+.book-facts { color: #c0c9bb; font-size: 11px; margin: 0 0 23px; }+.book-features { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 6px; font-size: 13px; color: var(--chalk); }+.feature-tick { display: inline-block; color: var(--task); margin-right: 12px; }+.book-actions { display: flex; flex-wrap: wrap; gap: 15px 20px; align-items: center; }+.shelf-open { display: inline-flex; align-items: center; gap: 18px; min-height: 44px; padding: 8px 0; border-bottom: 1px solid #ece8dc66; color: var(--chalk); font: 500 18px/1.3 var(--book); text-decoration: none; transition: color .25s, border-color .25s; }+.shelf-open:hover { color: var(--task); border-color: var(--task); }+.shelf-open span { font: 400 20px var(--ui); transition: transform .25s var(--ease); }+.shelf-open:hover span { transform: translateX(4px); }+.shelf-continue { font-size: 12px; color: var(--good); text-decoration: none; }+.shelf-continue:hover { text-decoration: underline; }+.shelf-progress { font-size: 11px; color: var(--dim); margin: -10px 0 16px; }+.shelf-footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px 0 27px; border-top: 1px solid #ece8dc24; color: var(--dim); font-size: 11px; }+.footer-star { display: inline-block; color: var(--task); margin-left: 12px; }+.back-shelf { color: var(--dim); font: 13px var(--ui); text-decoration: none; white-space: nowrap; }+.back-shelf:hover { color: var(--chalk); }+.cover-back { position: absolute; top: 24px; left: 24px; }+.contents-back { margin-left: 16px; }+@keyframes shelf-ink { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }+@keyframes shelf-point { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(19px, 9px); } }+@media (max-width: 850px) {+ #shelf { padding: 0 28px; }+ .shelf-book { gap: 32px; grid-template-columns: 42% 1fr; }+ .book-object { width: 224px; height: 302px; }+ .book-front { padding: 24px 20px 20px; }+ .book-cover-title { font-size: 27px; }+ .intro-doodle { right: 8px; }+}+@media (max-width: 600px) {+ #shelf { padding: 0 22px; }+ .shelf-top { min-height: 74px; }+ .shelf-top-note { display: none; }+ .shelf-intro { padding: 43px 0 36px; }+ #shelf-title { font-size: 59px; }+ .shelf-intro > p:last-of-type { font-size: 15px; }+ .intro-doodle { width: 104px; top: 101px; right: -8px; opacity: .16; }+ .collection-heading h2 { font-size: 21px; }+ #shelf-count { font-size: 10px; }+ .shelf-book { display: flex; flex-direction: column; gap: 30px; padding: 37px 0 40px; align-items: stretch; }+ .book-display { max-width: 350px; width: 100%; margin: 0 auto; }+ .book-object { width: 224px; height: 302px; }+ .book-info h3 { font-size: 31px; }+ .book-description { font-size: 15px; }+ .book-facts { font-size: 11px; }+ .book-features { margin-bottom: 22px; }+ .shelf-footer { flex-direction: column; gap: 9px; font-size: 10px; }+ .contents-back { margin-left: 0; font-size: 11px; }+ #contents .top { flex-wrap: wrap; gap: 8px 12px; }+ #contents .prog { font-size: 12px; }+}+@media (prefers-reduced-motion: reduce) {+ .book-object { transition: none; }+ .book-object:hover, .book-object:focus-visible { transform: rotateY(-14deg) rotateZ(-3deg); }+ .book-curve, .doodle-line, .curve-point { animation: none; }+}diff --git a/site/lib/bookshelf.js b/site/lib/bookshelf.jsnew file mode 100644index 0000000..9f4f2b2--- /dev/null+++ b/site/lib/bookshelf.js@@ -0,0 +1,91 @@+/* The public bookshelf. Add real, published books here; no build step required.+ * This first book shares index.html with its contents, so its counts and saved+ * place come from the rendered chapter cards, never a second chapter list.+ */+'use strict';+(() => {+ const books = [{+ id: 'pre-algebra', title: 'Pre-Algebra & Algebra', subject: 'Mathematics',+ href: '#book', coverTitle: ['Pre-Algebra', '& Algebra'], series: 'An animated workbook',+ description: 'From the first number line to the shape of an equation. See the math unfold, one idea at a time.',+ contents: '#units',+ }];+ const el = (tag, cls, text) => {+ const node = document.createElement(tag);+ if (cls) node.className = cls;+ if (text != null) node.textContent = text;+ return node;+ };+ const link = (cls, text, href) => {+ const a = el('a', cls, text);+ a.href = href;+ return a;+ };+ // Original SVG cover artwork: a graph draws itself as a point traces the curve.+ const artwork = `<svg viewBox="0 0 260 175" class="book-art" aria-hidden="true">+ <g fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path d="M25 140H238 M52 158V20" stroke="#a8c6ba" stroke-width="1" opacity=".45"/>+ <path d="M49 80H55 M49 110H55 M105 137V143 M158 137V143 M211 137V143" stroke="#a8c6ba" opacity=".5"/>+ <path d="M52 132C88 131 92 51 128 53S185 137 231 32" stroke="#f2c078" stroke-width="3" class="book-curve" pathLength="1"/>+ <circle cx="128" cy="53" r="5" fill="#f2c078" stroke="#f2c078" class="curve-point"/>+ <path d="M89 81C63 28 178 31 167 80S59 128 89 81C117 39 179 36 182 77S114 123 89 81Z" stroke="#e9eee2" stroke-width="2" opacity=".07"/>+ </g>+ <text x="180" y="155" fill="#d3ded5" opacity=".6" font-size="17" font-family="Georgia,serif" font-style="italic">f(x)</text>+ <text x="24" y="26" fill="#e9eee2" opacity=".6" font-size="22" font-family="Georgia,serif">∞</text>+ </svg>`;+ const container = document.getElementById('shelf-books');+ for (const [index, book] of books.entries()) {+ const contents = document.querySelector(book.contents);+ const chapters = contents.querySelectorAll('.ch');+ const units = contents.querySelectorAll('.unit').length;+ const last = contents.querySelector('.ch.last');+ const finished = contents.querySelectorAll('.ch.done').length;+ const row = el('article', 'shelf-book');+ row.style.setProperty('--book-index', index);+ const display = el('div', 'book-display');+ const cover = link('book-object', '', book.href);+ cover.setAttribute('aria-label', `Open ${book.title}: ${chapters.length} chapters`);+ const pages = el('span', 'book-pages');+ pages.setAttribute('aria-hidden', 'true');+ cover.append(pages);+ const front = el('span', 'book-front');+ front.append(el('span', 'book-series', book.series));+ const title = el('span', 'book-cover-title');+ title.append(el('span', '', book.coverTitle[0]), el('i', '', book.coverTitle[1]));+ front.append(title);+ const picture = el('span', 'book-picture');+ picture.innerHTML = artwork;+ front.append(picture, el('span', 'book-cover-bottom', 'Watch · Explore · Try'));+ cover.append(front);+ display.append(cover, el('span', 'shelf-plank'));+ const info = el('div', 'book-info');+ const category = el('p', 'book-category', book.subject);+ category.prepend(el('span', 'category-mark', String(index + 1).padStart(2, '0')));+ const heading = el('h3', '');+ heading.append(link('book-title-link', book.title, book.href));+ info.append(category, heading, el('p', 'book-description', book.description));+ const facts = el('p', 'book-facts', `${chapters.length} chapters · ${units} units · Narrated lessons`);+ info.append(facts);+ const features = el('ul', 'book-features');+ for (const text of ['Ideas drawn step by step', 'Quick checks inside the animation', 'Practice you can play with']) {+ const li = el('li', '', text);+ li.prepend(el('span', 'feature-tick', '↗'));+ features.append(li);+ }+ info.append(features);+ const actions = el('div', 'book-actions');+ const open = link('shelf-open', 'Explore this book', book.href);+ open.append(el('span', '', '→'));+ actions.append(open);+ if (last) {+ const chapter = last.querySelector('b').textContent;+ actions.append(link('shelf-continue', `Continue chapter ${chapter} →`, last.getAttribute('href')));+ const status = el('p', 'shelf-progress', `${finished} of ${chapters.length} chapters finished`);+ info.append(status);+ }+ info.append(actions);+ row.append(display, info);+ container.append(row);+ }+ document.getElementById('shelf-count').textContent = `${books.length} ${books.length === 1 ? 'book' : 'books'} · A growing collection`;+})();