reboot alterflixhub
This commit is contained in:
commit
1e84023a44
188 files changed
+31629
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import { IconCircleCheck, IconMapPin, IconSearch } from "@tabler/icons-react";
|
||||
|
||||
import type { NearMeStatus } from "@/hooks/use-near-me";
|
||||
import { useI18n } from "@/lib/i18n";
|
||||
|
||||
type HeroSectionProps = {
|
||||
query: string;
|
||||
onQueryChange: (query: string) => void;
|
||||
nearMeStatus: NearMeStatus;
|
||||
onRequestLocation: () => void;
|
||||
};
|
||||
|
||||
/** ข้อความสถานะของปุ่ม "ใกล้ฉัน" — แสดงเฉพาะตอนกำลังหา/ผิดพลาด/พร้อมใช้ */
|
||||
function statusMessage(status: NearMeStatus, messages: ReturnType<typeof useI18n>["messages"]) {
|
||||
switch (status) {
|
||||
case "locating":
|
||||
return messages.search.locating;
|
||||
case "denied":
|
||||
return messages.search.denied;
|
||||
case "unsupported":
|
||||
return messages.search.unsupported;
|
||||
case "error":
|
||||
return messages.search.error;
|
||||
case "ready":
|
||||
return messages.search.sortedByDistance;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** ฮีโร่หน้าแรก: หัวข้อ + ช่องค้นหา (ค้นทันทีขณะพิมพ์) + ปุ่มหาตำแหน่ง */
|
||||
export function HeroSection({
|
||||
query,
|
||||
onQueryChange,
|
||||
nearMeStatus,
|
||||
onRequestLocation,
|
||||
}: HeroSectionProps) {
|
||||
const { messages } = useI18n();
|
||||
const status = statusMessage(nearMeStatus, messages);
|
||||
const isReady = nearMeStatus === "ready";
|
||||
|
||||
return (
|
||||
<section className="mx-auto flex max-w-[1016px] flex-col items-center gap-10 pt-24 md:pt-[167px]">
|
||||
<div className="flex max-w-[745px] flex-col items-center gap-4 text-center">
|
||||
<h1 className="text-4xl font-bold leading-[1.3] md:text-[56px]">
|
||||
{messages.hero.titlePrefix}
|
||||
<span className="text-[#A92626]">{messages.hero.titleHighlight}</span>
|
||||
{messages.hero.titleSuffix}
|
||||
</h1>
|
||||
<p className="text-base md:text-xl">{messages.hero.subtitle}</p>
|
||||
</div>
|
||||
|
||||
<div className="w-full rounded-2xl border border-[#303030] bg-[#1B1B1B]/80 px-4 py-6 backdrop-blur-[32px] md:px-10">
|
||||
<div className="flex h-14 items-center gap-3 rounded-lg border border-[#1B1B1B] bg-[#1F1F1F] px-5">
|
||||
<IconSearch size={16} className="shrink-0 text-[#999]" />
|
||||
<input
|
||||
value={query}
|
||||
onChange={(event) => onQueryChange(event.target.value)}
|
||||
placeholder={messages.search.placeholder}
|
||||
aria-label={messages.search.placeholder}
|
||||
className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#454545]"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onRequestLocation}
|
||||
disabled={nearMeStatus === "locating"}
|
||||
aria-label={messages.search.nearMe}
|
||||
className={`hidden items-center gap-2 border-l border-[#999] px-4 text-sm transition disabled:opacity-60 sm:flex ${
|
||||
isReady ? "text-[#D47272]" : "text-[#999] hover:text-white"
|
||||
}`}
|
||||
>
|
||||
{isReady ? <IconCircleCheck size={16} /> : <IconMapPin size={16} />}
|
||||
{messages.search.nearMe}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="h-8 rounded-lg border border-[#8F0808] bg-[#8F0808] px-6 text-sm font-medium transition hover:bg-[#a30a0a]"
|
||||
>
|
||||
{messages.search.submit}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{status ? (
|
||||
<p
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
className={`px-1 pt-3 text-xs ${
|
||||
nearMeStatus === "ready" ? "text-[#B3B3B3]" : "text-[#D47272]"
|
||||
}`}
|
||||
>
|
||||
{status}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user