fix(css): Safari/iOS parity + @layer base ให้ utility ยังชนะ

- iOS Safari: ฟอร์ม ≥16px บนมือถือ (กัน auto-zoom โดยไม่ต้องล็อก user-scalable), input[type=search] appearance:none, tap-highlight transparent, text-size-adjust 100%
- ย้ายบล็อก cross-engine เข้า @layer base — เดิม unlayered ทับ text-sm ทำให้ desktop เพี้ยนเป็น 16px
- admin 3 จุด min-h-screen → min-h-dvh
- DESIGN.md: ขยายหัวข้อเป็น Chromium/Firefox/Safari + กฎ @layer · sw VERSION v2.0.3
This commit is contained in:
Bkk1234 committed 2026-11-14 13:11:45 +07:00
1 parent 301ad22a39
commit 2eb625c8bc
7 files changed
+68 -37

No files matched your search

+12 -10
View File
@@ -88,20 +88,22 @@ part of that build, not leave them as an empty template.
- **contrast ที่วัดจริง** (พื้น `#0D0D0D`): `#B3B3B3` 9.27 · `#D47272` 5.97 · **`#A92626` = 2.77 → ห้ามใช้กับตัวอักษร** (ใช้ได้เฉพาะเส้นขอบ/พื้น) · placeholder ช่องค้นหาใช้ `#8A8A8A` (4.77 บน `#1F1F1F`) ไม่ใช่ `#454545` (1.72)
- **hit area ≥ 44px**: ปุ่มที่หน้าตาเล็กกว่า (ใกล้ฉัน 20px, TH/EN 26px, chip 38px, ลูกศรแกลเลอรี 40px) ขยายด้วย `after:absolute after:-inset-*` — ห้ามเปลี่ยนความสูงที่มองเห็นเพื่อเพิ่ม hit area
## Cross-engine parity (Chromium / Firefox) — บังคับ
## Cross-engine parity (Chromium / Firefox / Safari) — บังคับ
เป้าหมาย: **Firefox ต้องดูและรู้สึกใกล้ Chromium ที่สุด** โดยไม่ต้องมี build แยก
เป้าหมาย: **Firefox และ Safari ต้องดู/รู้สึกใกล้ Chromium ที่สุด** โดยไม่ต้องมี build แยก · กฎทั้งหมดอยู่ใน `app/global.css` หัวข้อ "ความเท่ากันข้ามเอนจิน"
- **สกรอลบาร์**: Chromium/Safari ใช้ `::-webkit-scrollbar` (5px, `--muted-foreground/0.22`) · Firefox ไม่รู้จัก → ต้องมี `scrollbar-width: thin` + `scrollbar-color` คู่กันเสมอ (ตอนนี้ประกาศที่ `*` ใน `global.css`) · ห้ามลบฝั่งใดฝั่งหนึ่ง
- **`color-scheme: dark` บน `<html>`** — ทำให้ select/scrollbar/ฟอร์มเนทีฟ/autofill เป็นโทนเข้มทั้งสองเอนจิน (ถ้าไม่มี Firefox จะได้ select ขาวสว่างกลางธีมดำ)
- **สำคัญ: ต้องอยู่ใน `@layer base`** — CSS ที่ไม่ใส่ layer จะชนะ utility ของ Tailwind ทั้งหมด (เคสจริง: `input { font-size: 16px }` แบบ unlayered ทับ `text-sm` ทำให้ desktop กลายเป็น 16px)
- **สกรอลบาร์**: Chromium/Safari ใช้ `::-webkit-scrollbar` (5px, `--muted-foreground/0.22`) · Firefox ไม่รู้จัก → ต้องมี `scrollbar-width: thin` + `scrollbar-color` คู่กันเสมอ · ห้ามลบฝั่งใดฝั่งหนึ่ง
- **`color-scheme: dark` บน `<html>`** — ทำให้ select/scrollbar/ฟอร์มเนทีฟ/autofill เป็นโทนเข้มทุกเอนจิน
- **`::selection`** ต้องประกาศเอง (`#A92626` พื้น, ตัวอักษรขาว) — ไม่งั้นได้สีฟ้าตาม OS ซึ่งคนละเฉดในแต่ละเอนจิน
- **`::-moz-focus-inner`** reset (`border:0; padding:0`) สำหรับ `button`/`input` — Firefox ใส่ padding ภายในเองทำให้ปุ่มเตี้ย/กว้างต่างจาก Chromium เล็กน้อย
- **`::-moz-focus-inner`** reset (`border:0; padding:0`) สำหรับ `button`/`input`
- **`mask-image`** ต้องมีทั้ง `-webkit-mask-image` (Safari) และ `mask-image` (Firefox/Chromium)
- **`<details>/<summary>`**: ซ่อน marker ด้วย `list-none` (Firefox ใช้ `list-style: none`) **และ** `[&::-webkit-details-marker]:hidden` (Chromium) — ต้องมีทั้งคู่
- **`backdrop-blur`**: งบไม่เกิน **24px** ต่อชั้น (เดิม hero ใช้ 32px) — `backdrop-filter` ของ Firefox แพงกว่ามากและทำให้เลื่อนกระตุก · ห้ามซ้อน blur หลายชั้นใน element เดียว
- **ห้ามใส่ `-webkit-font-smoothing`** — ไม่มีผลใน Firefox ทำให้เห็นความต่างชัดขึ้นแทนที่จะเท่ากัน (การเรนเดอร์ฟอนต์ไทยสองเอนจินไม่มีทางเท่ากัน 100% — ยอมรับ)
- **สิ่งที่ต่างโดยธรรมชาติและไม่ต้องแก้**: Firefox เดสก์ท็อปไม่มี `navigator.share` (fallback คัดลอกลิงก์ทำงานอยู่) · ไม่มี install prompt ของ PWA (`beforeinstallprompt` ไม่มี) · inertia การเลื่อนต่างกัน
- ทดสอบ: เปิดทั้งสองเบราว์เซอร์ที่หน้า `/`, `/cinema/<slug>`, `/for-cinemas`, `/admin` — ดูสกรอลบาร์/select/`<details>`/ปุ่มต้องหน้าตาเดียวกัน
- **`<details>/<summary>`**: ซ่อน marker ด้วย `list-none` (Firefox) **และ** `[&::-webkit-details-marker]:hidden` (Chromium/Safari)
- **`backdrop-blur`**: งบไม่เกิน **24px** ต่อชั้น (hero เดิม 32px) · `-webkit-backdrop-filter` มาจาก Tailwind เอง ไม่ต้องเขียนเพิ่ม · ระวัง `position: sticky` + blur บน iOS (อาจกระพริบ)
- **iOS Safari**: ฟอร์มทุกช่องต้อง **≥16px บนมือถือ** (`text-base sm:text-sm`) ไม่งั้นเบราว์เซอร์ซูมหน้าเองเมื่อโฟกัส — **ห้ามแก้ด้วย `user-scalable=no`** (ผิด WCAG 1.4.4) · `input[type=search]` ต้อง `appearance: none` (iOS ใส่กรอบ/มุมโค้งเอง) · `-webkit-tap-highlight-color: transparent` และ `-webkit-text-size-adjust: 100%`
- **ห้ามใส่ `-webkit-font-smoothing`** — ไม่มีผลใน Firefox และทำให้ความต่างชัดขึ้น
- **สิ่งที่ต่างโดยธรรมชาติ ไม่ต้องแก้**: Firefox ไม่มี `navigator.share` / install prompt · Safari ไม่มี install prompt (`beforeinstallprompt` ไม่มี แต่ `display: standalone` ใน manifest ทำให้ติดตั้งจากเมนูแชร์ได้) · iOS ล้าง cache ของ SW เมื่อไม่ใช้งาน 7 วัน (ITP) · inertia การเลื่อนต่างกัน
- ทดสอบ: `/`, `/cinema/<slug>`, `/for-cinemas`, `/admin` ในทั้งสามเอนจิน — สกรอลบาร์/select/`<details>`/ปุ่ม/ขนาดช่องค้นหาต้องเท่ากัน (มือถือ 16px, เดสก์ท็อป 14px)
## Agent-Native is structural, not visual
+1 -1
View File
@@ -4,7 +4,7 @@
* (ห้ามประกาศ inputClass/labelClass ซ้ำใน component)
*/
export const inputClass =
"w-full rounded-lg border border-[#303030] bg-[#141414] px-3 py-2 text-sm text-white outline-none transition focus:border-[#A92626] focus-visible:ring-2 focus-visible:ring-[#A92626]/40";
"w-full rounded-lg border border-[#303030] bg-[#141414] px-3 py-2 text-base text-white outline-none transition focus:border-[#A92626] focus-visible:ring-2 focus-visible:ring-[#A92626]/40 sm:text-sm";
export const labelClass = "flex flex-col gap-1.5 text-xs text-[#999]";
+1 -1
View File
@@ -90,7 +90,7 @@ export function HeroSection({
aria-label={messages.search.placeholder}
type="search"
enterKeyHint="search"
className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#8A8A8A] [&::-webkit-search-cancel-button]:hidden"
className="min-w-0 flex-1 bg-transparent text-base text-white outline-none placeholder:text-[#8A8A8A] md:text-sm [&::-webkit-search-cancel-button]:hidden"
/>
<button
type="button"
+50 -21
View File
@@ -268,30 +268,59 @@
background: hsl(var(--muted-foreground) / 0.34);
}
/* ══ ความเท่ากันข้ามเอนจิน (Chromium / Firefox) ═══════════════════════════
ทุกอย่างในบล็อกนี้มีไว้เพื่อให้ Firefox ดู/ทำงานใกล้ Chromium ที่สุด
- `::-webkit-scrollbar` (ด้านบน) Firefox ไม่รู้จัก → ต้องมี scrollbar-width/color
- `color-scheme: dark` ทำให้ select/scrollbar/ฟอร์มเนทีฟเป็นโทนเข้มทั้งสองเอนจิน
- `::selection` ใช้สีแบรนด์แทนสีฟ้าเริ่มต้นของ OS (คนละสีในแต่ละเอนจิน)
- `::-moz-focus-inner` กันระยะขอบภายในปุ่มที่ Firefox ใส่เอง */
html {
color-scheme: dark;
}
@layer base {
/* ══ ความเท่ากันข้ามเอนจิน (Chromium / Firefox / Safari) ══════════════════
อยู่ใน @layer base เพื่อให้ utility ของ Tailwind (เช่น `text-sm`) ยังชนะได้
ทุกอย่างในบล็อกนี้มีไว้เพื่อให้ Firefox และ Safari ดู/ทำงานใกล้ Chromium ที่สุด
- `::-webkit-scrollbar` (ด้านบน) Firefox ไม่รู้จัก → ต้องมี scrollbar-width/color
- `color-scheme: dark` ทำให้ select/scrollbar/ฟอร์มเนทีฟเป็นโทนเข้มทุกเอนจิน
- `::selection` ใช้สีแบรนด์แทนสีฟ้าเริ่มต้นของ OS (คนละสีในแต่ละเอนจิน)
- `::-moz-focus-inner` กันระยะขอบภายในปุ่มที่ Firefox ใส่เอง
- Safari/iOS: ตัดไฮไลต์เทาตอนแตะ, กันข้อความพองตอนหมุนจอ, ตัดสไตล์เนทีฟของช่องค้นหา */
html {
color-scheme: dark;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
}
* {
scrollbar-width: thin;
scrollbar-color: hsl(var(--muted-foreground) / 0.22) transparent;
}
* {
scrollbar-width: thin;
scrollbar-color: hsl(var(--muted-foreground) / 0.22) transparent;
}
::selection {
background-color: #a92626;
color: #ffffff;
}
::selection {
background-color: #a92626;
color: #ffffff;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/* iOS Safari ใส่กรอบ/มุมโค้งของตัวเองให้ช่องค้นหา — ตัดออกให้เหมือน desktop */
input[type="search"] {
-webkit-appearance: none;
appearance: none;
}
/* iOS Safari ซูมหน้าเมื่อโฟกัสช่องที่ font-size < 16px — ฟอร์มทุกตัวจึงใช้ 16px บนมือถือ
(ห้ามล็อกซูมด้วย user-scalable=no เพราะผิด WCAG 1.4.4) */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
font-size: 16px;
}
@media (min-width: 640px) {
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
font-size: inherit;
}
}
}
/* ══ Motion — อนิเมชันเล็ก ๆ ตอนโหลด/เลื่อน ═══════════════════════════════
+2 -2
View File
@@ -242,7 +242,7 @@ export default function AdminRoute() {
if (!store) {
return (
<div className="flex min-h-screen items-center justify-center bg-[#0D0D0D] text-sm text-[#999]">
<div className="flex min-h-dvh items-center justify-center bg-[#0D0D0D] text-sm text-[#999]">
กำลังโหลดข้อมูลหลังบ้าน…
</div>
);
@@ -252,7 +252,7 @@ export default function AdminRoute() {
const locales = store.site.locales;
return (
<div className="min-h-screen bg-[#0D0D0D] text-white">
<div className="min-h-dvh bg-[#0D0D0D] text-white">
<header className="sticky top-0 z-10 flex flex-wrap items-center justify-between gap-3 border-b border-[#242424] bg-[#0D0D0D]/95 px-6 py-4">
<div>
<h1 className="text-xl font-semibold">หลังบ้าน AlterFlixHub</h1>
+1 -1
View File
@@ -59,7 +59,7 @@ export default function AdminLoginRoute() {
}
return (
<div className="flex min-h-screen items-center justify-center bg-[#0D0D0D] px-5 text-white">
<div className="flex min-h-dvh items-center justify-center bg-[#0D0D0D] px-5 text-white">
<form
onSubmit={submit}
className="w-full max-w-sm rounded-2xl border border-[#303030] bg-[#141414] p-6"
+1 -1
View File
@@ -18,7 +18,7 @@
* | โดเมนอื่น (รูป hotlink) | ไม่จัดการ |
* | /app/* · /node_modules/* · /@* | ไม่จัดการ (โมดูลของ dev server) |
*/
const VERSION = "v2.0.2";
const VERSION = "v2.0.3";
const PAGES_CACHE = `alterflixhub-pages-${VERSION}`;
const ASSETS_CACHE = `alterflixhub-assets-${VERSION}`;