feat(motion): scroll-reveal and cinematic entrance animations

- motion.css / motion.js: reveal-on-scroll (IntersectionObserver), hero word-by-word
  entrance, drifting warm orbs, sheen on primary CTA, section underline sweep,
  scroll progress bar, count-up numbers
- content never hidden unless <html>.fx-motion: JS off or reduced-motion shows everything
- hover lift moved to the translate property so reveal keyframes cannot override it
- re-call initReveal after grid re-render and admin re-mount; SW precache + VERSION bump
- docs: DESIGN.md §9 motion contract, AGENTS.md pitfalls
This commit is contained in:
Bkk1234 committed 2026-11-19 01:10:27 +07:00
1 parent c00bc62272
commit 2950295690
10 files changed
+503 -12

No files matched your search

+6 -3
View File
@@ -1,6 +1,7 @@
/* views/admin.js — หลังบ้าน: แก้ชื่อ/คำอธิบาย/ลิงก์ แล้วเผยแพร่หรือดาวน์โหลด JSON */
import { escapeHtml, icon, isEmail, normalizeUrl, toast, debounce } from "../ui.js";
import { initReveal } from "../motion.js";
import {
clearDraft,
createProject,
@@ -90,7 +91,7 @@ export function adminView(ctx) {
<span data-status-extra></span>
</div>
<section class="panel" aria-labelledby="site-panel-title">
<section class="panel" data-reveal="fade" aria-labelledby="site-panel-title">
<div class="panel__head">
<h2 class="panel__title" id="site-panel-title">ข้อความบนหน้าเว็บ</h2>
</div>
@@ -120,7 +121,7 @@ export function adminView(ctx) {
</div>
</section>
<section class="panel" aria-labelledby="projects-panel-title">
<section class="panel" data-reveal="fade" aria-labelledby="projects-panel-title">
<div class="panel__head">
<h2 class="panel__title" id="projects-panel-title">
รายชื่อโปรเจค (<span data-project-count>${draft.projects.length}</span>)
@@ -134,7 +135,7 @@ export function adminView(ctx) {
</div>
</section>
<section class="panel" aria-labelledby="publish-panel-title">
<section class="panel" data-reveal="fade" aria-labelledby="publish-panel-title">
<div class="panel__head">
<h2 class="panel__title" id="publish-panel-title">ช่องทางบันทึก</h2>
</div>
@@ -184,6 +185,8 @@ export function adminView(ctx) {
}
refreshDirty();
checkApi();
// เรียกซ้ำได้เสมอ เพราะ mount() ถูกเรียกใหม่หลังกด “ทิ้งการแก้ไข”
initReveal(root);
}
function bindSiteFields() {
+14 -6
View File
@@ -1,6 +1,7 @@
/* views/home.js — หน้าแรก: ข้อความต้อนรับ + ค้นหา + การ์ดโปรเจค */
import { escapeHtml, hostOf, icon, normalizeUrl } from "../ui.js";
import { initReveal, splitWordsHtml } from "../motion.js";
export function homeView(ctx) {
let root = null;
@@ -21,7 +22,7 @@ export function homeView(ctx) {
});
}
function cardHtml(project) {
function cardHtml(project, index = 0) {
const url = normalizeUrl(project.project_url);
const host = hostOf(project.project_url);
const name = escapeHtml(project.project_name || "ไม่มีชื่อโปรเจค");
@@ -30,7 +31,7 @@ export function homeView(ctx) {
? `<a href="${escapeHtml(url)}" target="_blank" rel="noopener noreferrer">${name}</a>`
: `<span>${name}</span>`;
return `
<article class="project-card">
<article class="project-card" data-reveal="pop" style="--fx-delay:${(index % 3) * 95}ms">
<div class="project-card__top">
<span class="project-card__icon" aria-hidden="true">${icon(project.icon)}</span>
<div class="project-card__heading">
@@ -70,7 +71,9 @@ export function homeView(ctx) {
return;
}
gridEl.className = "project-grid";
gridEl.innerHTML = items.map(cardHtml).join("");
gridEl.innerHTML = items.map((project, index) => cardHtml(project, index)).join("");
// การ์ดชุดใหม่หลังกรองต้องถูก observe/เปิดให้เห็นด้วย ไม่งั้นจะค้างที่ opacity 0
initReveal(gridEl);
}
return {
@@ -83,12 +86,17 @@ export function homeView(ctx) {
root.innerHTML = `
<div class="wrap">
<section class="hero" aria-labelledby="hero-title">
<div class="hero__ambience" aria-hidden="true">
<span class="hero__orb hero__orb--a"></span>
<span class="hero__orb hero__orb--b"></span>
</div>
<div class="hero__inner">
<p class="hero__eyebrow">${icon("spark")}<span>${escapeHtml(
site.site_title,
)}</span></p>
<h1 class="hero__title" id="hero-title">${escapeHtml(
<h1 class="hero__title" id="hero-title">${splitWordsHtml(
site.welcome_message,
escapeHtml,
)}</h1>
<p class="hero__lead">รวมเว็บที่ทำเองไว้ในที่เดียว เลือกดูได้ตามใจ ไม่มีโฆษณา ไม่มีล็อกอิน</p>
<form class="searchbar" role="search" autocomplete="off">
@@ -101,7 +109,7 @@ export function homeView(ctx) {
</button>
</form>
<div class="hero__meta">
<span>${icon("folder")}${total} โปรเจค</span>
<span>${icon("folder")}<span data-countup="${total}">${total}</span> โปรเจค</span>
<span>${icon("shield")}${escapeHtml(site.ssl_note)}</span>
${
withEmail
@@ -124,7 +132,7 @@ export function homeView(ctx) {
</div>
</section>
<div class="section-head">
<div class="section-head" data-reveal="fade">
<div>
<h2 class="section-head__title" id="projects-title">รายชื่อโปรเจค</h2>
<p class="section-head__sub">กดที่การ์ดเพื่อเปิดเว็บนั้นในแท็บใหม่</p>