feat: html 分类入夹+全站蓄力翻页链 (#47)
Build Tutorial / Build @stack/tutorial (kaniko) (push) Successful in 4m50s
## 背景
24 个 html 全部平铺在 apps/tutorial/,文件名前缀(blog-*、design-*)承担分类职责,互链散落在 SITE_NAV 与若干 `./ch${n}.html` 模板里;滚动蓄力翻页只串了 ch1–ch7,其余 12 个页面不在链上。
## 变更内容
**目录重排(URL 与代码解耦)**
- 根 `index.html` 不动;其余按 navbar 板块入夹:`tutorial/`(learn→index+ch1–7 原名)、`skills/`、`blog/`(枢纽 index+月份/文章去前缀)、`design/`(枢纽 index+五册去前缀)、`practice/`;`src/pages/` 不动
- 夹内 html 资产引用 `./src/`→`../src/`;全部 html head 补 sessionStorage vt 握手内联脚本(原 ch1–7 独有)
**全站翻页链(src/lib/pages.ts 注册表)**
- PAGES 有序数组即环形链序:index→learn→ch1–7→html/css/javascript→blog(月升序,月页→文章升序)→design 五册→practice→回环 index;blog 段由 content/blogs.ts 派生
- relHref 按路径深度算相对链接(兼容 --base 代理);siteNavFor 生成全站导航——站点路径唯一事实源
- PageFlipZone 上移到 Page 装配层;FlipTarget 泛化为 meta{title,color},气泡文案动态化;新 PageTurnBar 页底 ←上一页/返回首页/下一页→ 全站铺开
**构建设施**
- stack.config 递归扫 html;ssg 预渲染临时文件名展平;stack dev server 无斜杠目录 URL 308 补斜杠
**e2e 与文档**
- 全量 URL 对齐+跨段断言(index→learn、ch7→skills、practice→index 环回);修复四处存量断裂(runner 探活 URL、#45 抽屉收起后 role 断言、b0fdb90 编辑器默认收起后缺 openEditor、esbuild.wasm 相对路径 404);视觉基线重建;docs/page-flip-research 补「全站翻页链」一节
## 自测结果
- 构建:ssg 24/24 页预渲染;preview 下新 URL 全部 200,`/blog`→308→`/blog/`,全站链接零死链(playwright 逐链接探测)
- 蓄力翻页实测:index→learn、ch7→skills、practice→index 环回,data-vt 方向握手读后即清
- e2e:功能 118/119、visual 10/10;唯一失败 `learn.spec「绕过气泡手动操作」` joyride 用例为**存量断裂**(已在 main 基线复现,遮罩语义与该用例前提冲突,与本 PR 无关)
- biome 触达文件零诊断;strip-comments 零清除
- 视觉对照(桌面 1280×900,fonts.ready 后截图;页底翻页条全站新增):
| 页面 | before | after |
| --- | --- | --- |
| 设计册·颜色页底 |  |  |
| 博客文章页底 |  |  |
| 首页 |  |  |
---------
Co-authored-by: cqh963852 <cqh963852@hotmail.com>
Reviewed-on: #47
No files matched your search
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>博客 · 2025-07</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/blog-2025-07/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>博客 · 2026-08</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/blog-2026-08/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>gorzil:面向多人协作的 AI 原生工具开发自述</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/blog-gorzil/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>sapling_transformer 近半月开发自述</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/blog-sapling-transformer/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>博客 · idealjs stack 教程</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/blog/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>博客 · 2025-07</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/blog-2025-07/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>博客 · 2026-08</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/blog-2026-08/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>gorzil:面向多人协作的 AI 原生工具开发自述</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/blog-gorzil/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>博客 · idealjs stack 教程</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/blog/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>sapling_transformer 近半月开发自述</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/blog-sapling-transformer/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CSS · 技能熟悉 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<meta name="description" content="技能熟悉 · CSS:用选择器与布局控制页面样式。专项教程逐步补充中。" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/css/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 颜色 · 鲜艳与碰撞</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/design-colors/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 组件 · 入口载体与学习工作台</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/design-components/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 阴影 · 硬投影与拿起</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/design-shadow/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 符号、形状 · 装饰即语义</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/design-symbols/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 字体 · 一套字阶,两种强调</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/design-typography/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · idealjs stack 教程</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/design/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 颜色 · 鲜艳与碰撞</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/design-colors/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 组件 · 入口载体与学习工作台</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/design-components/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · idealjs stack 教程</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/design/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 阴影 · 硬投影与拿起</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/design-shadow/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 符号、形状 · 装饰即语义</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/design-symbols/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>设计系统 · 字体 · 一套字阶,两种强调</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/design-typography/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test'
|
||||
|
||||
test.describe('教程首页', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/learn.html')
|
||||
await page.goto('/tutorial/')
|
||||
})
|
||||
|
||||
test('成品演示可增删、勾选;空白输入不产生任务,刷新回到示例', async ({ page }) => {
|
||||
@@ -40,8 +40,9 @@ test.describe('教程首页', () => {
|
||||
})
|
||||
|
||||
test('站头恒为完整四行:四个行首与各条目在任何页面不缩减', async ({ page }) => {
|
||||
const header = page.locator('main > header')
|
||||
const header = page.locator('main header')
|
||||
|
||||
await page.getByLabel('展开导航网格').click()
|
||||
for (const label of ['全栈教程', '博客', '设计系统', '在线练习']) {
|
||||
await expect(header.getByRole('link', { name: label, exact: true })).toHaveCount(1)
|
||||
}
|
||||
@@ -55,7 +56,7 @@ test.describe('教程首页', () => {
|
||||
|
||||
test('移动端导航抽屉:对称触发器的 aria-expanded 随纯 CSS 开合翻转', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await page.goto('/learn.html')
|
||||
await page.goto('/tutorial/')
|
||||
const open = page.locator('label[aria-label="打开导航菜单"]')
|
||||
const close = page.locator('label[aria-label="收起导航菜单"]')
|
||||
const overlay = page.locator('label[for="site-nav-toggle"][aria-hidden="true"]')
|
||||
@@ -153,7 +154,7 @@ test.describe('教程首页', () => {
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/learn.html')
|
||||
await page.goto('/tutorial/')
|
||||
const trigger = page.getByRole('button', { name: /30 秒上手这个待办应用/ })
|
||||
const tooltip = page.locator('.react-joyride__tooltip')
|
||||
const demo = page.getByRole('region', { name: '待办应用演示' })
|
||||
@@ -206,7 +207,7 @@ test.describe('教程首页', () => {
|
||||
|
||||
test('新手引导:绕过气泡按钮手动操作待办,每一步仍可推进不卡死', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/learn.html')
|
||||
await page.goto('/tutorial/')
|
||||
const trigger = page.getByRole('button', { name: /30 秒上手这个待办应用/ })
|
||||
const tooltip = page.locator('.react-joyride__tooltip')
|
||||
const demo = page.getByRole('region', { name: '待办应用演示' })
|
||||
@@ -253,7 +254,7 @@ test.describe('教程首页', () => {
|
||||
|
||||
test('新手引导:开场就删光待办,改删两步自动跳过直达总结不卡死', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/learn.html')
|
||||
await page.goto('/tutorial/')
|
||||
const trigger = page.getByRole('button', { name: /30 秒上手这个待办应用/ })
|
||||
const tooltip = page.locator('.react-joyride__tooltip')
|
||||
const demo = page.getByRole('region', { name: '待办应用演示' })
|
||||
@@ -287,7 +288,7 @@ test.describe('教程首页', () => {
|
||||
})
|
||||
|
||||
test('待办演示:搜索实时过滤,可一键清空,无匹配时给出提示', async ({ page }) => {
|
||||
await page.goto('/learn.html')
|
||||
await page.goto('/tutorial/')
|
||||
const search = page.getByRole('textbox', { name: '搜索待办' })
|
||||
await search.fill('房间')
|
||||
await expect(page.locator('.learn-todo-items li')).toHaveCount(1)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test'
|
||||
|
||||
test.describe('拟物学习组件', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/design-components.html')
|
||||
await page.goto('/design/components.html')
|
||||
})
|
||||
|
||||
test('展示 13 类可复用组件,卡片继续沿用统一硬投影', async ({ page }) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const PAGES = ['/index.html', '/design.html', '/ch7.html', '/blog.html']
|
||||
const PAGES = ['/index.html', '/design/', '/tutorial/ch7.html', '/blog/']
|
||||
|
||||
test.describe('navbar 品牌徽章一致性', () => {
|
||||
test('各页面 brand 徽章:无背景填充、同款 3px 阴影(logo 恒定,不随页面翻转)', async ({
|
||||
|
||||
@@ -13,7 +13,7 @@ async function openVisualPage(
|
||||
browser: Browser,
|
||||
baseURL: string | undefined,
|
||||
freezeVt: boolean,
|
||||
path = './ch1.html',
|
||||
path = '/tutorial/ch1.html',
|
||||
) {
|
||||
const context = await browser.newContext({
|
||||
baseURL,
|
||||
@@ -87,7 +87,7 @@ test('翻页视觉 · next 翻页 VT 中间帧(50% 冻结)', async ({ browse
|
||||
})
|
||||
|
||||
test('翻页视觉 · prev 翻页 VT 中间帧(50% 冻结)', async ({ browser, baseURL }) => {
|
||||
const page = await openVisualPage(browser, baseURL, true, './ch2.html')
|
||||
const page = await openVisualPage(browser, baseURL, true, '/tutorial/ch2.html')
|
||||
await page.waitForTimeout(300)
|
||||
await chargeByWheel(page, -250)
|
||||
await page.waitForURL('**/ch1.html')
|
||||
|
||||
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 156 KiB |
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
import type { Page } from '@playwright/test'
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const chargeByWheel = async (page: Page, deltaY: number, steps = 20) => {
|
||||
for (let i = 0; i < steps; i += 1) {
|
||||
@@ -37,7 +37,7 @@ const edgeSettled = (side: 'next' | 'prev') => {
|
||||
}
|
||||
|
||||
test('charge past threshold at bottom flips to next chapter', async ({ page }) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.waitForTimeout(200)
|
||||
@@ -51,7 +51,7 @@ test('charge past threshold at bottom flips to next chapter', async ({ page }) =
|
||||
test('arrival momentum never flips; charge holds after wheel stops; reverse wheel clears it', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.mouse.move(640, 450)
|
||||
await page.mouse.wheel(0, 6000)
|
||||
@@ -76,7 +76,7 @@ test('arrival momentum never flips; charge holds after wheel stops; reverse whee
|
||||
})
|
||||
|
||||
test('charge upward at top flips to previous chapter', async ({ page }) => {
|
||||
await page.goto('./ch2.html')
|
||||
await page.goto('/tutorial/ch2.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.mouse.move(640, 450)
|
||||
await chargeByWheel(page, -250)
|
||||
@@ -85,7 +85,7 @@ test('charge upward at top flips to previous chapter', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('mid-page wheel keeps scrolling without flipping', async ({ page }) => {
|
||||
await page.goto('./ch3.html')
|
||||
await page.goto('/tutorial/ch3.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.mouse.move(640, 450)
|
||||
await page.mouse.wheel(0, 1500)
|
||||
@@ -94,7 +94,7 @@ test('mid-page wheel keeps scrolling without flipping', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('PageDown at bottom flips to next chapter', async ({ page }) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.keyboard.press('PageDown')
|
||||
@@ -102,19 +102,19 @@ test('PageDown at bottom flips to next chapter', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('clicking the next-chapter badge jumps directly to the next chapter', async ({ page }) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.waitForTimeout(200)
|
||||
await page.mouse.move(640, 450)
|
||||
await page.mouse.wheel(0, 250)
|
||||
await page.waitForTimeout(150)
|
||||
await page.getByRole('button', { name: /翻到下一章/ }).click()
|
||||
await page.getByRole('button', { name: /下一页:第 2 章/ }).click()
|
||||
await page.waitForURL('**/ch2.html')
|
||||
})
|
||||
|
||||
test('reload returns to chapter top', async ({ page }) => {
|
||||
await page.goto('./ch2.html')
|
||||
await page.goto('/tutorial/ch2.html')
|
||||
await page.evaluate(() => {
|
||||
const el = document.querySelector('[data-scroll-root]')
|
||||
if (el instanceof HTMLElement) el.scrollTop = 600
|
||||
@@ -126,7 +126,7 @@ test('reload returns to chapter top', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('after flip the next chapter lands at top and first wheel scrolls', async ({ page }) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.waitForTimeout(200)
|
||||
@@ -156,7 +156,7 @@ test('after flip the next chapter lands at top and first wheel scrolls', async (
|
||||
test('weak bottom charge holds next edge symbols on screen, reverse wheel springs them back', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.waitForTimeout(300)
|
||||
@@ -179,7 +179,7 @@ test('weak bottom charge holds next edge symbols on screen, reverse wheel spring
|
||||
test('weak top charge holds prev edge symbols on screen, reverse wheel springs them back', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('./ch2.html')
|
||||
await page.goto('/tutorial/ch2.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.mouse.move(640, 450)
|
||||
await page.mouse.wheel(0, -200)
|
||||
@@ -198,7 +198,7 @@ test('weak top charge holds prev edge symbols on screen, reverse wheel springs t
|
||||
test('navbar stays collapsed by default; toggle expands an overlay without squeezing content', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('./ch1.html')
|
||||
await page.goto('/tutorial/ch1.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
const grid = page.locator('#site-nav-drawer')
|
||||
await expect(grid).toBeHidden()
|
||||
@@ -226,3 +226,38 @@ test('navbar stays collapsed by default; toggle expands an overlay without squee
|
||||
await page.getByLabel('收起导航网格').click()
|
||||
await expect(grid).toBeHidden()
|
||||
})
|
||||
|
||||
test('charging at index bottom flips into the tutorial hub with next direction', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.waitForTimeout(200)
|
||||
await page.mouse.move(640, 450)
|
||||
await chargeByWheel(page, 250)
|
||||
await page.waitForURL('**/tutorial/index.html')
|
||||
await expect(page.locator('html')).toHaveAttribute('data-vt', 'next')
|
||||
})
|
||||
|
||||
test('charging at ch7 bottom crosses into the skills section', async ({ page }) => {
|
||||
await page.goto('/tutorial/ch7.html')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(scrollToBottom)
|
||||
await page.waitForTimeout(200)
|
||||
await page.mouse.move(640, 450)
|
||||
await chargeByWheel(page, 250)
|
||||
await page.waitForURL('**/skills/html.html')
|
||||
await expect(page.locator('html')).toHaveAttribute('data-vt', 'next')
|
||||
})
|
||||
|
||||
test('charging at practice bottom loops back to the index page', async ({ page }) => {
|
||||
await page.goto('/practice/')
|
||||
await expect(page.locator('[data-flip-edge="next"]')).toHaveCount(1)
|
||||
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight))
|
||||
await page.waitForTimeout(200)
|
||||
await page.mouse.move(640, 450)
|
||||
await chargeByWheel(page, 250)
|
||||
await page.waitForURL('**/index.html')
|
||||
await expect(page.locator('html')).toHaveAttribute('data-vt', 'next')
|
||||
})
|
||||
@@ -2,10 +2,15 @@ import type { Page } from '@playwright/test'
|
||||
import { expect, test } from '@playwright/test'
|
||||
import type { TicketProps } from '../src/design-system/components/Ticket'
|
||||
|
||||
const PAGES = ['design', 'design-colors', 'design-symbols', 'design-components'] as const
|
||||
const PAGES = [
|
||||
'/design/',
|
||||
'/design/colors.html',
|
||||
'/design/symbols.html',
|
||||
'/design/components.html',
|
||||
] as const
|
||||
|
||||
async function mountTicket(page: Page, props: TicketProps = {}) {
|
||||
await page.goto('/design-components.html')
|
||||
await page.goto('/design/components.html')
|
||||
const preview = page.getByTestId('ticket-preview')
|
||||
await preview.getByLabel('孔位', { exact: true }).fill(String(props.holePosition ?? '50%'))
|
||||
await preview.getByLabel('孔径').fill(String(props.holeSize ?? 12))
|
||||
@@ -30,21 +35,21 @@ async function mountTicket(page: Page, props: TicketProps = {}) {
|
||||
|
||||
test.describe('全局画布', () => {
|
||||
for (const p of PAGES) {
|
||||
test(`${p}.html 渲染且有内容`, async ({ page }) => {
|
||||
await page.goto(`/${p}.html`)
|
||||
test(`${p} 渲染且有内容`, async ({ page }) => {
|
||||
await page.goto(`${p}`)
|
||||
await expect(page.locator('#root')).not.toBeEmpty()
|
||||
await expect(page.locator('main')).toBeVisible()
|
||||
})
|
||||
}
|
||||
|
||||
test('body 大底为纸色 #FFF9F0', async ({ page }) => {
|
||||
await page.goto('/design.html')
|
||||
await page.goto('/design/')
|
||||
const bg = await page.evaluate(() => getComputedStyle(document.body).backgroundColor)
|
||||
expect(bg).toBe('rgb(255, 249, 240)')
|
||||
})
|
||||
|
||||
test('全站无色彩渐变', async ({ page }) => {
|
||||
await page.goto('/design-colors.html')
|
||||
await page.goto('/design/colors.html')
|
||||
const gradients = await page.evaluate(() => {
|
||||
const bad: string[] = []
|
||||
document.querySelectorAll<HTMLElement>('*').forEach((el) => {
|
||||
@@ -57,7 +62,7 @@ test.describe('全局画布', () => {
|
||||
})
|
||||
|
||||
test.describe('CourseCard 规格契约', () => {
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design-components.html'))
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design/components.html'))
|
||||
|
||||
test('2px ink 描边 + 统一硬投影(单层 ink,无纸叠)', async ({ page }) => {
|
||||
const card = page.locator('a[href="#ch1"]').first()
|
||||
@@ -155,7 +160,7 @@ test.describe('CourseCard 规格契约', () => {
|
||||
})
|
||||
|
||||
test.describe('RouteLine 规格契约', () => {
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design-components.html'))
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design/components.html'))
|
||||
test.use({ reducedMotion: 'no-preference' })
|
||||
|
||||
test('线形:实线先后 2.5px 无 dash;点线同族 0.1/6 圆帽', async ({ page }) => {
|
||||
@@ -185,8 +190,8 @@ test.describe('RouteLine 规格契约', () => {
|
||||
if (!svg) return null
|
||||
const wrap = svg.parentElement
|
||||
const wb = wrap.getBoundingClientRect()
|
||||
const c1 = wrap.querySelector('a[href="./ch1.html"]').getBoundingClientRect()
|
||||
const c2 = wrap.querySelector('a[href="./ch2.html"]').getBoundingClientRect()
|
||||
const c1 = wrap.querySelector('a[href="../tutorial/ch1.html"]').getBoundingClientRect()
|
||||
const c2 = wrap.querySelector('a[href="../tutorial/ch2.html"]').getBoundingClientRect()
|
||||
const stations = [...svg.querySelectorAll('circle')]
|
||||
.map((n) => ({ cx: +(n.getAttribute('cx') ?? 0), r: +(n.getAttribute('r') ?? 0) }))
|
||||
.filter((s) => s.r === 6)
|
||||
@@ -226,7 +231,9 @@ test.describe('RouteLine 规格契约', () => {
|
||||
.find((d) => d.startsWith('M 600')),
|
||||
|
||||
cardTranslate: getComputedStyle(
|
||||
svg.parentElement.querySelector('a[data-comp="course-card"][href="./ch2.html"]'),
|
||||
svg.parentElement.querySelector(
|
||||
'a[data-comp="course-card"][href="../tutorial/ch2.html"]',
|
||||
),
|
||||
).translate,
|
||||
}
|
||||
})
|
||||
@@ -252,7 +259,7 @@ test.describe('RouteLine 规格契约', () => {
|
||||
})
|
||||
|
||||
test.describe('价值区荧光标记契约', () => {
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design-symbols.html'))
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design/symbols.html'))
|
||||
|
||||
test('荧光笔标记文字:mustard 底、无描边、微斜——是标记不是形状', async ({ page }) => {
|
||||
const s = await page.evaluate(() => {
|
||||
@@ -271,7 +278,7 @@ test.describe('价值区荧光标记契约', () => {
|
||||
})
|
||||
|
||||
test.describe('票券规格契约', () => {
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design-components.html'))
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design/components.html'))
|
||||
test.use({ reducedMotion: 'no-preference' })
|
||||
|
||||
const chapterTickets = (page: Page) =>
|
||||
@@ -546,7 +553,7 @@ test.describe('票券规格契约', () => {
|
||||
})
|
||||
|
||||
test.describe('ShadowButton 按压契约', () => {
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design-components.html'))
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design/components.html'))
|
||||
test.use({ reducedMotion: 'no-preference' })
|
||||
|
||||
test('多态渲染:有 href=a、无 href=button[type=button]、disabled=虚线占位', async ({ page }) => {
|
||||
@@ -557,7 +564,7 @@ test.describe('ShadowButton 按压契约', () => {
|
||||
expect(tags).toEqual(expect.arrayContaining(['BUTTON', 'A', 'SPAN']))
|
||||
await expect(
|
||||
page.locator('a[data-comp="shadow-button"]', { hasText: '链接 · href 渲染 a' }),
|
||||
).toHaveAttribute('href', /learn\.html/)
|
||||
).toHaveAttribute('href', /tutorial\/index\.html/)
|
||||
await expect(page.locator('button[data-comp="shadow-button"]').first()).toHaveAttribute(
|
||||
'type',
|
||||
'button',
|
||||
@@ -614,7 +621,7 @@ test.describe('ShadowButton 按压契约', () => {
|
||||
})
|
||||
|
||||
test.describe('ShadowCard · 四部曲契约', () => {
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design-components.html'))
|
||||
test.beforeEach(async ({ page }) => await page.goto('/design/components.html'))
|
||||
test.use({ reducedMotion: 'no-preference' })
|
||||
|
||||
const specimens = (page: Page) =>
|
||||
@@ -673,7 +680,7 @@ test.describe('阴影册 · hover-host 触发模型', () => {
|
||||
test.use({ reducedMotion: 'no-preference' })
|
||||
|
||||
test('宿主承接 hover:命中区不动,位移作用于内部元素(防边界震荡)', async ({ page }) => {
|
||||
await page.goto('/design-shadow.html')
|
||||
await page.goto('/design/shadow.html')
|
||||
const host = page.locator('main section .hover-host').first()
|
||||
const inner = host.locator('.hoverable-shadow')
|
||||
await expect(inner).toHaveCSS('translate', 'none')
|
||||
@@ -693,7 +700,7 @@ test.describe('阴影册 · hover-host 触发模型', () => {
|
||||
|
||||
test.describe('阴影册 · hover-host 尊重 reduced-motion', () => {
|
||||
test('reduce 下宿主 hover 只换影、不位移', async ({ page }) => {
|
||||
await page.goto('/design-shadow.html')
|
||||
await page.goto('/design/shadow.html')
|
||||
const host = page.locator('main section .hover-host').first()
|
||||
const inner = host.locator('.hoverable-shadow')
|
||||
await host.hover()
|
||||
@@ -710,13 +717,14 @@ test.describe('技能熟悉页', () => {
|
||||
] as const
|
||||
|
||||
for (const { key, name } of SKILLS) {
|
||||
test(`${key}.html 渲染有内容,导航新组「技能熟悉」当前项高亮`, async ({ page }) => {
|
||||
await page.goto(`/${key}.html`)
|
||||
test(`${key} 渲染有内容,导航新组「技能熟悉」当前项高亮`, async ({ page }) => {
|
||||
await page.goto(`/skills/${key}.html`)
|
||||
await expect(page.locator('#root')).not.toBeEmpty()
|
||||
await expect(page.locator('h1')).toHaveText(name)
|
||||
await expect(page.getByText('内容建设中')).toBeVisible()
|
||||
await page.getByLabel('展开导航网格').click()
|
||||
for (const { key: sibling } of SKILLS) {
|
||||
const item = page.locator(`#site-nav-drawer a[href="./${sibling}.html"]`)
|
||||
const item = page.locator(`#site-nav-drawer a[href="../skills/${sibling}.html"]`)
|
||||
await expect(item).toHaveClass(
|
||||
sibling === key ? /bg-paper-deep/ : /text-body hover:bg-paper-deep/,
|
||||
)
|
||||
@@ -727,11 +735,11 @@ test.describe('技能熟悉页', () => {
|
||||
|
||||
test('practice 侧栏同步出现技能熟悉组与三个入口', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
const sidebar = page.locator('#site-sidebar-drawer')
|
||||
await expect(sidebar.getByText('技能熟悉')).toBeVisible()
|
||||
for (const { key, name } of SKILLS) {
|
||||
await expect(sidebar.locator(`a[href="./${key}.html"]`)).toHaveText(name)
|
||||
await expect(sidebar.locator(`a[href="../skills/${key}.html"]`)).toHaveText(name)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,7 +1,14 @@
|
||||
import type { Page } from '@playwright/test'
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const openEditor = async (page: Page) => {
|
||||
await page.locator('[data-comp="editor-dock-tab"]').click()
|
||||
await expect(page.locator('#playground-dock-panel')).toBeVisible()
|
||||
}
|
||||
|
||||
test('模板预置 stack.config.ts:文件栏三件套,esbuild.config.json 不存在', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await expect(page.getByRole('button', { name: 'index.html', exact: true })).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: 'main.ts', exact: true })).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: 'stack.config.ts', exact: true })).toBeVisible()
|
||||
@@ -13,7 +20,8 @@ test('模板预置 stack.config.ts:文件栏三件套,esbuild.config.json
|
||||
test('无配置回退:删掉 stack.config.ts 后 script src 指向不存在文件报错不执行', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: '删除 stack.config.ts' }).click()
|
||||
await page.getByRole('button', { name: 'index.html', exact: true }).click()
|
||||
await page.getByLabel('模块代码').fill('<script type="module" src="./nope.ts"></script>')
|
||||
@@ -24,7 +32,8 @@ test('无配置回退:删掉 stack.config.ts 后 script src 指向不存在文
|
||||
})
|
||||
|
||||
test('无配置回退:改写 script src 指向新建文件,运行走新入口', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: '删除 stack.config.ts' }).click()
|
||||
await page.getByLabel('新文件名').fill('hello.ts')
|
||||
await page.getByRole('button', { name: '新建文件', exact: true }).click()
|
||||
@@ -39,7 +48,8 @@ test('无配置回退:改写 script src 指向新建文件,运行走新入
|
||||
})
|
||||
|
||||
test('inputs 含 index.html:script src 指向 main.ts,运行走 main.ts 闭包', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'stack.config.ts', exact: true }).click()
|
||||
await page
|
||||
.getByLabel('模块代码')
|
||||
@@ -55,7 +65,8 @@ test('inputs 含 index.html:script src 指向 main.ts,运行走 main.ts 闭
|
||||
test('inputs 含 index.html:改写 body 文本后预览框渲染改后文本——index.html 被沙盒应用', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'index.html', exact: true }).click()
|
||||
await page
|
||||
.getByLabel('模块代码')
|
||||
@@ -73,7 +84,8 @@ test('inputs 含 index.html:改写 body 文本后预览框渲染改后文本
|
||||
})
|
||||
|
||||
test('inputs 与 entry 同时出现:inputs 优先,entry 不再消费', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'stack.config.ts', exact: true }).click()
|
||||
await page
|
||||
.getByLabel('模块代码')
|
||||
@@ -88,7 +100,8 @@ test('inputs 与 entry 同时出现:inputs 优先,entry 不再消费', async
|
||||
})
|
||||
|
||||
test('stack.config.ts 改 entry(旧形态兼容):运行走 entry', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByLabel('新文件名').fill('hello.ts')
|
||||
await page.getByRole('button', { name: '新建文件', exact: true }).click()
|
||||
await page.getByRole('button', { name: 'hello.ts', exact: true }).click()
|
||||
@@ -102,7 +115,8 @@ test('stack.config.ts 改 entry(旧形态兼容):运行走 entry', async (
|
||||
})
|
||||
|
||||
test('inputs 指向不存在的文件:报错不执行', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'stack.config.ts', exact: true }).click()
|
||||
await page
|
||||
.getByLabel('模块代码')
|
||||
@@ -115,7 +129,8 @@ test('inputs 指向不存在的文件:报错不执行', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('stack.config.ts 的 entry 指向不存在的文件:报错不执行', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'stack.config.ts', exact: true }).click()
|
||||
await page.getByLabel('模块代码').fill("export default {\n entry: 'nope.ts',\n}\n")
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
@@ -125,7 +140,8 @@ test('stack.config.ts 的 entry 指向不存在的文件:报错不执行', asy
|
||||
})
|
||||
|
||||
test('stack.config.ts 语法错误:构建徽章报错,不执行不出预览', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'stack.config.ts', exact: true }).click()
|
||||
await page.getByLabel('模块代码').fill('const = ;\n')
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
import type { Page } from '@playwright/test'
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const openEditor = async (page: Page) => {
|
||||
await page.locator('[data-comp="editor-dock-tab"]').click()
|
||||
await expect(page.locator('#playground-dock-panel')).toBeVisible()
|
||||
}
|
||||
|
||||
const RUNTIME_ORIGIN = 'http://localhost:9912'
|
||||
|
||||
test('iframe 恰为 allow-scripts,src 指向独立源运行时', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
const frame = page.locator('[data-testid="sandbox-frame"]')
|
||||
await expect(frame).toHaveAttribute('sandbox', 'allow-scripts')
|
||||
await expect(frame).toHaveAttribute('src', `${RUNTIME_ORIGIN}/`)
|
||||
})
|
||||
|
||||
test('握手自证:独立源部署+父窗口访问已阻断,无隔离异常', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
const status = page.locator('[data-testid="runtime-status"]')
|
||||
await expect(status).toContainText(`运行时源:${RUNTIME_ORIGIN}(独立源部署)`, {
|
||||
timeout: 10_000,
|
||||
@@ -23,7 +29,8 @@ test('握手自证:独立源部署+父窗口访问已阻断,无隔离异
|
||||
test('运行预置 template:宿主 stack 构建后输出面板回传 hello, template,预览框可见并收尾', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
const out = page.getByRole('region', { name: '输出' })
|
||||
await expect(out).toContainText('hello, template', { timeout: 20_000 })
|
||||
@@ -32,7 +39,8 @@ test('运行预置 template:宿主 stack 构建后输出面板回传 hello, te
|
||||
})
|
||||
|
||||
test('异常回传:顶层抛错以 error 级别显示', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'main.ts', exact: true }).click()
|
||||
await page.getByLabel('模块代码').fill(`throw new Error('boom from sandbox')\n`)
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
@@ -41,7 +49,8 @@ test('异常回传:顶层抛错以 error 级别显示', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('宿主构建失败:语法错误带「构建」徽章报错,不执行不出预览', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: 'main.ts', exact: true }).click()
|
||||
await page.getByLabel('模块代码').fill('const = ;\n')
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
|
||||
@@ -11,7 +11,7 @@ async function addFile(page: import('@playwright/test').Page, name: string) {
|
||||
}
|
||||
|
||||
test('新建文件:进列表并自动激活', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await addFile(page, 'utils.js')
|
||||
const tab = page.getByRole('button', { name: 'utils.js', exact: true })
|
||||
@@ -20,7 +20,7 @@ test('新建文件:进列表并自动激活', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('切换文件:两份代码互不串', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await addFile(page, 'utils.js')
|
||||
await page.getByLabel('模块代码').fill('export const one = 1')
|
||||
@@ -33,7 +33,7 @@ test('切换文件:两份代码互不串', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('删除文件:删活跃文件后切到首个剩余文件,最后一份不可再删', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await addFile(page, 'utils.js')
|
||||
await page.getByRole('button', { name: '删除 utils.js' }).click()
|
||||
@@ -56,7 +56,7 @@ test('删除文件:删活跃文件后切到首个剩余文件,最后一份
|
||||
})
|
||||
|
||||
test('文件名白名单:路径与非法字符被拒并提示', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await addFile(page, '../evil')
|
||||
await expect(page.getByTestId('file-name-error')).toContainText('文件名只能')
|
||||
|
||||
@@ -6,7 +6,7 @@ async function openEditor(page: import('@playwright/test').Page) {
|
||||
}
|
||||
|
||||
test('html 身体注入:运行后预览框渲染 #app 文本', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
const out = page.getByRole('region', { name: '输出' })
|
||||
@@ -18,7 +18,7 @@ test('html 身体注入:运行后预览框渲染 #app 文本', async ({ page }
|
||||
})
|
||||
|
||||
test('ch7 实验室:template 跑起来,预览框可见且 #app 渲染', async ({ page }) => {
|
||||
await page.goto('/ch7.html')
|
||||
await page.goto('/tutorial/ch7.html')
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
const out = page.getByRole('region', { name: '输出' })
|
||||
await expect(out).toContainText('hello, template', { timeout: 30_000 })
|
||||
@@ -32,7 +32,7 @@ test('ch7 实验室:template 跑起来,预览框可见且 #app 渲染', asyn
|
||||
})
|
||||
|
||||
test('入口文档被删:运行报错、不执行、不出预览', async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
await openEditor(page)
|
||||
await page.getByRole('button', { name: '删除 index.html' }).click()
|
||||
await page.getByRole('button', { name: '运行 ▶' }).click()
|
||||
|
||||
@@ -7,7 +7,7 @@ const OVERLAY = 'label[for="site-sidebar-toggle"][aria-hidden="true"]'
|
||||
test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
|
||||
test('桌面:顶部 navbar 退场,侧栏常驻在场', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/practice.html', { timeout: 20_000 })
|
||||
await page.goto('/practice/', { timeout: 20_000 })
|
||||
await expect(page.locator('header')).toHaveCount(0)
|
||||
const sidebar = page.locator(SIDEBAR)
|
||||
await expect(sidebar).toBeVisible()
|
||||
@@ -19,7 +19,7 @@ test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
|
||||
|
||||
test('桌面:brand 徽章 ghost 同款(无背景填充+3px 阴影),在线练习组高亮', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/practice.html', { timeout: 20_000 })
|
||||
await page.goto('/practice/', { timeout: 20_000 })
|
||||
const brand = page.locator(`${SIDEBAR} a`).first()
|
||||
await expect(brand).toHaveText('idealjs stack')
|
||||
const background = await brand.evaluate((el) => getComputedStyle(el).backgroundColor)
|
||||
@@ -34,7 +34,7 @@ test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
|
||||
|
||||
test('桌面:主区一屏放下,沙箱已撤出主区住进右缘侧栏', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.goto('/practice.html', { timeout: 20_000 })
|
||||
await page.goto('/practice/', { timeout: 20_000 })
|
||||
await expect(page.getByRole('heading', { name: '在线练习' })).toBeVisible()
|
||||
await expect(page.locator('#practice-sandbox')).toHaveCount(0)
|
||||
const overflow = await page.evaluate(
|
||||
@@ -45,7 +45,7 @@ test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
|
||||
|
||||
test('移动:抽屉开合,brand 同款,遮罩点按收起', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await page.goto('/practice.html', { timeout: 20_000 })
|
||||
await page.goto('/practice/', { timeout: 20_000 })
|
||||
const sidebar = page.locator(SIDEBAR)
|
||||
await expect(sidebar).toBeHidden()
|
||||
await page.locator(OPENER).click()
|
||||
|
||||
@@ -15,7 +15,7 @@ const TIPS_PANEL = '#tips-dock-panel'
|
||||
|
||||
test.describe('练习场 · 陪练 agent 贴签(右下角)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
})
|
||||
|
||||
test('停靠右下角,aria 关系正确;点击展开、再点与 Esc 收起', async ({ page }) => {
|
||||
@@ -71,7 +71,7 @@ test.describe('练习场 · 陪练 agent 贴签(右下角)', () => {
|
||||
|
||||
test.describe('练习场 · 验收清单夹板(顶部右上)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
})
|
||||
|
||||
test('夹具停靠页面右上,aria 关系正确;点击拉出清单、再点与 Esc 收回', async ({ page }) => {
|
||||
@@ -154,7 +154,7 @@ test.describe('练习场 · 验收清单夹板(顶部右上)', () => {
|
||||
|
||||
test.describe('练习场 · tips 喂给陪练(右上角)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
})
|
||||
|
||||
test('tips 贴签停靠右上角,默认收起;点击展开流水线板、再点与 Esc 收起,与验收夹具互斥', async ({
|
||||
@@ -260,7 +260,7 @@ test.describe('练习场 · tips 喂给陪练(右上角)', () => {
|
||||
|
||||
test.describe('练习场 · playground 侧栏(沙箱 + 编辑器)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
})
|
||||
|
||||
test('沙箱撤出主区,整体住进右缘侧栏;编辑器与沙箱两个独特贴签停靠右缘', async ({ page }) => {
|
||||
@@ -386,7 +386,7 @@ test.describe('练习场 · 布局自查', () => {
|
||||
test('320/390/768/1280 无横向溢出,清单夹具与 tips 贴签停靠右上、陪练贴签右下、编辑器签右缘', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/practice.html')
|
||||
await page.goto('/practice/')
|
||||
for (const width of [320, 390, 768, 1280]) {
|
||||
await page.setViewportSize({ width, height: 900 })
|
||||
const overflow = await page.evaluate(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const CASES: [name: string, path: string][] = [
|
||||
['design', '/design.html'],
|
||||
['design-colors', '/design-colors.html'],
|
||||
['design-symbols', '/design-symbols.html'],
|
||||
['design-components', '/design-components.html'],
|
||||
['design-shadow', '/design-shadow.html'],
|
||||
['design', '/design/'],
|
||||
['design-colors', '/design/colors.html'],
|
||||
['design-symbols', '/design/symbols.html'],
|
||||
['design-components', '/design/components.html'],
|
||||
['design-shadow', '/design/shadow.html'],
|
||||
]
|
||||
|
||||
for (const [name, path] of CASES) {
|
||||
|
||||
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 822 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 278 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 129 KiB |
@@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>HTML · 技能熟悉 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<meta name="description" content="技能熟悉 · HTML:用标记描述网页结构。专项教程逐步补充中。" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/html/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,15 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>idealjs stack · 全栈教程与开发实践</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<meta
|
||||
name="description"
|
||||
content="从第一个网页,到完整的应用。idealjs stack 提供全栈工程师教程,分享开发经验与工程实践,并提供跑在浏览器里的在线 Agent 练习场。"
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>JavaScript · 技能熟悉 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<meta name="description" content="技能熟悉 · JavaScript:让页面响应操作、管理数据。专项教程逐步补充中。" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/javascript/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>全栈教程 · 做一个自己的待办清单 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<meta name="description" content="从页面、交互到 API 和数据库,逐步完成一个单人版 TodoList。了解技术积木、浏览器内运行时与 Agent 练习环境、预计学习时间,以及贯穿全栈的数据控制。" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="./src/pages/learn/learn.css" />
|
||||
<link rel="stylesheet" href="./src/pages/learn/learn-todo.css" />
|
||||
<link rel="stylesheet" href="./src/pages/learn/learn-tour.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/learn/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -27,7 +27,8 @@ export default defineConfig({
|
||||
timeout: 300_000,
|
||||
},
|
||||
{
|
||||
command: 'yarn workspace @stack/web-runner dev --port 9912',
|
||||
command:
|
||||
'yarn workspace @stack/web-runner build:runtime && yarn workspace @stack/web-runner exec stack preview --port 9912',
|
||||
url: 'http://localhost:9912/',
|
||||
reuseExistingServer: true,
|
||||
},
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>在线练习 · idealjs stack 教程</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/practice/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>在线练习 · idealjs stack 教程</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/practice/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CSS · 技能熟悉 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<meta name="description" content="技能熟悉 · CSS:用选择器与布局控制页面样式。专项教程逐步补充中。" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/css/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>HTML · 技能熟悉 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<meta name="description" content="技能熟悉 · HTML:用标记描述网页结构。专项教程逐步补充中。" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/html/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>JavaScript · 技能熟悉 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<meta name="description" content="技能熟悉 · JavaScript:让页面响应操作、管理数据。专项教程逐步补充中。" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/javascript/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { MONTHS, monthOf, POSTS } from '../content/blogs'
|
||||
import { BrickDot, Mark, Tri } from '../design-system'
|
||||
import { type PageKey, relHref } from '../lib/pages'
|
||||
import { Page, Section } from '../lib/ui'
|
||||
|
||||
function inline(text: string): ReactNode[] {
|
||||
@@ -135,7 +136,7 @@ function Markdown({ raw }: { raw: string }) {
|
||||
return <div className="space-y-5">{out}</div>
|
||||
}
|
||||
|
||||
export function BlogCard({ post }: { post: (typeof POSTS)[number] }) {
|
||||
export function BlogCard({ post, from }: { post: (typeof POSTS)[number]; from: PageKey }) {
|
||||
const quote =
|
||||
post.raw.split('\n').find((l) => l.startsWith('> ') && l.trim() !== '') ??
|
||||
post.raw
|
||||
@@ -147,7 +148,7 @@ export function BlogCard({ post }: { post: (typeof POSTS)[number] }) {
|
||||
return (
|
||||
<span className="hover-host block w-fit">
|
||||
<a
|
||||
href={`./blog-${post.slug}.html`}
|
||||
href={relHref(from, `blog-${post.slug}`)}
|
||||
className="hoverable-shadow block w-[420px] rounded-2xl border-2 border-ink bg-paper p-5 no-underline shadow-ink transition-[translate,box-shadow] duration-150"
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
@@ -180,7 +181,7 @@ export function BlogDatePage({ dateKey }: { dateKey: string }) {
|
||||
<Section label="本月文章" note="点卡片进入文章">
|
||||
<div className="flex flex-wrap gap-6">
|
||||
{month.posts.map((p) => (
|
||||
<BlogCard key={p.slug} post={p} />
|
||||
<BlogCard key={p.slug} post={p} from={`blog-${dateKey}`} />
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
@@ -192,7 +193,7 @@ export function BlogPostPage({ slug }: { slug: string }) {
|
||||
const post = POSTS.find((p) => p.slug === slug)
|
||||
if (!post) throw new Error(`unknown post: ${slug}`)
|
||||
return (
|
||||
<Page active={`blog-${monthOf(slug)}`}>
|
||||
<Page active={`blog-${monthOf(slug)}`} chain={`blog-${slug}`}>
|
||||
<div className="relative overflow-hidden rounded-2xl border-2 border-ink bg-paper p-5 shadow-ink">
|
||||
<span
|
||||
className="t-display pointer-events-none absolute right-4 top-1/2 -translate-y-1/2 select-none"
|
||||
@@ -214,13 +215,13 @@ export function BlogPostPage({ slug }: { slug: string }) {
|
||||
</article>
|
||||
<div className="mt-10 flex items-center justify-between">
|
||||
<a
|
||||
href={`./blog-${monthOf(slug)}.html`}
|
||||
href={relHref(`blog-${slug}`, `blog-${monthOf(slug)}`)}
|
||||
className="rounded-xl border-2 border-ink bg-paper px-4 py-2 text-small font-bold text-ink no-underline shadow-ink"
|
||||
>
|
||||
← 返回 {monthOf(slug)}
|
||||
</a>
|
||||
<a
|
||||
href="./index.html"
|
||||
href={relHref(`blog-${slug}`, 'index')}
|
||||
className="rounded-xl border-2 border-ink bg-ink px-4 py-2 text-small font-bold text-paper no-underline"
|
||||
>
|
||||
返回首页
|
||||
|
||||
@@ -1,150 +1,107 @@
|
||||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import type { ChapterId } from '../design-system'
|
||||
import { BrickDots, Mark, PageFlipZone, Ring, Tri, Wave } from '../design-system'
|
||||
import { BrickDots, Mark, Ring, Tri, Wave } from '../design-system'
|
||||
import { CHAPTERS, CONTENT } from '../lib/chapters'
|
||||
import { Page, Section } from '../lib/ui'
|
||||
|
||||
const ALL: ChapterId[] = [1, 2, 3, 4, 5, 6, 7]
|
||||
|
||||
export function ChapterPage({ id, children }: { id: ChapterId; children?: ReactNode }) {
|
||||
const ch = CHAPTERS[id]
|
||||
const c = CONTENT[id]
|
||||
const prev = ALL[id - 2]
|
||||
const next = ALL[id]
|
||||
|
||||
return (
|
||||
<Page active={id}>
|
||||
<PageFlipZone
|
||||
prev={prev ? { href: `./ch${prev}.html`, chapter: CHAPTERS[prev] } : undefined}
|
||||
next={next ? { href: `./ch${next}.html`, chapter: CHAPTERS[next] } : undefined}
|
||||
<div
|
||||
className="relative flex items-center gap-4 overflow-hidden rounded-2xl border-2 border-ink p-5 shadow-ink"
|
||||
style={{ background: ch.color } as CSSProperties}
|
||||
>
|
||||
<div
|
||||
className="relative flex items-center gap-4 overflow-hidden rounded-2xl border-2 border-ink p-5 shadow-ink"
|
||||
style={{ background: ch.color } as CSSProperties}
|
||||
<span
|
||||
className="t-display pointer-events-none absolute right-4 top-1/2 -translate-y-1/2 select-none"
|
||||
aria-hidden
|
||||
>
|
||||
<span
|
||||
className="t-display pointer-events-none absolute right-4 top-1/2 -translate-y-1/2 select-none"
|
||||
aria-hidden
|
||||
>
|
||||
0{id}
|
||||
</span>
|
||||
<span className="text-[44px] leading-none">{ch.emoji}</span>
|
||||
<div className="flex-1">
|
||||
<h1 className="m-0 text-t1 font-extrabold text-ink">
|
||||
第 {id} 章 · {ch.title}
|
||||
</h1>
|
||||
<div className="mt-2 flex flex-wrap gap-x-6 gap-y-1 t-small-strong">
|
||||
<span>▲ 目标:{ch.target.goal}</span>
|
||||
<span>○ 预期:{ch.target.expectation}</span>
|
||||
<span className="flex items-center gap-1.5">
|
||||
● 积木 <BrickDots bricks={ch.target.bricks} />
|
||||
{ch.target.bricks.length} 块
|
||||
</span>
|
||||
</div>
|
||||
0{id}
|
||||
</span>
|
||||
<span className="text-[44px] leading-none">{ch.emoji}</span>
|
||||
<div className="flex-1">
|
||||
<h1 className="m-0 text-t1 font-extrabold text-ink">
|
||||
第 {id} 章 · {ch.title}
|
||||
</h1>
|
||||
<div className="mt-2 flex flex-wrap gap-x-6 gap-y-1 t-small-strong">
|
||||
<span>▲ 目标:{ch.target.goal}</span>
|
||||
<span>○ 预期:{ch.target.expectation}</span>
|
||||
<span className="flex items-center gap-1.5">
|
||||
● 积木 <BrickDots bricks={ch.target.bricks} />
|
||||
{ch.target.bricks.length} 块
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-8">
|
||||
<Section label="步骤" note="每步先分类:这一步的过程里有没有学习价值">
|
||||
<ol className="m-0 list-none space-y-3 p-0">
|
||||
{c.steps.map((s, i) => (
|
||||
<li
|
||||
key={s.title}
|
||||
className="rounded-xl border-2 border-ink bg-paper p-4 shadow-ink"
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-2.5">
|
||||
<span className="flex h-6 w-6 items-center justify-center rounded-full border-2 border-ink bg-white text-[12px] font-extrabold">
|
||||
{i + 1}
|
||||
</span>
|
||||
{s.kind === 'value' ? (
|
||||
<Mark className="text-t3">{s.title}</Mark>
|
||||
) : (
|
||||
<span className="flex items-center gap-1.5 text-t3 font-bold text-ink">
|
||||
<Wave size={30} />
|
||||
{s.title}
|
||||
<span className="rounded-full bg-clash3b/15 px-2 py-0.5 text-[10.5px]">
|
||||
代理区 · 交给 agent
|
||||
</span>
|
||||
<div className="mt-8">
|
||||
<Section label="步骤" note="每步先分类:这一步的过程里有没有学习价值">
|
||||
<ol className="m-0 list-none space-y-3 p-0">
|
||||
{c.steps.map((s, i) => (
|
||||
<li key={s.title} className="rounded-xl border-2 border-ink bg-paper p-4 shadow-ink">
|
||||
<div className="flex flex-wrap items-center gap-2.5">
|
||||
<span className="flex h-6 w-6 items-center justify-center rounded-full border-2 border-ink bg-white text-[12px] font-extrabold">
|
||||
{i + 1}
|
||||
</span>
|
||||
{s.kind === 'value' ? (
|
||||
<Mark className="text-t3">{s.title}</Mark>
|
||||
) : (
|
||||
<span className="flex items-center gap-1.5 text-t3 font-bold text-ink">
|
||||
<Wave size={30} />
|
||||
{s.title}
|
||||
<span className="rounded-full bg-clash3b/15 px-2 py-0.5 text-[10.5px]">
|
||||
代理区 · 交给 agent
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="m-0 mt-2.5 text-content text-body">{s.what}</p>
|
||||
<p className="m-0 mt-2 text-content text-body">
|
||||
<b className="t-small-strong">验收</b>
|
||||
<span className="mx-1.5 text-mute">·</span>
|
||||
{s.accept}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</Section>
|
||||
|
||||
<Section label="积木清单" note="从靶子倒推、每块三句话、教一块带一族">
|
||||
<div className="grid grid-cols-1 gap-3 md:grid-cols-3">
|
||||
{c.bricks.map((b) => (
|
||||
<div
|
||||
key={b.name}
|
||||
className="rounded-xl border-2 border-ink bg-paper p-3.5 shadow-ink"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<Tri size={13} />
|
||||
<b className="text-t3">{b.name}</b>
|
||||
</div>
|
||||
<p className="m-0 mt-2 text-small leading-relaxed text-body">
|
||||
<b>是什么</b>:{b.what}
|
||||
<br />
|
||||
<b>为何在这</b>:{b.why}
|
||||
<br />
|
||||
<b>带一族</b>:{b.family}
|
||||
</p>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
<p className="m-0 mt-2.5 text-content text-body">{s.what}</p>
|
||||
<p className="m-0 mt-2 text-content text-body">
|
||||
<b className="t-small-strong">验收</b>
|
||||
<span className="mx-1.5 text-mute">·</span>
|
||||
{s.accept}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</Section>
|
||||
|
||||
<Section label="积木清单" note="从靶子倒推、每块三句话、教一块带一族">
|
||||
<div className="grid grid-cols-1 gap-3 md:grid-cols-3">
|
||||
{c.bricks.map((b) => (
|
||||
<div
|
||||
key={b.name}
|
||||
className="rounded-xl border-2 border-ink bg-paper p-3.5 shadow-ink"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<Tri size={13} />
|
||||
<b className="text-t3">{b.name}</b>
|
||||
</div>
|
||||
<p className="m-0 mt-2 text-small leading-relaxed text-body">
|
||||
<b>是什么</b>:{b.what}
|
||||
<br />
|
||||
<b>为何在这</b>:{b.why}
|
||||
<br />
|
||||
<b>带一族</b>:{b.family}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{c.base && (
|
||||
<Section label="认知基础" note="脚下的地(env/库/运行环境)——第一次用到就地露出">
|
||||
<div className="flex items-start gap-3 rounded-xl border-2 border-dashed border-ink/40 bg-clash3b/15 p-4">
|
||||
<Ring size={18} className="mt-0.5 shrink-0" />
|
||||
<p className="m-0 text-content text-body">{c.base}</p>
|
||||
</div>
|
||||
</Section>
|
||||
)}
|
||||
|
||||
{c.base && (
|
||||
<Section label="认知基础" note="脚下的地(env/库/运行环境)——第一次用到就地露出">
|
||||
<div className="flex items-start gap-3 rounded-xl border-2 border-dashed border-ink/40 bg-clash3b/15 p-4">
|
||||
<Ring size={18} className="mt-0.5 shrink-0" />
|
||||
<p className="m-0 text-content text-body">{c.base}</p>
|
||||
</div>
|
||||
</Section>
|
||||
)}
|
||||
|
||||
{children}
|
||||
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
{prev ? (
|
||||
<a
|
||||
href={`./ch${prev}.html`}
|
||||
data-dir="prev"
|
||||
className="rounded-xl border-2 border-ink bg-paper px-4 py-2 text-[12.5px] font-bold text-ink no-underline shadow-ink"
|
||||
>
|
||||
← 第 {prev} 章 · {CHAPTERS[prev].title}
|
||||
</a>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
<a
|
||||
href="./index.html"
|
||||
className="rounded-xl border-2 border-ink bg-ink px-4 py-2 text-[12.5px] font-bold text-paper no-underline"
|
||||
>
|
||||
返回首页
|
||||
</a>
|
||||
{next ? (
|
||||
<a
|
||||
href={`./ch${next}.html`}
|
||||
data-dir="next"
|
||||
className="rounded-xl border-2 border-ink bg-paper px-4 py-2 text-[12.5px] font-bold text-ink no-underline shadow-ink"
|
||||
>
|
||||
第 {next} 章 · {CHAPTERS[next].title} →
|
||||
</a>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</PageFlipZone>
|
||||
{children}
|
||||
</div>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { neighborsOf, type PageKey, relHref } from '../lib/pages'
|
||||
|
||||
export function PageTurnBar({ from }: { from: PageKey }) {
|
||||
const neighbors = neighborsOf(from)
|
||||
if (neighbors === undefined) return null
|
||||
const { prev, next } = neighbors
|
||||
return (
|
||||
<div className="mt-10 flex items-center justify-between gap-4">
|
||||
<a
|
||||
href={relHref(from, prev.key)}
|
||||
data-dir="prev"
|
||||
className="max-w-[36ch] truncate rounded-xl border-2 border-ink bg-paper px-4 py-2 text-[12.5px] font-bold text-ink no-underline shadow-ink"
|
||||
>
|
||||
← {prev.title}
|
||||
</a>
|
||||
{from === 'index' ? (
|
||||
<span />
|
||||
) : (
|
||||
<a
|
||||
href={relHref(from, 'index')}
|
||||
className="flex-none rounded-xl border-2 border-ink bg-ink px-4 py-2 text-[12.5px] font-bold text-paper no-underline"
|
||||
>
|
||||
返回首页
|
||||
</a>
|
||||
)}
|
||||
<a
|
||||
href={relHref(from, next.key)}
|
||||
data-dir="next"
|
||||
className="max-w-[36ch] truncate rounded-xl border-2 border-ink bg-paper px-4 py-2 text-[12.5px] font-bold text-ink no-underline shadow-ink"
|
||||
>
|
||||
{next.title} →
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -4,11 +4,13 @@ export function EntryGuide({
|
||||
chapters,
|
||||
profiles,
|
||||
linkChapter = false,
|
||||
chapterHref,
|
||||
}: {
|
||||
chapters: Record<ChapterId, Chapter>
|
||||
profiles: Profile[]
|
||||
|
||||
linkChapter?: boolean
|
||||
chapterHref?: (id: ChapterId) => string
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-wrap gap-5">
|
||||
@@ -33,7 +35,7 @@ export function EntryGuide({
|
||||
{i > 0 && <span className="text-small text-mute">→</span>}
|
||||
{linkChapter ? (
|
||||
<a
|
||||
href={`./ch${id}.html`}
|
||||
href={(chapterHref ?? ((chapterId: ChapterId) => `./ch${chapterId}.html`))(id)}
|
||||
className={`rounded-full border-[1.5px] border-ink px-2.5 py-0.5 text-small no-underline ${id === p.entry ? 'bg-clash2a font-extrabold' : 'bg-white'}`}
|
||||
>
|
||||
{id === p.entry && ['①', '②', '③'][profiles.indexOf(p)]} {chapters[id].title}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { CSSProperties, ReactNode, RefObject } from 'react'
|
||||
import { useEffect, useRef } from 'react'
|
||||
import type { Chapter } from '../lib/types'
|
||||
|
||||
const CHARGE_DAMPING = 0.12
|
||||
const CHARGE_RATE_CAP = 220
|
||||
@@ -10,9 +9,14 @@ const GESTURE_GAP_MS = 100
|
||||
const SPRING_STIFFNESS = 170
|
||||
const SPRING_DAMPING = 18
|
||||
|
||||
export interface FlipMeta {
|
||||
title: string
|
||||
color: string
|
||||
}
|
||||
|
||||
export interface FlipTarget {
|
||||
href: string
|
||||
chapter: Chapter
|
||||
meta: FlipMeta
|
||||
}
|
||||
|
||||
export interface PageFlipZoneProps {
|
||||
@@ -32,13 +36,13 @@ const EDGE_ANCHOR = {
|
||||
container: 'bottom-0',
|
||||
badge: 'bottom-4',
|
||||
bar: 'bottom-0',
|
||||
label: '▼ 继续滚动 · 翻到下一章',
|
||||
label: (title: string) => `▼ 继续滚动 · 下一页:${title}`,
|
||||
},
|
||||
prev: {
|
||||
container: 'top-0',
|
||||
badge: 'top-4',
|
||||
bar: 'top-0',
|
||||
label: '▲ 继续滚动 · 翻到上一章',
|
||||
label: (title: string) => `▲ 继续滚动 · 上一页:${title}`,
|
||||
},
|
||||
} as const
|
||||
|
||||
@@ -63,9 +67,9 @@ function FlipEdge({ side, target, edgeRef, onFlip }: FlipEdgeProps) {
|
||||
type="button"
|
||||
onClick={onFlip}
|
||||
className="cursor-pointer rounded-full border-2 border-ink px-3 py-1 text-[12px] font-bold text-ink shadow-ink transition-[translate,box-shadow] duration-150 [pointer-events:var(--flip-pointer)] hover:-translate-y-0.5 hover:shadow-ink-lift active:translate-x-[2px] active:translate-y-[2px] active:shadow-[1px_1px_0_var(--color-ink)]"
|
||||
style={{ background: target.chapter.color }}
|
||||
style={{ background: target.meta.color }}
|
||||
>
|
||||
{anchor.label}
|
||||
{anchor.label(target.meta.title)}
|
||||
</button>
|
||||
</div>
|
||||
<div aria-hidden className={`absolute inset-x-0 ${anchor.bar} h-1 bg-ink/15`}>
|
||||
|
||||
@@ -41,7 +41,7 @@ export type { LearningTone } from './components/learning/shared'
|
||||
export type { TaskEnvelopeProps } from './components/learning/TaskEnvelope'
|
||||
export { TaskEnvelope } from './components/learning/TaskEnvelope'
|
||||
export { BrickDots, EntryBadge, MemphisCard } from './components/MemphisCard'
|
||||
export type { FlipTarget, PageFlipZoneProps } from './components/PageFlipZone'
|
||||
export type { FlipMeta, FlipTarget, PageFlipZoneProps } from './components/PageFlipZone'
|
||||
export { PageFlipZone } from './components/PageFlipZone'
|
||||
export type { PinActions } from './components/RoutableCard'
|
||||
export { RoutableCard, RoutableScene } from './components/RoutableCard'
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
import { MONTHS } from '../content/blogs'
|
||||
import type { ChapterId, FlipTarget } from '../design-system'
|
||||
import { CHAPTERS } from './chapters'
|
||||
|
||||
export type PageKey =
|
||||
| 'index'
|
||||
| 'learn'
|
||||
| `ch${ChapterId}`
|
||||
| 'html'
|
||||
| 'css'
|
||||
| 'javascript'
|
||||
| 'blog'
|
||||
| `blog-${string}`
|
||||
| 'design'
|
||||
| 'design-colors'
|
||||
| 'design-typography'
|
||||
| 'design-symbols'
|
||||
| 'design-components'
|
||||
| 'design-shadow'
|
||||
| 'practice'
|
||||
|
||||
export interface PageMeta {
|
||||
key: PageKey
|
||||
path: string
|
||||
title: string
|
||||
color: string
|
||||
mono?: boolean
|
||||
}
|
||||
|
||||
const CHAPTER_IDS = [1, 2, 3, 4, 5, 6, 7] as ChapterId[]
|
||||
|
||||
const chapterPages: PageMeta[] = CHAPTER_IDS.map((id) => ({
|
||||
key: `ch${id}`,
|
||||
path: `tutorial/ch${id}.html`,
|
||||
title: `第 ${id} 章 · ${CHAPTERS[id].title}`,
|
||||
color: CHAPTERS[id].color,
|
||||
}))
|
||||
|
||||
const skillPages: PageMeta[] = [
|
||||
{ key: 'html', path: 'skills/html.html', title: 'HTML', color: 'var(--color-clash2a)' },
|
||||
{ key: 'css', path: 'skills/css.html', title: 'CSS', color: 'var(--color-clash2b)' },
|
||||
{
|
||||
key: 'javascript',
|
||||
path: 'skills/javascript.html',
|
||||
title: 'JavaScript',
|
||||
color: 'var(--color-clash3a)',
|
||||
},
|
||||
]
|
||||
|
||||
const blogPages: PageMeta[] = [...MONTHS]
|
||||
.sort((a, b) => (a.key < b.key ? -1 : 1))
|
||||
.flatMap((month) => [
|
||||
{
|
||||
key: `blog-${month.key}`,
|
||||
path: `blog/${month.key}.html`,
|
||||
title: month.key,
|
||||
color: 'var(--color-paper-deep)',
|
||||
mono: true,
|
||||
},
|
||||
...[...month.posts]
|
||||
.sort((a, b) => (a.date < b.date ? -1 : 1))
|
||||
.map(
|
||||
(post): PageMeta => ({
|
||||
key: `blog-${post.slug}`,
|
||||
path: `blog/${post.slug}.html`,
|
||||
title: post.title,
|
||||
color: 'var(--color-clash3b)',
|
||||
}),
|
||||
),
|
||||
])
|
||||
|
||||
const DESIGN_PAGES: { key: PageKey; leaf: string; title: string; color: string }[] = [
|
||||
{ key: 'design-colors', leaf: 'colors', title: '颜色', color: 'var(--color-clash1a)' },
|
||||
{ key: 'design-typography', leaf: 'typography', title: '字体', color: 'var(--color-clash1b)' },
|
||||
{ key: 'design-symbols', leaf: 'symbols', title: '符号形状', color: 'var(--color-clash2a)' },
|
||||
{ key: 'design-components', leaf: 'components', title: '组件', color: 'var(--color-clash2b)' },
|
||||
{ key: 'design-shadow', leaf: 'shadow', title: '阴影', color: 'var(--color-clash3a)' },
|
||||
]
|
||||
|
||||
export const PAGES: PageMeta[] = [
|
||||
{ key: 'index', path: 'index.html', title: '首页', color: 'var(--color-clash1a)' },
|
||||
{ key: 'learn', path: 'tutorial/index.html', title: '全栈教程', color: 'var(--color-clash1b)' },
|
||||
...chapterPages,
|
||||
...skillPages,
|
||||
{ key: 'blog', path: 'blog/index.html', title: '博客', color: 'var(--color-clash3b)' },
|
||||
...blogPages,
|
||||
{ key: 'design', path: 'design/index.html', title: '设计系统', color: 'var(--color-clash2b)' },
|
||||
...DESIGN_PAGES.map((p) => ({ ...p, path: `design/${p.leaf}.html` })),
|
||||
{
|
||||
key: 'practice',
|
||||
path: 'practice/index.html',
|
||||
title: '在线练习',
|
||||
color: 'var(--color-clash3b)',
|
||||
},
|
||||
]
|
||||
|
||||
const BY_KEY = new Map(PAGES.map((page) => [page.key as string, page]))
|
||||
|
||||
export const pageOf = (key: PageKey): PageMeta | undefined => BY_KEY.get(key)
|
||||
|
||||
export const relHref = (from: PageKey, to: PageKey): string => {
|
||||
const source = BY_KEY.get(from)
|
||||
const target = BY_KEY.get(to)
|
||||
if (source === undefined || target === undefined) return '#'
|
||||
const prefix = source.path.includes('/') ? '../' : './'
|
||||
return `${prefix}${target.path}`
|
||||
}
|
||||
|
||||
export const neighborsOf = (key: PageKey): { prev: PageMeta; next: PageMeta } | undefined => {
|
||||
const index = PAGES.findIndex((page) => page.key === key)
|
||||
if (index === -1) return undefined
|
||||
return {
|
||||
prev: PAGES[(index - 1 + PAGES.length) % PAGES.length],
|
||||
next: PAGES[(index + 1) % PAGES.length],
|
||||
}
|
||||
}
|
||||
|
||||
export const DESIGN_KEYS = DESIGN_PAGES.map((p) => p.key)
|
||||
|
||||
export const flipTargetsOf = (from: PageKey): { prev?: FlipTarget; next?: FlipTarget } => {
|
||||
const neighbors = neighborsOf(from)
|
||||
if (neighbors === undefined) return {}
|
||||
const to = (meta: PageMeta): FlipTarget => ({
|
||||
href: relHref(from, meta.key),
|
||||
meta: { title: meta.title, color: meta.color },
|
||||
})
|
||||
return { prev: to(neighbors.prev), next: to(neighbors.next) }
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
import '../design-system'
|
||||
import type { ReactNode } from 'react'
|
||||
import { PageTurnBar } from '../components/PageTurnBar'
|
||||
import { MONTHS } from '../content/blogs'
|
||||
import type { ChapterId, NavItemLink, NavRowGroup } from '../design-system'
|
||||
import { PageFlipZone } from '../design-system'
|
||||
import { CHAPTERS } from './chapters'
|
||||
import { flipTargetsOf, type PageKey, relHref } from './pages'
|
||||
import type { SiteNav } from './site'
|
||||
import { SitePage } from './site'
|
||||
|
||||
@@ -15,69 +18,76 @@ export type DesignKey =
|
||||
|
||||
export type SkillKey = 'html' | 'css' | 'javascript'
|
||||
|
||||
const DESIGN: { href: string; label: string; key: DesignKey }[] = [
|
||||
{ href: './design-colors.html', label: '颜色', key: 'design-colors' },
|
||||
{ href: './design-typography.html', label: '字体', key: 'design-typography' },
|
||||
{ href: './design-symbols.html', label: '符号形状', key: 'design-symbols' },
|
||||
{ href: './design-components.html', label: '组件', key: 'design-components' },
|
||||
{ href: './design-shadow.html', label: '阴影', key: 'design-shadow' },
|
||||
const DESIGN: { label: string; key: DesignKey }[] = [
|
||||
{ label: '颜色', key: 'design-colors' },
|
||||
{ label: '字体', key: 'design-typography' },
|
||||
{ label: '符号形状', key: 'design-symbols' },
|
||||
{ label: '组件', key: 'design-components' },
|
||||
{ label: '阴影', key: 'design-shadow' },
|
||||
]
|
||||
|
||||
const SKILLS: { href: string; label: string; key: SkillKey }[] = [
|
||||
{ href: './html.html', label: 'HTML', key: 'html' },
|
||||
{ href: './css.html', label: 'CSS', key: 'css' },
|
||||
{ href: './javascript.html', label: 'JavaScript', key: 'javascript' },
|
||||
const SKILLS: { label: string; key: SkillKey }[] = [
|
||||
{ label: 'HTML', key: 'html' },
|
||||
{ label: 'CSS', key: 'css' },
|
||||
{ label: 'JavaScript', key: 'javascript' },
|
||||
]
|
||||
|
||||
const CHAPTER_ITEMS: NavItemLink[] = ([1, 2, 3, 4, 5, 6, 7] as ChapterId[]).map((id) => ({
|
||||
key: `ch${id}`,
|
||||
label: CHAPTERS[id].title,
|
||||
href: `./ch${id}.html`,
|
||||
color: CHAPTERS[id].color,
|
||||
}))
|
||||
const chapterItems = (from: PageKey): NavItemLink[] =>
|
||||
([1, 2, 3, 4, 5, 6, 7] as ChapterId[]).map((id) => ({
|
||||
key: `ch${id}`,
|
||||
label: CHAPTERS[id].title,
|
||||
href: relHref(from, `ch${id}`),
|
||||
color: CHAPTERS[id].color,
|
||||
}))
|
||||
|
||||
const NAV_ROWS: NavRowGroup[] = [
|
||||
{ sectionKey: 'tutorial', label: '全栈教程', href: './learn.html', items: CHAPTER_ITEMS },
|
||||
{
|
||||
sectionKey: 'skills',
|
||||
label: '技能熟悉',
|
||||
items: SKILLS.map((n) => ({ key: n.key, label: n.label, href: n.href })),
|
||||
},
|
||||
{
|
||||
sectionKey: 'blog',
|
||||
label: '博客',
|
||||
href: './blog.html',
|
||||
items: MONTHS.map((m) => ({
|
||||
key: `blog-${m.key}`,
|
||||
label: m.key,
|
||||
href: `./blog-${m.key}.html`,
|
||||
mono: true,
|
||||
})),
|
||||
},
|
||||
{
|
||||
sectionKey: 'design',
|
||||
label: '设计系统',
|
||||
href: './design.html',
|
||||
items: DESIGN.map((n) => ({ key: n.key, label: n.label, href: n.href })),
|
||||
},
|
||||
{
|
||||
sectionKey: 'practice',
|
||||
label: '在线练习',
|
||||
href: './practice.html',
|
||||
items: [{ key: 'practice-starter', label: '重建中', href: './practice.html', mono: true }],
|
||||
},
|
||||
]
|
||||
|
||||
export const SITE_NAV: SiteNav = {
|
||||
brand: { key: 'index', label: 'idealjs stack', href: './index.html' },
|
||||
rows: NAV_ROWS,
|
||||
}
|
||||
export const siteNavFor = (from: PageKey): SiteNav => ({
|
||||
brand: { key: 'index', label: 'idealjs stack', href: relHref(from, 'index') },
|
||||
rows: [
|
||||
{
|
||||
sectionKey: 'tutorial',
|
||||
label: '全栈教程',
|
||||
href: relHref(from, 'learn'),
|
||||
items: chapterItems(from),
|
||||
},
|
||||
{
|
||||
sectionKey: 'skills',
|
||||
label: '技能熟悉',
|
||||
items: SKILLS.map((n) => ({ key: n.key, label: n.label, href: relHref(from, n.key) })),
|
||||
},
|
||||
{
|
||||
sectionKey: 'blog',
|
||||
label: '博客',
|
||||
href: relHref(from, 'blog'),
|
||||
items: MONTHS.map((m) => ({
|
||||
key: `blog-${m.key}`,
|
||||
label: m.key,
|
||||
href: relHref(from, `blog-${m.key}`),
|
||||
mono: true,
|
||||
})),
|
||||
},
|
||||
{
|
||||
sectionKey: 'design',
|
||||
label: '设计系统',
|
||||
href: relHref(from, 'design'),
|
||||
items: DESIGN.map((n) => ({ key: n.key, label: n.label, href: relHref(from, n.key) })),
|
||||
},
|
||||
{
|
||||
sectionKey: 'practice',
|
||||
label: '在线练习',
|
||||
href: relHref(from, 'practice'),
|
||||
items: [
|
||||
{ key: 'practice-starter', label: '重建中', href: relHref(from, 'practice'), mono: true },
|
||||
],
|
||||
},
|
||||
] satisfies NavRowGroup[],
|
||||
})
|
||||
|
||||
export function Page({
|
||||
title,
|
||||
subtitle,
|
||||
desc,
|
||||
active,
|
||||
chain,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
@@ -93,8 +103,10 @@ export function Page({
|
||||
| DesignKey
|
||||
| SkillKey
|
||||
| `blog-${string}`
|
||||
chain?: PageKey
|
||||
children: ReactNode
|
||||
}) {
|
||||
const pageKey = (chain ?? (typeof active === 'number' ? `ch${active}` : active)) as PageKey
|
||||
const activeKey =
|
||||
active === 'index'
|
||||
? 'index'
|
||||
@@ -104,16 +116,21 @@ export function Page({
|
||||
? `ch${active}`
|
||||
: active
|
||||
|
||||
const flips = flipTargetsOf(pageKey)
|
||||
|
||||
return (
|
||||
<SitePage
|
||||
nav={SITE_NAV}
|
||||
nav={siteNavFor(pageKey)}
|
||||
active={activeKey}
|
||||
viewTransitionName="site-header"
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
desc={desc}
|
||||
>
|
||||
{children}
|
||||
<PageFlipZone prev={flips.prev} next={flips.next}>
|
||||
{children}
|
||||
<PageTurnBar from={pageKey} />
|
||||
</PageFlipZone>
|
||||
</SitePage>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export function App() {
|
||||
<Section key={m.key} label={m.key} note={`${m.posts.length} 篇`}>
|
||||
<div className="flex flex-wrap gap-6">
|
||||
{m.posts.map((p) => (
|
||||
<BlogCard key={p.slug} post={p} />
|
||||
<BlogCard key={p.slug} post={p} from="blog" />
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Button } from '../../design-system'
|
||||
import { relHref } from '../../lib/pages'
|
||||
import { Page, Section } from '../../lib/ui'
|
||||
|
||||
export function App() {
|
||||
@@ -15,7 +16,7 @@ export function App() {
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Button href="./learn.html">
|
||||
<Button href={relHref('css', 'learn')}>
|
||||
打开全栈教程 <span aria-hidden="true">→</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from '../../design-system'
|
||||
import { LearningKitGallery } from '../../design-system/examples/LearningKitGallery'
|
||||
import { CHAPTERS, PROFILES } from '../../lib/chapters'
|
||||
import { relHref } from '../../lib/pages'
|
||||
import { Page, Section } from '../../lib/ui'
|
||||
import { TicketPreview } from './TicketPreview'
|
||||
|
||||
@@ -163,19 +164,19 @@ export function App() {
|
||||
<RoutableCard
|
||||
no={1}
|
||||
title="快速开始"
|
||||
href="./ch1.html"
|
||||
href={relHref('design-components', 'ch1')}
|
||||
className="absolute left-[60px] top-[110px] w-[180px]"
|
||||
/>
|
||||
<RoutableCard
|
||||
no={2}
|
||||
title="React"
|
||||
href="./ch2.html"
|
||||
href={relHref('design-components', 'ch2')}
|
||||
className="absolute left-[420px] top-[70px] w-[180px] -rotate-1"
|
||||
/>
|
||||
<RoutableCard
|
||||
no={5}
|
||||
title="全栈基础"
|
||||
href="./ch5.html"
|
||||
href={relHref('design-components', 'ch5')}
|
||||
className="absolute left-[780px] top-[70px] w-[180px]"
|
||||
/>
|
||||
</RoutableScene>
|
||||
@@ -248,7 +249,9 @@ export function App() {
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<ShadowButton>默认 · paper</ShadowButton>
|
||||
<ShadowButton href="./learn.html">链接 · href 渲染 a</ShadowButton>
|
||||
<ShadowButton href={relHref('design-components', 'learn')}>
|
||||
链接 · href 渲染 a
|
||||
</ShadowButton>
|
||||
<ShadowButton tone="clash1b">tone · clash1b</ShadowButton>
|
||||
<ShadowButton size="sm">紧凑 · sm</ShadowButton>
|
||||
<ShadowButton disabled>占位 · 虚线</ShadowButton>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { type PageKey, relHref } from '../../lib/pages'
|
||||
import { Page, Section } from '../../lib/ui'
|
||||
|
||||
const BOOKS = [
|
||||
const BOOKS: { key: PageKey; label: string; desc: string }[] = [
|
||||
{ key: 'design-colors', label: '颜色', desc: '高饱和 clash 色板与纸色系统——把鲜艳关进形状里。' },
|
||||
{ key: 'design-typography', label: '字体', desc: '展示、正文、等宽的字阶与排版层级。' },
|
||||
{
|
||||
@@ -32,7 +33,7 @@ export function App() {
|
||||
{BOOKS.map((b) => (
|
||||
<span key={b.key} className="hover-host block w-fit">
|
||||
<a
|
||||
href={`./${b.key}.html`}
|
||||
href={relHref('design', b.key)}
|
||||
className="hoverable-shadow block w-[280px] rounded-2xl border-2 border-ink bg-paper p-5 no-underline shadow-ink transition-[translate,box-shadow] duration-150"
|
||||
>
|
||||
<span className="text-t3 font-extrabold text-ink">{b.label}</span>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Button } from '../../design-system'
|
||||
import { relHref } from '../../lib/pages'
|
||||
import { Page, Section } from '../../lib/ui'
|
||||
|
||||
export function App() {
|
||||
@@ -15,7 +16,7 @@ export function App() {
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Button href="./learn.html">
|
||||
<Button href={relHref('html', 'learn')}>
|
||||
打开全栈教程 <span aria-hidden="true">→</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MONTHS } from '../../content/blogs'
|
||||
import { Button } from '../../design-system'
|
||||
import { relHref } from '../../lib/pages'
|
||||
import { Page } from '../../lib/ui'
|
||||
|
||||
export function App() {
|
||||
@@ -8,14 +9,14 @@ export function App() {
|
||||
<div className="max-w-[72ch]">
|
||||
<p className="m-0 text-content">通过全栈工程师教程,逐步学习前端、后端与工程实践;</p>
|
||||
<div className="mt-2.5">
|
||||
<Button tone="clash1a" href="./learn.html">
|
||||
<Button tone="clash1a" href={relHref('index', 'learn')}>
|
||||
开始学习 <span aria-hidden="true">→</span>
|
||||
</Button>
|
||||
</div>
|
||||
<p className="mb-0 mt-7 text-content">在博客中,分享开发过程中的经验与思考。</p>
|
||||
<div className="mt-2.5">
|
||||
{MONTHS[0] && (
|
||||
<Button tone="clash2a" href={`./blog-${MONTHS[0].key}.html`}>
|
||||
<Button tone="clash2a" href={relHref('index', `blog-${MONTHS[0].key}`)}>
|
||||
阅读博客 <span aria-hidden="true">→</span>
|
||||
</Button>
|
||||
)}
|
||||
@@ -24,7 +25,7 @@ export function App() {
|
||||
在线练习场正在以 ESM + MCP 的形式重建;在那之前,从教程开始、在本地环境跟练。
|
||||
</p>
|
||||
<div className="mt-2.5">
|
||||
<Button tone="clash2b" href="./practice.html">
|
||||
<Button tone="clash2b" href={relHref('index', 'practice')}>
|
||||
打开在线练习场
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Button } from '../../design-system'
|
||||
import { relHref } from '../../lib/pages'
|
||||
import { Page, Section } from '../../lib/ui'
|
||||
|
||||
export function App() {
|
||||
@@ -15,7 +16,7 @@ export function App() {
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Button href="./learn.html">
|
||||
<Button href={relHref('javascript', 'learn')}>
|
||||
打开全栈教程 <span aria-hidden="true">→</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Mark,
|
||||
StickyNote,
|
||||
} from '../../design-system'
|
||||
import { relHref } from '../../lib/pages'
|
||||
import { Page, Section } from '../../lib/ui'
|
||||
import { TodoPreview } from './components/TodoPreview'
|
||||
import { TodoTour } from './components/TodoTour'
|
||||
@@ -187,10 +188,10 @@ export function App() {
|
||||
</section>
|
||||
|
||||
<div className="learn-actions">
|
||||
<Button tone="clash1b" href="./ch1.html">
|
||||
<Button tone="clash1b" href={relHref('learn', 'ch1')}>
|
||||
从第一个网页开始 <span aria-hidden="true">→</span>
|
||||
</Button>
|
||||
<Button href="./practice.html">打开练习场</Button>
|
||||
<Button href={relHref('learn', 'practice')}>打开练习场</Button>
|
||||
<p>你提出需求,Agent 协助实现;再对照结果,理解代码为什么这样工作。</p>
|
||||
</div>
|
||||
|
||||
@@ -274,7 +275,7 @@ export function App() {
|
||||
<p className="learn-environment-note">
|
||||
首次搭建预留 30–60 分钟,从「快速开始」查看环境准备。
|
||||
</p>
|
||||
<Button href="./ch1.html">查看本地环境准备</Button>
|
||||
<Button href={relHref('learn', 'ch1')}>查看本地环境准备</Button>
|
||||
</>
|
||||
),
|
||||
}}
|
||||
|
||||
@@ -1,27 +1,34 @@
|
||||
import { SiteSidebar } from '../../design-system'
|
||||
import { PageTurnBar } from '../../components/PageTurnBar'
|
||||
import { PageFlipZone, SiteSidebar } from '../../design-system'
|
||||
import { flipTargetsOf } from '../../lib/pages'
|
||||
import { SiteFooter } from '../../lib/site'
|
||||
import { SITE_NAV } from '../../lib/ui'
|
||||
import { siteNavFor } from '../../lib/ui'
|
||||
import { PracticeWorkspace } from './components/PracticeWorkspace'
|
||||
|
||||
export function App() {
|
||||
const nav = siteNavFor('practice')
|
||||
const flips = flipTargetsOf('practice')
|
||||
return (
|
||||
<div className="flex min-h-dvh text-content text-body">
|
||||
<SiteSidebar brand={SITE_NAV.brand} rows={SITE_NAV.rows} active="practice" />
|
||||
<main className="mx-auto w-full max-w-[1200px] min-w-0 flex-1 px-3 py-4 max-lg:pr-12 max-lg:pt-16">
|
||||
<div className="mb-4">
|
||||
<h1 className="m-0 text-t1 font-extrabold text-ink">在线练习</h1>
|
||||
<p className="m-0 mt-1.5 text-content text-mute">
|
||||
沙箱写真跑:web runner 沙箱预览与 playground
|
||||
编辑器同住右缘侧栏——点紫色的「沙箱预览」签直接看沙箱,点「编辑器」签写码;点「运行
|
||||
▶」构建产物送进隔离 iframe
|
||||
执行,并自动切到沙箱页签;侧栏展开时页面罩上灰色蒙版,点蒙版或按 Esc
|
||||
收回。标题栏右上角「💡 tips」拉出操作流水线,点任意一步,提示词自动填进陪练 agent
|
||||
输入框,回车即发;验收夹具和 tips 并排在标题栏,点夹具拉出来逐条打勾。
|
||||
</p>
|
||||
</div>
|
||||
<PracticeWorkspace />
|
||||
<SiteFooter />
|
||||
</main>
|
||||
</div>
|
||||
<PageFlipZone prev={flips.prev} next={flips.next}>
|
||||
<div className="flex min-h-dvh text-content text-body">
|
||||
<SiteSidebar brand={nav.brand} rows={nav.rows} active="practice" />
|
||||
<main className="mx-auto w-full max-w-[1200px] min-w-0 flex-1 px-3 py-4 max-lg:pr-12 max-lg:pt-16">
|
||||
<div className="mb-4">
|
||||
<h1 className="m-0 text-t1 font-extrabold text-ink">在线练习</h1>
|
||||
<p className="m-0 mt-1.5 text-content text-mute">
|
||||
沙箱写真跑:web runner 沙箱预览与 playground
|
||||
编辑器同住右缘侧栏——点紫色的「沙箱预览」签直接看沙箱,点「编辑器」签写码;点「运行
|
||||
▶」构建产物送进隔离 iframe
|
||||
执行,并自动切到沙箱页签;侧栏展开时页面罩上灰色蒙版,点蒙版或按 Esc
|
||||
收回。标题栏右上角「💡 tips」拉出操作流水线,点任意一步,提示词自动填进陪练 agent
|
||||
输入框,回车即发;验收夹具和 tips 并排在标题栏,点夹具拉出来逐条打勾。
|
||||
</p>
|
||||
</div>
|
||||
<PracticeWorkspace />
|
||||
<PageTurnBar from="practice" />
|
||||
<SiteFooter />
|
||||
</main>
|
||||
</div>
|
||||
</PageFlipZone>
|
||||
)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { extractHtmlDocument } from './htmlBody'
|
||||
import type { OutputLine } from './OutputPanel'
|
||||
import { isRuntimeMessage, PROTOCOL_VERSION } from './protocol'
|
||||
|
||||
const WASM_URL = 'esbuild.wasm'
|
||||
const WASM_URL = '/esbuild.wasm'
|
||||
|
||||
export const RUNTIME_ORIGIN: string = runtimeOrigin
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from '@idealjs/stack'
|
||||
import { bundle, imports } from '@idealjs/stack/builtins'
|
||||
|
||||
const WASM_URL = 'esbuild.wasm'
|
||||
const WASM_URL = '/esbuild.wasm'
|
||||
const CONFIG_NAME = 'stack.config.ts'
|
||||
const DOC_NAME = 'index.html'
|
||||
|
||||
|
||||
@@ -93,12 +93,13 @@ const renderPage = async (
|
||||
workspace: string,
|
||||
root: string,
|
||||
): Promise<string> => {
|
||||
const flat = name.replaceAll('/', '__')
|
||||
for (const stale of readdirSync(workspace)) {
|
||||
if (stale.startsWith(`${name}-`) && stale.endsWith('.mjs')) {
|
||||
if (stale.startsWith(`${flat}-`) && stale.endsWith('.mjs')) {
|
||||
rmSync(join(workspace, stale))
|
||||
}
|
||||
}
|
||||
const outfile = join(workspace, `${name}-${fingerprint}.mjs`)
|
||||
const outfile = join(workspace, `${flat}-${fingerprint}.mjs`)
|
||||
await esbuild({
|
||||
entryPoints: [entryId],
|
||||
bundle: true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { readdirSync } from 'node:fs'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { defineConfig } from '@idealjs/stack'
|
||||
import { imports, vendor } from '@idealjs/stack/builtins'
|
||||
@@ -16,9 +16,19 @@ try {
|
||||
|
||||
const runtimeDocPath = resolve(appDir, '../web-runner/dist-runtime/index.html')
|
||||
|
||||
const pages = readdirSync(appDir)
|
||||
.filter((file) => file.endsWith('.html'))
|
||||
.map((file) => file.replace(/\.html$/, ''))
|
||||
const IGNORED_DIRS = new Set(['node_modules', 'dist', '.git'])
|
||||
|
||||
const collectPages = (dir: string, prefix: string): string[] =>
|
||||
readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
if (entry.isDirectory()) {
|
||||
return IGNORED_DIRS.has(entry.name)
|
||||
? []
|
||||
: collectPages(join(dir, entry.name), `${prefix}${entry.name}/`)
|
||||
}
|
||||
return entry.name.endsWith('.html') ? [`${prefix}${entry.name.replace(/\.html$/, '')}`] : []
|
||||
})
|
||||
|
||||
const pages = collectPages(appDir, '')
|
||||
|
||||
const readRuntimeDoc = async (): Promise<string> => {
|
||||
try {
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch1/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch1/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch2/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch2/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch3/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch3/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch4/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch4/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch5/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch5/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch6/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch6/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,11 @@
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<link rel="stylesheet" href="./src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="./src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/pages/ch7/main.tsx"></script>
|
||||
<script type="module" src="../src/pages/ch7/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>全栈教程 · 做一个自己的待办清单 · idealjs stack</title>
|
||||
<style>@view-transition { navigation: auto; }</style>
|
||||
<script>
|
||||
var vt = sessionStorage.getItem("vt")
|
||||
if (vt) document.documentElement.dataset.vt = vt
|
||||
sessionStorage.removeItem("vt")
|
||||
document.addEventListener("click", function (e) {
|
||||
var a = e.target.closest("a[data-dir]")
|
||||
if (a) sessionStorage.setItem("vt", a.dataset.dir)
|
||||
})
|
||||
</script>
|
||||
<meta name="description" content="从页面、交互到 API 和数据库,逐步完成一个单人版 TodoList。了解技术积木、浏览器内运行时与 Agent 练习环境、预计学习时间,以及贯穿全栈的数据控制。" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/tokens.css" />
|
||||
<link rel="stylesheet" href="../src/design-system/styles/learning.css" />
|
||||
<link rel="stylesheet" href="../src/pages/learn/learn.css" />
|
||||
<link rel="stylesheet" href="../src/pages/learn/learn-todo.css" />
|
||||
<link rel="stylesheet" href="../src/pages/learn/learn-tour.css" />
|
||||
</head>
|
||||
<body class="bg-paper text-ink">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="../src/pages/learn/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -125,6 +125,16 @@ apps/tutorial/src/
|
||||
- `scrollRestoration = 'manual'` 随框架布局删除:window 恒不滚动,新文档/刷新后容器天然回顶。
|
||||
- 手势层同步适配:`PageFlipZone` 边界检测与 scroll 监听从 window 改为 `[data-scroll-root]`(scroll 不冒泡,监听必须挂容器;wheel/keydown 仍挂 window 靠冒泡到达)。
|
||||
|
||||
### 全站翻页链(2026-11)
|
||||
|
||||
html 按 navbar 板块入夹(`tutorial/` `skills/` `blog/` `design/` `practice/`,枢纽页用 `index.html`,根 `index.html` 不动),翻页链从 ch1–ch7 扩到全部页面并成环:
|
||||
|
||||
- **页面注册表即链**:`src/lib/pages.ts` 的 `PAGES` 有序数组就是链序——index → learn → ch1…ch7 → html/css/javascript → blog(月升序,每月:月页→文章按日期升序,从 `content/blogs.ts` 的 MONTHS/POSTS 派生)→ design → 颜色/字体/符号/组件/阴影 → practice → 回到 index。`neighborsOf()` 环形取邻居,`relHref(from, to)` 按路径深度算相对链接(`./` vs `../`,兼容 `--base` 代理),`flipTargetsOf()` 产出 `PageFlipZone` 的 prev/next。导航 `siteNavFor(from)` 也由注册表生成,站点路径只在这一处定义。
|
||||
- **装配上移**:`PageFlipZone` 从 `ChapterPage` 上移到 `lib/ui.tsx` 的 `Page`——所有走 `Page` 的页面自动入链;practice 不走 `Page`,在 App 里手动包。`FlipTarget.chapter: Chapter` 泛化为 `meta: { title, color }`(非章节页从 clash 色板取色),气泡文案随目标动态化(「▼ 继续滚动 · 下一页:{title}」)。
|
||||
- **页底翻页条**:新 `components/PageTurnBar`(← 上一页 / 返回首页 / 下一页 →,`data-dir` 带方向握手),`Page` 统一追加在内容尾部;ChapterPage 原私有页底条删除,措辞不丢(注册表 title 本身含「第 N 章 · …」)。博客文章页的「返回月份」行保留在其上。
|
||||
- **vt 握手脚本全站化**:所有 html head 都带 sessionStorage 握手内联脚本(原 ch1–ch7 独有),跨文档方向动画对全部页面生效。
|
||||
- **配套设施**:`stack.config.ts` 递归扫描入夹 html(input name = 相对路径,如 `blog/gorzil`);`stack-plugins/ssg.ts` 预渲染临时文件名把 `/` 展平为 `__`;`packages/stack` dev server 对无斜杠目录 URL(如 `/blog`)在 `blog/index.html` 存在时 308 到 `/blog/`,防止相对链接错位解析。
|
||||
|
||||
## 参考
|
||||
|
||||
- [Chrome: Cross-document view transitions for MPAs](https://developer.chrome.com/docs/web-platform/view-transitions/cross-document)
|
||||
|
||||
@@ -105,47 +105,49 @@ export async function startDevServer(
|
||||
? requestPath.slice(base.length) || '/'
|
||||
: requestPath
|
||||
const stripped = withoutBase.endsWith('/') ? withoutBase : `${withoutBase}`
|
||||
for (const candidate of [stripped, join(stripped, 'index.html')]) {
|
||||
const safe = join(distRelative, candidate)
|
||||
if (!safe.startsWith(distRelative)) continue
|
||||
if (options.serve !== undefined) {
|
||||
let served: ServedFile | null
|
||||
try {
|
||||
served = await options.serve(candidate)
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return c.text(`[stack] dev 构建未就绪:${message}`, 500)
|
||||
const isSafe = (candidate: string): boolean =>
|
||||
join(distRelative, candidate).startsWith(distRelative)
|
||||
const read = async (candidate: string): Promise<ServedFile | null> => {
|
||||
if (options.serve !== undefined) return options.serve(candidate)
|
||||
try {
|
||||
const body = await readFile(join(distRelative, candidate))
|
||||
return {
|
||||
code: body,
|
||||
contentType: MIME[extname(candidate)] ?? 'application/octet-stream',
|
||||
}
|
||||
if (served !== null) {
|
||||
const isHtml = served.contentType.startsWith('text/html')
|
||||
let code: string | Uint8Array = served.code
|
||||
if (isHtml && typeof code === 'string') {
|
||||
let text = base === '' ? code : rewriteWithBase(code, base, withoutBase)
|
||||
if (options.liveReload === true)
|
||||
text = text.replace(/<\/body>/i, `${liveScript}</body>`)
|
||||
code = text
|
||||
}
|
||||
return c.body(code, 200, {
|
||||
'Content-Type': served.contentType,
|
||||
'Cache-Control': 'no-store',
|
||||
})
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
const respond = async (served: ServedFile): Promise<Response> => {
|
||||
const isHtml = served.contentType.startsWith('text/html')
|
||||
let code: string | Uint8Array = served.code
|
||||
if (isHtml && typeof code === 'string') {
|
||||
let text = base === '' ? code : rewriteWithBase(code, base, withoutBase)
|
||||
if (options.liveReload === true) text = text.replace(/<\/body>/i, `${liveScript}</body>`)
|
||||
code = text
|
||||
}
|
||||
return c.body(code, 200, {
|
||||
'Content-Type': served.contentType,
|
||||
'Cache-Control': 'no-store',
|
||||
})
|
||||
}
|
||||
try {
|
||||
if (isSafe(stripped)) {
|
||||
const exact = await read(stripped)
|
||||
if (exact !== null) return await respond(exact)
|
||||
}
|
||||
const indexCandidate = join(stripped, 'index.html')
|
||||
if (isSafe(indexCandidate)) {
|
||||
const indexPage = await read(indexCandidate)
|
||||
if (indexPage !== null) {
|
||||
if (!withoutBase.endsWith('/')) return c.redirect(`${base}${withoutBase}/`, 308)
|
||||
return await respond(indexPage)
|
||||
}
|
||||
}
|
||||
try {
|
||||
const body = await readFile(safe)
|
||||
const isHtml = extname(safe) === '.html'
|
||||
let code: string | Buffer = body
|
||||
if (isHtml) {
|
||||
let text = body.toString('utf8')
|
||||
if (base !== '') text = rewriteWithBase(text, base, withoutBase)
|
||||
if (options.liveReload === true) text = text.replace(/<\/body>/i, `${liveScript}</body>`)
|
||||
code = text
|
||||
}
|
||||
return c.body(code, 200, {
|
||||
'Content-Type': MIME[extname(safe)] ?? 'application/octet-stream',
|
||||
'Cache-Control': 'no-store',
|
||||
})
|
||||
} catch {}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return c.text(`[stack] dev 构建未就绪:${message}`, 500)
|
||||
}
|
||||
return c.text('Not Found', 404)
|
||||
})
|
||||
|
||||