แผงเนื้อหา
Panel
A white card with rounded corners and no border, for a group of content on a page, such as an introduction, a form or a summary. With title, it's a section named by that heading. The page around it lays panels out.
เลิกใช้แล้ว
Since 0.40.0. Use Card, which does everything Panel does: every part of Card is optional, so a Card with only children is the same plain white surface. <Panel title={x}> becomes <Card title={x} description={…} icon={…}>, because a card that holds a section of a page always has its header. A Panel inside a Panel becomes a Card with tone="muted" inside a Card. className stays the same. Removed in 1.0.0.
เลิกใช้แล้วตั้งแต่ 0.40.0 และจะถูกนำออกใน 1.0.0 ให้ใช้ Card แทน Card ทำได้ทุกอย่างที่ Panel ทำ ทุกส่วนของ Card ไม่บังคับ Card ที่มีแค่ children จึงเป็นพื้นผิวสีขาวแบบเดียวกัน การ์ดที่เป็นส่วนหนึ่งของหน้ามีส่วนหัวเสมอ: title, description สั้น ๆ และ icon Panel ยังใช้ได้จนถึง 1.0.0
import { Panel } from "@bsru/ui";ตัวอย่าง
หัวหน้าใน Card
แทน <Panel><PageHeader /></Panel> ด้วย Card ที่มีแค่ children ไม่ต้องเขียนคลาสสีหรือขนาดตัวอักษรเอง
BSRU ERP
ระบบบริหารทรัพยากรองค์กร มหาวิทยาลัยราชภัฏบ้านสมเด็จเจ้าพระยา
งบประมาณและการเงิน ทรัพยากรบุคคล ทรัพย์สิน งานทะเบียนนักศึกษา และข้อมูลผู้บริหาร ในระบบเดียว
<Card>
<PageHeader kicker={t("app.name")} title={t("app.title")} description={t("app.intro")} />
</Card>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|
ส่วนที่มีหัวข้อ ด้วย Card
แทน <Panel title> ด้วย Card ที่มี title, description และ icon หัวข้อยังตั้งชื่อส่วนนั้นให้โปรแกรมอ่านหน้าจอ
ข้อมูลหน่วยงาน
ปีงบประมาณ 2570
- หน่วยงาน
- หน่วยงาน ก
- ปีงบประมาณ
- 2570
- ผู้รับผิดชอบ
- นายทดสอบ ตัวอย่าง
<Card title="ข้อมูลหน่วยงาน" description="ปีงบประมาณ 2570" icon={Building2}>
<FieldList fields={fields} />
</Card>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title | "ข้อมูลหน่วยงาน" | string | The header's heading, which also names the card for screen readers. |
| description | "ปีงบประมาณ 2570" | string | A line under the title, such as what the card counts or when it was updated. |
| icon | "Building2" | LucideIcon | An outline icon from lucide-react, in a round tile beside the title. |
การ์ดซ้อนในการ์ด
แทน Panel ที่ซ้อนใน Panel ด้วย Card tone muted ใน Card การ์ดด้านในเป็นสีเทาอ่อน และไม่ต้องมีไอคอน
ข้อมูลหน่วยงาน
ปีงบประมาณ 2570
- หน่วยงาน
- หน่วยงาน ก
- ปีงบประมาณ
- 2570
- ผู้รับผิดชอบ
- นายทดสอบ ตัวอย่าง
หมายเหตุ
ใช้ข้อมูลทดสอบเท่านั้น
<Card title="ข้อมูลหน่วยงาน" description="ปีงบประมาณ 2570" icon={Building2}>
<FieldList fields={fields} />
<Card tone="muted" title="หมายเหตุ" className="mt-4">…</Card>
</Card>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title | "ข้อมูลหน่วยงาน" | string | The header's heading, which also names the card for screen readers. |
Panel ที่เลิกใช้แล้ว
วิธีเดิม ย้ายไปใช้ Card ตามหมายเหตุด้านล่าง
ข้อมูลหน่วยงาน
- หน่วยงาน
- หน่วยงาน ก
- ปีงบประมาณ
- 2570
- ผู้รับผิดชอบ
- นายทดสอบ ตัวอย่าง
<Panel title="ข้อมูลหน่วยงาน">
<FieldList
fields={[
{ label: "หน่วยงาน", value: "หน่วยงาน ก" },
{ label: "ปีงบประมาณ", value: "2570", numeric: true },
{ label: "ผู้รับผิดชอบ", value: "นายทดสอบ ตัวอย่าง" },
]}
/>
</Panel>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title | "ข้อมูลหน่วยงาน" | string | A heading at the top, which also names the section for screen readers. Leave it out for a plain surface. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| title | string | — | A heading at the top, which also names the section for screen readers. Leave it out for a plain surface. |
| children* จำเป็น | ReactNode | — | The panel's content, such as a PageHeader, a FieldList or a form. |
| className | string | — | Placement in the page layout only, such as md:col-span-2. |
ชนิดข้อมูล
CardTone
How a card looks: plain white, feature in the app's brand gradient, or muted light grey.
type CardTone = "plain" | "feature" | "muted";ข้อควรปฏิบัติ
- ย้ายจาก Panel: <Panel> เป็น <Card> และ <Panel title={x}> เป็น <Card title={x} description={…} icon={…}> โดยเลือก icon แบบเส้นจาก lucide-react ที่ตรงกับเนื้อหา Panel ที่ซ้อนใน Panel เป็น <Card tone="muted"> className เหมือนเดิม
- เนื้อหาของ Card มีระยะห่างจากขอบของมันเอง ถ้า Panel เดิมมี div ที่ใส่ mt-4 ใต้หัวข้อ ไม่ต้องใช้แล้ว
- หัวข้อของ Panel เป็น h2 เหมือน title ของ Card ส่วนต่าง ๆ ของหน้าจึงยังเรียงหัวข้อแบบเดิม
ซอร์สโค้ด: ui/src/panel.tsx