From 6509f2a4ff2c3048afd1c3151136faf7d83cfa6f Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 29 Jun 2026 16:51:45 +0800 Subject: [PATCH] docs: consolidate component conventions into CLAUDE.md and skill - Add "Dynamic add-item form fields" guidance to CLAUDE.md (pick component by field schema: LabelSelector / ListInput / MetadataList) - Fold StatusTag status-display recipe into create-crud-page skill - Remove DESIGN.md (content migrated to the above) --- .claude/skills/create-crud-page/SKILL.md | 45 ++++++++++++++++++++++- CLAUDE.md | 8 +++++ DESIGN.md | 46 ------------------------ 3 files changed, 52 insertions(+), 47 deletions(-) delete mode 100644 DESIGN.md diff --git a/.claude/skills/create-crud-page/SKILL.md b/.claude/skills/create-crud-page/SKILL.md index 89e973a1..aa6c429b 100644 --- a/.claude/skills/create-crud-page/SKILL.md +++ b/.claude/skills/create-crud-page/SKILL.md @@ -95,6 +95,49 @@ Main form component goes in `forms/index.tsx`. ## Common UI conventions - **Drawer/Modal open/close**: use `useBodyScroll` from `@gpustack/core-ui`. Ref: `src/pages/model-routes/hooks/use-create-route.ts`. -- **Status display** (success/failed/processing/warning): use `StatusTag`. Ref: `src/pages/llmodels/components/table-list.tsx`. +- **Status display** (success/failed/processing/warning): use `StatusTag`, never `Tag` from `antd` directly. See **Status display** below. Ref: `src/pages/llmodels/components/table-list.tsx`. - **Permission-gated visibility**: use `Access` / `useAccess`. Ref: `src/pages/access/index.tsx`. - **Styles**: avoid `styled-components` for complex/large styling. Prefer `createStyles` for component-scoped dynamic styles, CSS Modules (`xxx.module.less`) for static structured styles. + +## Status display + +Use `StatusTag` from `@gpustack/core-ui` for status display. Do not use `Tag` from `antd` directly. + +1. Define the mapping from business status values to UI status values in the module's `config/index.ts`: + +```ts +import { StatusMaps } from '@/config'; +import { StatusType } from '@/config/types'; + +export const XxxStatusValueMap = { + Running: 'running', + Pending: 'pending', + Failed: 'failed' +}; + +export const XxxStatusLabelMap: Record = { + [XxxStatusValueMap.Running]: 'Running', + [XxxStatusValueMap.Pending]: 'Pending', + [XxxStatusValueMap.Failed]: 'Failed' +}; + +export const status: Record = { + [XxxStatusValueMap.Running]: StatusMaps.success, + [XxxStatusValueMap.Pending]: StatusMaps.transitioning, + [XxxStatusValueMap.Failed]: StatusMaps.error +}; +``` + +2. In table columns, pass only the UI status value and display text required by `StatusTag`: + +```tsx + +``` + +`statusValue.status` must be a value mapped from `StatusMaps` (`success`, `transitioning`, `warning`, `error`, `inactive`). Do not pass business status values such as `running` or `pending` directly. diff --git a/CLAUDE.md b/CLAUDE.md index ac3df51c..bab63fcf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -93,3 +93,11 @@ Avoid `styled-components` for complex or large-scale styling. Prefer: - **Permission-gated visibility**: `Access` / `useAccess`. - **Request hooks**: `useRequest` / `useQueryData` / `useQueryDataList` from `@gpustack/core-ui`. - **Table data fetching**: `useTableFetch` from `@gpustack/core-ui`. + +# Dynamic add-item form fields + +When building a form, select the add-item component from the **shape of the field's data** (its schema). Match the schema, don't hand-roll a list UI: + +- **Plain object** (key→value map) → `LabelSelector`. +- **String array** → `ListInput`. Ref `src/pages/llmodels/forms/backend-parameters-list.tsx`. +- **Object array** → `MetadataList` with a custom item renderer per entry. Ref `src/pages/llmodels/forms/model-lora-list.tsx`. diff --git a/DESIGN.md b/DESIGN.md deleted file mode 100644 index 806376d9..00000000 --- a/DESIGN.md +++ /dev/null @@ -1,46 +0,0 @@ -## Create form table list - -## Create a form - -## StatusTag - -Use `StatusTag` from `@gpustack/core-ui` for status display. Do not use `Tag` from `antd` directly. - -1. Define the mapping from business status values to UI status values in the module's `config/index.ts`: - -```ts -import { StatusMaps } from '@/config'; -import { StatusType } from '@/config/types'; - -export const XxxStatusValueMap = { - Running: 'running', - Pending: 'pending', - Failed: 'failed' -}; - -export const XxxStatusLabelMap: Record = { - [XxxStatusValueMap.Running]: 'Running', - [XxxStatusValueMap.Pending]: 'Pending', - [XxxStatusValueMap.Failed]: 'Failed' -}; - -export const status: Record = { - [XxxStatusValueMap.Running]: StatusMaps.success, - [XxxStatusValueMap.Pending]: StatusMaps.transitioning, - [XxxStatusValueMap.Failed]: StatusMaps.error -}; -``` - -2. In table columns, pass only the UI status value and display text required by `StatusTag`: - -```tsx - -``` - -`statusValue.status` must be a value mapped from `StatusMaps`, such as `success`, `transitioning`, `warning`, `error`, or `inactive`. Do not pass business status values such as `running` or `pending` directly.