mirror of
https://github.com/saltbo/zpan.git
synced 2026-09-19 01:51:11 +08:00
2.9 KiB
2.9 KiB
Admin Form UI
This document defines the UI rules for admin create/edit/configuration forms.
Surface
- Admin create/edit/configuration forms must live in
AdminFormDrawer, a dialog, or a dedicated secondary page. - Do not place management forms directly in primary list/detail page content.
- Drawer actions belong in the drawer footer. Use one horizontal row: secondary action first, primary submit last.
- Do not auto-focus the first input when it creates visual noise. Use
onOpenAutoFocus={(event) => event.preventDefault()}for configuration drawers where immediate typing is not the primary action.
Layout
- Use
AdminFormDrawerfor admin drawers. - Use
bodyClassName="grid auto-rows-min content-start gap-4"for ordinary vertical forms. - Use
auto-rows-min content-startwhenever the body uses CSS grid; otherwise grid rows can stretch and create large empty gaps. - Use
AdminFormFieldfor text, password, number, textarea, and select-like fields. - Use
AdminFormLabelonly when a field needs custom composition, such as input suffix controls. - Use
AdminSwitchFieldfor switch rows unless a form-specific compact inline layout is required. - Keep cards out of forms unless the section is a genuinely framed, repeated, or gated sub-surface.
Field Rules
- Every input must have a label.
- Every input must have a placeholder. Use concise examples, not instructions.
- Required fields must use
requiredonAdminFormFieldorAdminFormLabel; this shows the required marker and setsaria-required. - Long explanations belong in
help, not always-visible body text. - Use visible
descriptiononly when the text is needed while editing and is short enough to not dominate the field. - Error text stays under the control via
error.
Density
- Default field spacing is intentionally compact but readable:
- Field internal spacing:
AdminFormFielddefault. - Form item spacing: drawer body
gap-4.
- Field internal spacing:
- Do not use viewport-sized spacing, stretched grid rows, or large section padding in forms.
- Do not over-compress form items below
gap-3unless the form is a dense table-like editor.
Switches
- Switches should not appear as oversized cards.
- If a switch enables dependent fields, keep those fields visible and disabled when off unless hiding them materially improves comprehension.
- Put plan badges, such as
ProBadge, next to the field label. - Put explanatory text behind
helpunless it is a gate notice or required state message.
Input Suffixes
- For numeric value + unit controls, prefer a single composed control that visually reads as one input with a suffix selector.
- Do not show a separate preview when it duplicates the selected value and unit.
- Keep disabled suffix controls visually disabled as one group.
Localization
- Labels, placeholders, help text, descriptions, errors, and success messages must use i18n keys.
- New
admin.storages.*keys must be added to the corresponding locale test.