From 2eb625c8bcd32d15a02c826a837db1830e6c14fd Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Sat, 14 Nov 2026 13:11:45 +0700 Subject: [PATCH] =?UTF-8?q?fix(css):=20Safari/iOS=20parity=20+=20@layer=20?= =?UTF-8?q?base=20=E0=B9=83=E0=B8=AB=E0=B9=89=20utility=20=E0=B8=A2?= =?UTF-8?q?=E0=B8=B1=E0=B8=87=E0=B8=8A=E0=B8=99=E0=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- DESIGN.md | 22 +++++---- app/components/admin/form-styles.ts | 2 +- app/components/home/HeroSection.tsx | 2 +- app/global.css | 71 ++++++++++++++++++++--------- app/routes/admin.tsx | 4 +- app/routes/admin_.login.tsx | 2 +- public/sw.js | 2 +- 7 files changed, 68 insertions(+), 37 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 01f780e..54dbe78 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -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` บน ``** — ทำให้ 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` บน ``** — ทำให้ 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) -- **`
/`**: ซ่อน 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/`, `/for-cinemas`, `/admin` — ดูสกรอลบาร์/select/`
`/ปุ่มต้องหน้าตาเดียวกัน +- **`
/`**: ซ่อน 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/`, `/for-cinemas`, `/admin` ในทั้งสามเอนจิน — สกรอลบาร์/select/`
`/ปุ่ม/ขนาดช่องค้นหาต้องเท่ากัน (มือถือ 16px, เดสก์ท็อป 14px) ## Agent-Native is structural, not visual diff --git a/app/components/admin/form-styles.ts b/app/components/admin/form-styles.ts index 59be8c6..d3fd33b 100644 --- a/app/components/admin/form-styles.ts +++ b/app/components/admin/form-styles.ts @@ -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]"; diff --git a/app/components/home/HeroSection.tsx b/app/components/home/HeroSection.tsx index 6578545..938250c 100644 --- a/app/components/home/HeroSection.tsx +++ b/app/components/home/HeroSection.tsx @@ -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" />