คลังคอมโพเนนต์ BSRU ERP
เริ่มจากพื้นฐานการออกแบบ ได้แก่ สี ตัวอักษร มุมโค้งและเงา แล้วจึงดูคอมโพเนนต์ที่สร้างจากพื้นฐานเหล่านี้
ค่าทั้งหมดมาจาก tokens.json ซึ่งสร้างจาก source/src/theme.css ส่วน tokens.md บอกว่าใช้ค่าไหนเมื่อไร หน้าจอไม่ต้องใช้ค่าเหล่านี้เอง คอมโพเนนต์ใช้ให้แล้ว
สี
สีทั้งหมด 36 สีจาก tokens.json ใช้ผ่านคลาส Tailwind เช่น bg-green-700, text-ink-600 หรือ border-ink-200 ตัวอักษรปกติต้องมีความคมชัดอย่างน้อย 4.5:1
เขียว
สีหลักของการกระทำ ลิงก์ และสถานะที่กำลังใช้งาน ไม่ใช้ตกแต่ง
green-50#eef7f0bg-green-50green-100#d6ecdbbg-green-100green-300#8fcb9fbg-green-300green-500#38a057bg-green-500green-700#1f7533bg-green-700ปุ่มหลัก ลิงก์green-800#185c28bg-green-800ปุ่มหลักเมื่อชี้ ลิงก์green-900#123f1dbg-green-900เมนูด้านซ้าย
ม่วง
ใช้เน้น แถบหัวหน้า และสถานะเฉพาะของคำขอ ไม่ใช้กับปุ่มหลัก
purple-50#f7eff6bg-purple-50purple-100#ebd9e9bg-purple-100purple-300#cda4c8bg-purple-300purple-500#93488bbg-purple-500purple-700#76306fbg-purple-700เน้นpurple-800#5c2557bg-purple-800purple-900#3f1a3cbg-purple-900แถบหัวหน้า
ทอง
บอกสิ่งที่กำลังใช้งานบนพื้นเข้ม และสถานะรอดำเนินการ ห้ามใช้เป็นตัวอักษรบนพื้นขาว
gold-100#fdf4ccbg-gold-100gold-300#f8d858bg-gold-300รัศมี สิ่งที่เลือกบนพื้นเข้มgold-800#6b5200bg-gold-800ตัวอักษรเตือนบน gold-100
แดง
ข้อผิดพลาด การไม่อนุมัติ และคำสั่งที่ลบหรือย้อนกลับไม่ได้ ไม่ใช้เน้นเมื่อไม่มีปัญหา
red-50#fdeeecbg-red-50red-700#b3261ebg-red-700ข้อผิดพลาด คำสั่งลบred-800#8c1d18bg-red-800
หมึกและขาว
ตัวอักษร ตัวอักษรรอง เส้นขอบ ราง และพื้นที่ปิดใช้งาน
white#ffffffbg-whiteink-50#f4f5f2bg-ink-50ink-100#eaece7bg-ink-100ราง พื้นที่ปิดใช้งานink-200#d9ddd5bg-ink-200เส้นขอบink-400#868e83bg-ink-400ink-600#565d53bg-ink-600ตัวอักษรรองink-900#1e231dbg-ink-900ตัวอักษร
สีชุดข้อมูลในกราฟ
ใช้ c1 ถึง c4 ตามลำดับเสมอ สีติดตามข้อมูลแต่ละชุด สีสถานะไม่ใช้แทนชุดข้อมูล
c1#1f7533bg-c1c2#76306fbg-c2c3#b8860bbg-c3c4#2f6da8bg-c4
ไล่ระดับสำหรับแผนที่ความร้อน
ไล่สีเดียวจากน้อยไปมาก สำหรับแผนที่ความร้อน
seq-1#e4f2e7bg-seq-1seq-2#b5dcc0bg-seq-2seq-3#7cbf90bg-seq-3seq-4#3f9a5bbg-seq-4seq-5#1f7533bg-seq-5
ไล่สีของแบรนด์
ตัวอย่างจากไล่สีทั้งหมด 34 แบบ แต่ละแบบอยู่ในกลุ่มสีเดียวกัน ตัวอักษรจึงคมชัดตลอดแนว ใช้ผ่านคลาสของคอมโพเนนต์ ใช้ตัวแปรโดยตรงเฉพาะพื้นผิวใหม่ ตัวอย่างสีและเอกสารที่ระบบออกใช้สีเรียบ
--g-primaryปุ่มหลัก--g-dangerคำสั่งลบ--g-railเมนูด้านซ้าย--g-heroแถบหัวหน้า--g-inkข้อความแจ้ง คำแนะนำ--g-goldแถบสาธิต--g-pageพื้นหลังหน้า--g-surfaceแผง--g-green-softสถานะ เลือกอยู่--g-purple-softสถานะของคำขอ--g-gold-softคำเตือน รอดำเนินการ--g-red-softข้อผิดพลาด
ตัวอักษร
ตัวอักษร 3 แบบ แต่ละแบบมีหน้าที่เดียว และเว้นบรรทัดกว้าง 1.3 ถึง 1.7 เพื่อไม่ให้สระและวรรณยุกต์ชนกัน อย่าบีบระยะบรรทัด
font-display· Trirong · หัวข้อ h1, h2 และตัวเลขเด่นในแถบหัวหน้าเท่านั้นภาพรวมงบประมาณ
Budget overview
"Trirong", "Noto Serif Thai", serif
font-sans· IBM Plex Sans Thai · ทุกหน้าจอระบบตรวจสอบวงเงินคงเหลือก่อนอนุมัติทุกครั้ง
The system checks the remaining budget before every approval.
"IBM Plex Sans Thai", "Noto Sans Thai", sans-serif
font-doc· Sarabun · เอกสารที่ระบบออกใบเสร็จรับเงินอิเล็กทรอนิกส์ ภาคเรียนที่ 1/2570
Electronic receipt, semester 1/2570
"Sarabun", "TH Sarabun New", sans-serif
ขนาดตัวอักษร
text-xs0.8125rem · 13px · ระยะบรรทัด 1.6งบประมาณคงเหลือtext-sm0.875rem · 14px · ระยะบรรทัด 1.65งบประมาณคงเหลือtext-base1rem · 16px · ระยะบรรทัด 1.7งบประมาณคงเหลือtext-lg1.125rem · 18px · ระยะบรรทัด 1.65งบประมาณคงเหลือtext-xl1.375rem · 22px · ระยะบรรทัด 1.5งบประมาณคงเหลือtext-2xl1.75rem · 28px · ระยะบรรทัด 1.45งบประมาณคงเหลือtext-3xl2.25rem · 36px · ระยะบรรทัด 1.4งบประมาณคงเหลือtext-4xl3.25rem · 52px · ระยะบรรทัด 1.3งบประมาณคงเหลือ
น้ำหนักที่ใช้
- อนุมัติใบขอเบิก
font-normal· 400 · ข้อความทั่วไป - อนุมัติใบขอเบิก
font-medium· 500 · ปุ่ม แท็บ ป้ายกำกับ ป้ายสถานะ - อนุมัติใบขอเบิก
font-semibold· 600 · หัวข้อย่อย หัวตาราง และหัวข้อ Trirong - อนุมัติใบขอเบิก
font-bold· 700 · Sarabun ในเอกสารที่ระบบออก
ตัวเลขเงินเรียงตรงหลัก
tabular-nums1,234,567.89150,000.008,250.5042.00ตัวเลขที่เรียงเป็นคอลัมน์ใช้ tabular-nums และชิดขวาเสมอ
มุมโค้งและเงา
rounded-control6px · ปุ่ม ช่องกรอก ป้ายสถานะrounded-panel8px · แผง เมนูrounded-overlay12px · หน้าต่างซ้อน ป๊อปโอเวอร์shadow-overlayเฉพาะสิ่งที่ลอยเหนือหน้า
เอกสารที่ระบบออกใช้มุมเหลี่ยม พื้นผิวส่วนใหญ่ใช้เส้นขอบแทนเงา
สร้างหน้าจอจากคอมโพเนนต์
หน้าจอใน bsru-erp-web และ bsru-erp-console สร้างจากคอมโพเนนต์เหล่านี้เท่านั้น หน้าจอส่งข้อมูลเข้าไป แล้วคอมโพเนนต์แสดงผลตามแนวทางการออกแบบ หน้าตาและ CSS ทั้งหมดอยู่ที่ที่เก็บนี้ที่เดียว
แต่ละหน้ามีตัวอย่างที่ใช้งานได้จริง โค้ดที่หน้าจอต้องเขียน ตารางข้อมูลที่ส่งเข้าไปพร้อมค่าที่ใช้ได้ และตาราง props ทั้งหมดที่อ่านจากชนิดข้อมูลใน TypeScript โดยตรง
import { Badge } from "@bsru/ui";
<Badge tone="approved">อนุมัติแล้ว</Badge>พื้นฐาน
ปุ่ม
- Buttonปุ่มA button, or a link that looks like one with href.
- IconButtonปุ่มไอคอนA button that shows only an icon, such as Close or View details.
- ActionMenuเมนูคำสั่งA button that opens a short list of actions, such as Edit, Copy, Print and Delete beside a record's main action.
- CopyButtonปุ่มคัดลอกCopies a value, such as a document number, a link or code, to the clipboard.
โครงหน้าจอ
- AppShellโครงแอปThe application frame: the left menu, which collapses to icons on wide screens and slides in on phones, and the top bar with the breadcrumb, global search, language switch, notifications and account menu.
- GlobalSearchค้นหาทั้งระบบSearch across the whole system from the top bar.
- PageHeaderหัวหน้าThe top of a page: a short line saying where it belongs, the page's title as its one level 1 heading, a sentence on what it's for, and the page's actions.
- Panelแผงเนื้อหาA white surface with a border and rounded corners, for a group of content on a page, such as an introduction, a form or a summary.
- Breadcrumbเส้นทางWhere the current page sits, from the top level down.
- Tabsแท็บTabs for the parts of one record, such as details, items and history.
- Segmentedปุ่มเลือกแบบแบ่งส่วนA small set of choices in one bar, such as Day, Month and Year.
- Stepsขั้นตอนThe steps of a process, with the finished ones ticked.
- ApprovalChainลำดับการอนุมัติAn approval chain: each level, who acted and when, so anyone can see who holds the item.
- RecordSectionส่วนของหน้ารายละเอียดOne part of a record, such as Details or Items, with its heading.
ฟอร์ม
- FormFieldช่องกรอกพร้อมป้ายกำกับA form control with its label above, and its hint and error below, with the ids wired for screen readers.
- TextInputช่องข้อความA one-line text field, with an optional leading icon.
- SelectรายการตัวเลือกA dropdown list on the ARIA listbox pattern.
- NativeSelectรายการตัวเลือกมาตรฐานThe browser's own select, for long plain lists on phones, where the phone's picker is easier than a menu.
- Comboboxค้นหาอัตโนมัติA searchable field on the ARIA combobox pattern, for long lists such as vendors or budget codes.
- Checkboxช่องทำเครื่องหมายA checkbox with its label beside it.
- Switchสวิตช์An on or off setting that takes effect at once, such as Email me when approved.
- RadioCardsตัวเลือกแบบการ์ดOne choice from a few, shown as cards so each can carry a detail line, such as a leave type and the days left.
- PasswordInputช่องรหัสผ่านA password field with a leading icon and a button that shows or hides what was typed.
- SearchInputช่องค้นหาA search field with a leading icon and a clear button that shows once something is typed.
- MoneyInputช่องจำนวนเงินAn amount field.
- PhoneInputช่องเบอร์โทรศัพท์A Thai phone number field that groups the digits as 081-234-5678 while you type.
- NumberStepperช่องตัวเลขแบบเพิ่มลดA number field with minus and plus buttons.
- RangeInputแถบเลื่อนค่าA slider for a number in a range, with the value shown beside it, such as a percentage.
- ColourInputช่องเลือกสีA colour picker with the chosen colour's hex code beside it, such as for a chart series or a label.
- OtpInputช่องรหัส OTPA one-time code in separate boxes.
- FileDropแนบไฟล์A drop zone that is also a file picker.
- CountedTextareaช่องข้อความนับตัวอักษรA textarea with a count of characters used against the limit, below it on the right.
- TagInputช่องป้ายกำกับA text box that turns each entry into a chip.
ข้อมูล
- DataTableตารางข้อมูลA complete data table from columns and rows: search, criteria and filter chips, sortable headings, paging, row selection with bulk actions, a total row, and the loading, error, first-use and no-results states.
- SortHeaderหัวคอลัมน์เรียงลำดับA column heading that sorts the table.
- Paginationเลขหน้าPrevious and next buttons with page numbers between them, and an ellipsis for each gap.
- FilterChipsตัวกรองที่ใช้อยู่The filters in use, each a chip with a remove button, then Clear all.
- BulkBarแถบจัดการหลายรายการA bar for actions on the chosen rows, with the count and Clear selection.
- TableSkeletonตารางระหว่างโหลดPlaceholder rows for the first load, keeping the table's real columns.
- TableStateสถานะของตารางOne row across all columns for a table that can't show rows: `no-results` when the search or filters match nothing, `error` when the rows failed to load.
- TableFirstUseตารางที่ยังไม่มีข้อมูลShown instead of the whole table when nothing exists yet, on first use: no headers, search, criteria, pager or total.
- FieldListรายการข้อมูลA record's fields as label and value pairs.
- LineItemsรายการสินค้าThe lines of a request or document, with money right-aligned and a total row.
- AttachmentListไฟล์แนบThe files attached to a record, each with its size and a download button.
- KeyFiguresตัวเลขสำคัญA strip of a record's key figures, laid out like the KPI tiles: one column on phones, four on wide screens.
- RecordHeaderหัวหน้ารายละเอียดThe top of a record page: a link back to its list, the document number with its status, the item's name, and the actions.
- ConfirmChangeยืนยันก่อนบันทึกAsks the person to confirm a change before anything is saved, when AI proposes it on their behalf.
- DocumentSheetเอกสารAn issued document, such as a receipt, as it prints: Sarabun on white, the logo and title at the top, the stamp, its lines and the total.
กราฟ
- ChartกรอบกราฟThe frame every chart sits in: title, optional controls and legend, the SVG drawn at the canvas's real width (at least 240px), a tooltip for any mark with data-tip, an optional footer and the table view.
- LineChartกราฟเส้นValues over time as a line, area or step chart, with a style switch.
- BarChartกราฟแท่งCompares groups as grouped, stacked or 100% bars, with a switch between them.
- DonutChartกราฟโดนัทWhat share each part is, as a donut with the total in the middle.
- GaugeChartมาตรวัดOne percentage against a target, as a half-circle gauge with a target tick.
- BulletChartกราฟเทียบเป้าSeveral percentages against one target, as horizontal bars on a track with a target line.
- WaterfallChartกราฟน้ำตกHow a balance changed: totals stand on the baseline, and each change floats from the running balance.
- Heatmapแผนภาพความร้อนWhere values are high or low, as a grid of rows by columns in five shades of green.
- SlopeChartกราฟความชันWhat changed between two periods, as one line per measure from the left axis to the right.
- KpiTilesตัวชี้วัดA row of key figures, each with its change and a trend line.
- Sparklineกราฟเส้นขนาดเล็กA trend line that fills its box.
- SealChartกราฟตราประทับThe signature chart: the university seal drawn from data.
- BudgetBarแถบงบประมาณA budget line's four figures and its split as one bar: actual from the left, committed after it, and the rest remaining.
การตอบสนอง
- Badgeป้ายสถานะReports a state and can't be pressed.
- ChipชิปA choice or filter the user turns on and off.
- StatusDotจุดสถานะA small coloured dot with text beside it, for a live state such as a service being available.
- Alertข้อความแจ้งเตือนA message that stays on the page: what happened and what to do next.
- Toastข้อความชั่วคราวShows toasts at the bottom right.
- ProgressBarแถบความคืบหน้าA progress bar on the native progress element, so the value never needs a style attribute.
- ProgressRingวงแหวนความคืบหน้าA ring for one share of a whole, such as items counted so far.
- SpinnerตัวหมุนรอโหลดA small spinner for work of unknown length.
- Skeletonโครงร่างระหว่างโหลดA grey placeholder line while content loads.
- Veilม่านระหว่างบันทึกCovers only the busy area, so the rest of the page stays usable.
- Tooltipคำอธิบายเมื่อชี้Short help that shows on hover and on keyboard focus.
หน้าต่างซ้อน
- Dialogกล่องโต้ตอบA modal dialog for a decision, built on the native dialog element, so focus stays inside and Esc closes it.
- Drawerแผงด้านข้างA panel from the right edge, for a record's details beside the list it came from: a quick look and a decision without losing your place.
- Popoverกล่องข้อมูลA button that opens a small box of extra information beside it, such as what a term means.