mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-27 10:43:45 +00:00
Register golden paths, YAGNI, and verify:ui in app instructions and Cursor rules. Co-authored-by: zuiidea <zuiiidea@gmail.com>
2.6 KiB
2.6 KiB
applyTo, description
| applyTo | description |
|---|---|
| src/**/*.{ts,tsx,css} | Use when editing React UI, route pages, components, styles, layout, or Ant Design behavior. Keywords: frontend, component, page, ui, layout, style, antd. |
Frontend Instructions
Purpose
Keep frontend changes predictable, minimal, and reusable for AI-assisted edits.
Do
- Preserve existing route contracts and UI behavior unless explicitly asked.
- Prefer reusable components and hooks over copy-paste logic.
- Keep styles token-driven using
src/theme/theme.config.tsandtheme.useToken(). - For Ant Design styling, follow this priority: component native API (
variant/type/size/styles/classNames) ->theme.useToken()with inlinestyle->className+ external CSS. - Follow current folder conventions under src/components and src/routes.
Do Not
- Do not introduce new UI libraries when Ant Design already covers the need.
- Do not bypass existing theme/store abstractions with hardcoded global state.
- Do not write CSS overrides first when props or semantic
stylescan express the same UI. - Do not put literal
#hex/rgb()/hsl()colors in business TSX (usetheme.configor tokens). - Do not refactor unrelated files in the same change.
Golden paths
Classify the page archetype, open the golden path, copy file split and data flow, then replace domain schema/API/columns only.
| Archetype | Path |
|---|---|
| ListCRUD | src/routes/_auth/users/ (includes -Toolbar.tsx, -FormModal.tsx) |
| Auth | src/routes/login/ |
| Dashboard | src/routes/_auth/dashboard/ |
| Shell | src/components/Layout/ |
| Error | src/components/NotFound/, src/components/RouteError.tsx |
Ant Design and tokens
- Prefer
Flex/Space/Row/Colfor layout intent. - Brand and seed tokens live only in
src/theme/theme.config.ts(optionalcolorPrimary). - Menu/table chrome algorithms stay in
hooks/tokenBuilders.ts.
Div and CSS exceptions
- Native
divis allowed forrefmeasure slots, scroll containers, and third-party DOM requirements. - New CSS files must be on the
verify:uiallowlist (seescripts/verify-ui.mjs); prefer tokens over new CSS.
YAGNI
- Do not extract a shared hook/component without a third call site.
- Do not add parallel abstractions when an existing shell (
DataTable,FilterToolbar,FormModal,useResourceCRUD) covers the need.
Validation
- Run:
pnpm check(orvp check --no-fmt) - Run:
pnpm verify:ui(local/Agent gate; not CI in phase 1) - On failure: fix the same violation set at most twice, then stop and shrink scope
- For UI flow changes, run focused e2e where possible