From 0bfbefd930445337ff084cbfce36fc2cad7d5a89 Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Fri, 20 Nov 2026 14:37:43 +0700 Subject: [PATCH] feat(hero): make the three floating cards open their project - cards are links to the same project_url as the grid card (new tab, noopener) - drop aria-hidden from the stack and restore pointer events; add hover/focus/active states - entrance animation moves to the translate property with fill-mode backwards so the staggered offsets/rotation and the hover lift are no longer overridden - reduced-motion keeps the stagger (translate: none) without killing the layout --- DESIGN.md | 4 ++-- assets/css/home.css | 18 +++++++++++++++++- assets/css/motion.css | 20 ++++++++++++++++++-- ui/views/home.js | 18 +++++++++++------- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index f0d8974..397fbc3 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -51,7 +51,7 @@ - **ช่องค้นหา**: pill, เงา, ไอคอนซ้าย, ปุ่มล้างคำค้นหา 32×32 (มี label ให้ screen reader) - **การ์ดโปรเจค**: ไอคอน 46×46 (พื้น `--brand-50`), ชื่อเป็นลิงก์ที่ขยายพื้นที่คลิกเต็มใบด้วย `::after`, คำอธิบาย 3 บรรทัดตัดด้วย `-webkit-line-clamp`, ท้ายการ์ดมี host + “เปิดเว็บไซต์” - **คำว่า `hobbyproject` ในฮีโร่**: แบ่งสีตามตัวอักษร — `hobbyp` + `j` ใช้ `--brand-900` (#3D241A, 12.21:1) และ `ro` + `ect` ใช้ `--brand-500` (#C4703C, 3.12:1 บนพื้นฮีโร่เข้มสุด) จึงต้องมีขนาด ≥24px ตัวหนาขึ้นไป (ตอนนี้ clamp 24–32px) ถ้าลดต่ำกว่านั้นต้องเปลี่ยนไปใช้ `--brand-600` (#A85A2C, 4.30:1) เพื่อให้ผ่าน 4.5:1 ของตัวอักษรปกติ -- **ฮีโร่**: พื้นไล่เฉดอุ่นอ่อน + การ์ดลอย 3 ใบ **สุ่มจากโปรเจคทั้งหมดใหม่ทุกครั้งที่โหลดหน้า** (Fisher–Yates, ไม่ซ้ำ) แสดงเฉพาะ ≥1080px, `aria-hidden` +- **ฮีโร่**: พื้นไล่เฉดอุ่นอ่อน + การ์ดลอย 3 ใบ **สุ่มจากโปรเจคทั้งหมดใหม่ทุกครั้งที่โหลดหน้า** (Fisher–Yates, ไม่ซ้ำ) แสดงเฉพาะ ≥1080px — **กดได้จริง** ลิงก์ไป `project_url` เดียวกับการ์ดในกริด (`target="_blank"` + `rel="noopener noreferrer"`) จึงต้องไม่ใส่ `aria-hidden` และต้องโฟกัสด้วยคีย์บอร์ดได้ - **หลังบ้าน**: พาเนล + การ์ดรายการ, ปุ่มเลื่อนขึ้น/ลง/ลบ, แถบบันทึกแบบ sticky ด้านล่าง, `` ยืนยันการลบ/ทิ้งการแก้ไข ## 6. สิ่งที่ห้าม @@ -90,7 +90,7 @@ |---|---|---| | ชื่อเรื่องฮีโร่ | แยกเป็นคำ (`splitWordsHtml` ตัดด้วยช่องว่างเท่านั้น ปลอดภัยกับสระ/วรรณยุกต์ไทย) ยกขึ้น + คลายเบลอ | 760ms · เริ่ม 140ms · เว้น 85ms/คำ | | ป้ายเหนือหัวเรื่อง / คำโปรย / ช่องค้นหา / แถบข้อมูล | drop / rise / pop / fade ตามลำดับ | 520–760ms | -| การ์ดลอยในฮีโร่ | สุ่ม 3 ใบใหม่ทุก refresh แล้วสไลด์จากซ้ายทีละใบ | 700ms · 320/440/560ms | +| การ์ดลอยในฮีโร่ | สุ่ม 3 ใบใหม่ทุก refresh แล้วสไลด์จากซ้ายทีละใบ (`translate` + `fill-mode: backwards` เพื่อไม่ทับ `transform` เยื้อง/เอียง และไม่ทับ hover) | 700ms · 320/440/560ms | | การ์ดโปรเจค | `data-reveal="pop"` ตอนเลื่อนถึง (IntersectionObserver, `rootMargin: 2000px 0px -6% 0px`) | 660ms · หน่วง 95ms × คอลัมน์ | | หัวข้อ section | เส้นใต้กวาดจากซ้าย (`scaleX`) | 760ms | | แถบความคืบหน้า | `scaleX` ตาม scroll ผ่าน rAF | — | diff --git a/assets/css/home.css b/assets/css/home.css index 7727d45..5a996fc 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -160,7 +160,6 @@ inset-inline-end: var(--space-10); width: 302px; transform: translateY(-50%); - pointer-events: none; } .hero__deco-card { display: flex; @@ -174,8 +173,25 @@ font-size: 14px; font-weight: 500; color: var(--brand-900); + text-decoration: none; + cursor: pointer; transform: translateX(calc(var(--i) * 14px)) rotate(calc((var(--i) - 1) * -0.8deg)); opacity: 0.97; + transition: + border-color 180ms var(--ease), + box-shadow 180ms var(--ease), + translate 180ms var(--ease); + } + .hero__deco-card:hover, + .hero__deco-card:focus-visible { + border-color: var(--brand-300); + box-shadow: var(--shadow-lg); + opacity: 1; + translate: 0 -3px; + text-decoration: none; + } + .hero__deco-card:active { + translate: 0 -1px; } .hero__deco-card:nth-child(2) { border-color: var(--brand-300); diff --git a/assets/css/motion.css b/assets/css/motion.css index db899cf..0e1cfaa 100644 --- a/assets/css/motion.css +++ b/assets/css/motion.css @@ -89,6 +89,16 @@ html.fx-motion .scroll-progress__bar { transform: none; } } +@keyframes fx-deco-in { + from { + opacity: 0; + translate: -22px 0; + } + to { + opacity: 0.97; + translate: 0 0; + } +} @keyframes fx-orb-a { from { transform: translate3d(0, 0, 0) scale(1); @@ -130,8 +140,10 @@ html.fx-motion .searchbar { html.fx-motion .hero__meta { animation: fx-fade-in 620ms var(--ease) 760ms both; } +/* การ์ดลอย: ใช้ translate (ไม่ใช่ transform) และ fill-mode backwards + เพื่อไม่ให้ทับ transform เดิม (ระยะเยื้อง/ความเอียง) และไม่ทับ hover */ html.fx-motion .hero__deco-card { - animation: fx-slide-in 700ms var(--ease) both; + animation: fx-deco-in 700ms var(--ease) backwards; } html.fx-motion .hero__deco-card:nth-child(1) { animation-delay: 320ms; @@ -286,7 +298,6 @@ html.fx-motion .section-head[data-revealed] .section-head__title::after { html.fx-motion [data-reveal][data-revealed], html.fx-motion .hero__eyebrow, html.fx-motion .hero__lead, - html.fx-motion .hero__deco-card, html.fx-motion .fx-word > span, html.fx-motion .section-head[data-revealed] .section-head__title::after, html.fx-motion .btn--primary::after { @@ -295,6 +306,11 @@ html.fx-motion .section-head[data-revealed] .section-head__title::after { transform: none !important; filter: none !important; } + html.fx-motion .hero__deco-card { + animation: none !important; + opacity: 0.97 !important; + translate: none !important; + } html.fx-motion .hero__orb { animation: none !important; } diff --git a/ui/views/home.js b/ui/views/home.js index a0afbe9..009a2f3 100644 --- a/ui/views/home.js +++ b/ui/views/home.js @@ -128,15 +128,19 @@ export function homeView(ctx) { } -