用途:这是 Prowler 项目 UI 子目录(ui/)的专属开发规范,指导在该目录内编写符合 Prowler 约定的前端代码。通用模式另见 typescript、react-19、nextjs-16、tailwind-4 等技能。
技术栈:Next.js 16.2.3、React 19.2.5、Tailwind 4.1.18、shadcn/ui、Zod 4.1.11、React Hook Form 7.62.0、Zustand 5.0.8、NextAuth 5.0.0-beta.30、Recharts 2.15.4。
主要能力与规则:组件库必须使用 shadcn/ui + Tailwind(components/shadcn/),禁止向 components/ui/ 添加组件(该目录仅为 prowler-cloud overlay 的临时再导出垫片,HeroUI 已移除)。设计系统要求复用优先,通过 variant/size/tone 属性控制外观,禁止在共享控件上添加临时视觉 className,禁止使用原始 Tailwind 颜色工具类或十六进制色值,颜色须复用 ui/styles/globals.css 中的语义 token。模态框仅用 @/components/shadcn/modal,选择器用 components/shadcn/select。
目录与代码位置:新 UI 原语放 components/shadcn/,单域组件放 components/{domain}/,跨域放 components/shared/;server action 放 actions/{feature}/,数据转换放 .adapter.ts,共享类型放 types/,共享工具放 lib/,共享 hooks 放 hooks/。Recharts 不支持 className 的属性使用 CHART_COLORS 常量与 var()。表单采用 react-hook-form + zodResolver + Zod 4 语法。批量与即时组件 API 须用可辨识联合建模,避免无效半状态。派生状态直接从源头计算,避免 useState + useEffect 镜像 props。标签映射使用严格键类型而非 Record<string, string>。
使用方式:cd ui && pnpm install;pnpm run dev;质量检查 pnpm run typecheck、lint:fix、format:write、healthcheck;测试 pnpm run test:e2e(含 :ui、:debug);构建 pnpm run build、pnpm start。
限制:仅适用于 Prowler 的 ui/ 目录;新增变体或 token 属于设计系统变更,需设计方确认后加入共享组件 API,不得在调用点自行决定。提交前需通过类型检查、lint、格式化与相关 E2E,并处理加载、错误、空状态、无障碍与移动端适配。