Files
web-alterflixhub/app/components/admin/AdminSection.tsx
T
2026-11-01 17:24:44 +07:00

52 lines
1.9 KiB
TypeScript

import { IconChevronRight } from "@tabler/icons-react";
import type { ReactNode } from "react";
/**
* หมวดการ์ดแบบพับได้ของหลังบ้าน (ใช้ <details> เนทีฟ — คีย์บอร์ดและ screen reader ทำงานได้เอง)
* ค่าเริ่มต้น = พับเก็บ เพื่อไม่ให้หน้าแอดมินยืดยาว
*/
type Props = {
title: string;
description?: string;
/** ข้อความสั้น ๆ เช่นจำนวนรายการ */
badge?: string;
defaultOpen?: boolean;
children: ReactNode;
};
export function AdminSection({
title,
description,
badge,
defaultOpen = false,
children,
}: Props) {
return (
<details
open={defaultOpen}
className="group overflow-hidden rounded-xl border border-[#242424] bg-[#111111]"
>
<summary className="flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 transition hover:bg-[#171717] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[#A92626] [&::-webkit-details-marker]:hidden">
<span className="flex min-w-0 items-center gap-2">
<IconChevronRight
size={16}
className="shrink-0 text-[#8F8F8F] transition-transform group-open:rotate-90"
/>
<span className="truncate text-sm font-medium">{title}</span>
{badge ? (
<span className="shrink-0 rounded-full bg-[#242424] px-2 py-0.5 text-[11px] text-[#B3B3B3]">
{badge}
</span>
) : null}
</span>
{description ? (
<span className="hidden shrink-0 text-[11px] text-[#777] sm:block">
{description}
</span>
) : null}
</summary>
<div className="border-t border-[#242424] px-4 py-4">{children}</div>
</details>
);
}