diff --git a/code/g3soft-libs/.codebuddy/plans/g3-ui-重写-参照fms-vue_084cfb52.md b/code/g3soft-libs/.codebuddy/plans/g3-ui-重写-参照fms-vue_084cfb52.md new file mode 100644 index 00000000..3021c70f --- /dev/null +++ b/code/g3soft-libs/.codebuddy/plans/g3-ui-重写-参照fms-vue_084cfb52.md @@ -0,0 +1,334 @@ +--- +name: g3-ui-重写-参照fms-vue +overview: 以 fms-vue 的 `src/components/ui` 为原型,全量重写 `packages/ui`(@g3soft/ui)组件库:25 个组件按「基础→表单→浮层→反馈→数据展示」分批实现,全部 TypeScript 化并遵守 g3 约定(非 scoped SCSS + `g3-` BEM + `--g3-*` 令牌 + types.ts + gen:api + 文档示例)。确认语义统一从 fms 的 `ok/onOk/okText` 改为 `confirm/onConfirm/confirmText`。 +design: + styleKeywords: + - 中性克制 + - shadcn 风格主色派生 + - 层次靠面不靠线 + - 轻描边 + - 微动效反馈 + - 三层 z 轴秩序 + fontSystem: + fontFamily: PingFang SC + heading: + size: 24px + weight: 600 + subheading: + size: 16px + weight: 500 + body: + size: 14px + weight: 400 + colorSystem: + primary: + - "#18181B" + - "#E5E5E5" + background: + - "#FFFFFF" + - "#141414" + text: + - "#000000" + - "#FFFFFF" + functional: + - "#45B114" + - "#E79A0D" + - "#EC4246" +todos: + - id: infra-setup + content: 扩展 tokens 8 个变量、TS 化 _utils、改造 z-index 分层、加 @lucide/vue 依赖与 external + status: completed + - id: genapi-and-config + content: 改造 gen-api 只解析目录主组件,扩充 locale 并实现 useComponentDefaults + status: completed + dependencies: + - infra-setup + - id: base-components + content: 用 [skill:ui-ux-pro-max] 重写 Button 变体体系,实现 button-group/space/grid/tag/segmented/scrollbar/spin + status: completed + dependencies: + - genapi-and-config + - id: overlay-popover + content: 用 [subagent:code-explorer] 移植浮层工具,实现 useFloating 与 popover/tooltip/dropdown + status: completed + dependencies: + - base-components + - id: form-components + content: 移植 input/checkbox/radio/switch/select 与 form 校验体系 + status: completed + dependencies: + - overlay-popover + - id: modal-drawer-feedback + content: 参照 [skill:antdv-next] 实现 modal(confirm 语义+命令式)、drawer、message/notification + status: completed + dependencies: + - overlay-popover + - id: data-display + content: 实现 tree/tabs/pagination/splitter 与 date-picker/range-picker/time-select + status: completed + dependencies: + - overlay-popover + - id: docs-and-verify + content: 补齐示例与文档页,跑 gen:api、tokens/ui 全量构建冒烟 + status: completed + dependencies: + - base-components + - form-components + - modal-drawer-feedback + - data-display +--- + +## 产品概述 + +将 `packages/ui`(@g3soft/ui)从一个只有 Button + ConfigProvider 的雏形,重写为一套完整的 Vue 3 组件库。实现原型来自 `D:\workspace\code\fms\fms-vue\src\components\ui` 的 25 个组件目录,但必须全部落在 g3soft 自身的技术约定上:TypeScript、非 scoped SCSS + `g3-` BEM、 `--g3-*` 设计令牌、`types.ts` + `gen:api` 生成文档、docs 示例与 md 页面。 + +## 核心范围 + +- 全量迁移 fms-vue 的组件能力,按「基础 → 浮层 → 表单 → 覆盖层与反馈 → 数据展示」分批落地,每批可独立构建验证。 +- 共规划 28 个组件目录:button、button-group、space、grid、scrollbar、spin、tag、segmented、input、checkbox、radio(+radio-group)、switch、select、form(+form-item/form-group)、date-picker、range-picker、time-select、popover、tooltip、dropdown、modal、drawer、message、notification、tree、tabs、pagination、splitter。 + +## 确认语义(本次重写的关键变更) + +fms 的 `ok` 风格一律改为 `confirm` 风格: + +- `okText` → `confirmText`、`okButtonProps` → `confirmButtonProps`、`onOk` → `onConfirm` +- 事件 `ok` → `confirm`(`update:open` / `cancel` / `closed` 保持不变) +- 命令式仍为 `G3Modal.confirm({ ..., onConfirm })`,返回 `{ destroy }` +- `confirmLoading` 语义不变予以保留;「只有点取消按钮才触发 `onCancel`,点遮罩/Esc/右上角 X 为静默关闭」的行为保留 + +## 其他已确认决策 + +- Button 改用 fms 变体体系:`primary | secondary | outline | ghost | danger | danger-outline | link | icon`(破坏性变更,现有 `docs/examples/button/*` 与 `button.md` 一并重写)。 +- 图标新增 `@lucide/vue` 运行时依赖,照搬 fms 用法。 +- 扩展 `@g3soft/tokens`,但只补跨组件共享的少量语义变量,组件私有尺寸一律用 `v()` 兜底不进令牌;**z-index 不进令牌**,继续走 `packages/ui/src/_utils/z-index.ts`,并改造为分层分配。 + +## 技术栈 + +- 组件库:Vue 3.5(` - - - - diff --git a/code/g3soft-libs/docs/content/framework/.navigation.yml b/code/g3soft-libs/docs/content/framework/.navigation.yml new file mode 100644 index 00000000..30a9bf80 --- /dev/null +++ b/code/g3soft-libs/docs/content/framework/.navigation.yml @@ -0,0 +1,2 @@ +title: 框架 +icon: i-lucide-layout-dashboard diff --git a/code/g3soft-libs/docs/content/framework/1.layout/.navigation.yml b/code/g3soft-libs/docs/content/framework/1.layout/.navigation.yml new file mode 100644 index 00000000..7cc790da --- /dev/null +++ b/code/g3soft-libs/docs/content/framework/1.layout/.navigation.yml @@ -0,0 +1,2 @@ +title: 布局 +icon: i-lucide-panel-left diff --git a/code/g3soft-libs/docs/content/framework/1.layout/index.md b/code/g3soft-libs/docs/content/framework/1.layout/index.md new file mode 100644 index 00000000..9615df10 --- /dev/null +++ b/code/g3soft-libs/docs/content/framework/1.layout/index.md @@ -0,0 +1,21 @@ +--- +title: Layout 布局框架 +description: G3 框架的布局骨架,支持 7 种布局模式,菜单/页签数据由宿主注入 +--- + +# Layout 布局框架 + +`G3Layout` 是 `@g3soft/framework` 的布局骨架。它只负责「怎么摆」,不关心菜单从哪来 —— 菜单、用户、页签都由宿主通过 props / 插槽注入。 + +点击下方按钮切换 7 种布局模式: + +:::demo{name="layout/basic"} +::: + +## 说明 + +- **7 种模式**:`sidebar-nav`(垂直,默认)/ `header-nav`(顶部)/ `sidebar-mixed-nav`(双列)/ `mixed-nav` / `header-sidebar-nav` / `header-mixed-nav` / `full-content`。 +- **一个组件 + 模式表驱动**:内部按 `layout` prop 条件渲染,不拆成 7 个组件。 +- **菜单数据注入**:`:menus` 直接给数组,或 `:menu-source` 给函数(framework 接管加载态)。 +- **插槽宁可多不要少**:`logo` / `header-left` / `header-right` / `sidebar-top` / `sidebar-footer` / `tabbar-extra` / `breadcrumb-extra` / `page` / `default`。 +- **主题**:偏好里的主色 / 暗色最终经 `@g3soft/ui` 的 `ConfigProvider` 派生,不另起一套变量系统。 diff --git a/code/g3soft-libs/docs/content/index.md b/code/g3soft-libs/docs/content/index.md index 82bd2435..fc70d4fb 100644 --- a/code/g3soft-libs/docs/content/index.md +++ b/code/g3soft-libs/docs/content/index.md @@ -36,7 +36,7 @@ to: /ui/general/button :::u-page-section #title -四个内容域 +内容板块 #features :::u-page-feature @@ -60,30 +60,42 @@ to: /ui/general/button 参考 #description -组件库 API 自动生成,另有 Hooks 与后端接口文档。 +每个组件的手写 API 与可运行示例,含 props / events / slots 与类型定义。 +::: + +:::u-page-feature +--- +icon: i-lucide-layout-dashboard +to: /framework/layout +--- +#title +框架 + +#description +应用框架:布局骨架(7 种模式)、偏好设置与主题,供业务项目引用。 ::: :::u-page-feature --- icon: i-lucide-ruler -to: /standard/code-style +to: /ui/usage/getting-started --- #title -规范 +使用规范 #description -代码风格、命名约定、Git 与发布流程等团队工程规范。 +安装与引入方式、换肤与暗色主题、全局默认值配置。 ::: :::u-page-feature --- icon: i-lucide-lightbulb -to: /explain/why-tokens +to: /ui/overlay/modal --- #title -解释 +浮层与反馈 #description -设计决策背后的取舍与常见问题解答。 +对话框、抽屉、下拉与提示:层级管理与确认语义的统一约定。 ::: ::: diff --git a/code/g3soft-libs/docs/content/ui/1.usage/getting-started.md b/code/g3soft-libs/docs/content/ui/1.usage/getting-started.md index d3819358..58aed3cf 100644 --- a/code/g3soft-libs/docs/content/ui/1.usage/getting-started.md +++ b/code/g3soft-libs/docs/content/ui/1.usage/getting-started.md @@ -67,4 +67,5 @@ document.documentElement.dataset.g3Theme = 'dark' ## 下一步 - 浏览[组件参考](/ui/general/button) -- 了解[设计变量](/explain/why-tokens)的设计取舍 +- 了解[全局默认值(componentDefaults)](/ui/general/button#全局默认值)的用法 +- 需要弹窗时先看[对话框与确认语义](/ui/overlay/modal) diff --git a/code/g3soft-libs/docs/content/ui/2.general/button-group.md b/code/g3soft-libs/docs/content/ui/2.general/button-group.md new file mode 100644 index 00000000..9a245ba8 --- /dev/null +++ b/code/g3soft-libs/docs/content/ui/2.general/button-group.md @@ -0,0 +1,64 @@ +--- +title: ButtonGroup 按钮组 +description: 把多个按钮贴合排列成一组,适用于工具条与互斥动作 +--- + +# ButtonGroup 按钮组 + +按钮组把多个 `G3Button` 贴合排列:组内按钮去掉相邻圆角、边框重叠 1px,视觉上成为一整块。它只负责**布局**,每个按钮的 `type` / `size` / `disabled` 仍由自己决定。 + +## 何时使用 + +- 多个同层级操作成排出现(工具栏、卡片操作区)时,用按钮组把它们的关联关系表达出来; +- 一组图标动作(左对齐 / 居中 / 右对齐)时使用,避免按钮之间出现缝隙; +- 只是想给按钮之间加间距,请用 [Space 间距](/ui/general/space),不要用按钮组。 + +## 基础用法 + +默认水平排列,组内按钮共用一套圆角与边框。 + +:::demo{name="button-group/basic"} +::: + +## 纵向排列 + +`orientation="vertical"` 时纵向贴合,组内按钮宽度一致,常作为侧边操作组。 + +:::demo{name="button-group/vertical"} +::: + +## 组合不同变体与尺寸 + +组内按钮各自保留 `type` / `size`;混排时建议统一变体,否则视觉层次会混乱。 + +:::demo{name="button-group/variant"} +::: + +## API + +### Props(ButtonGroup) + +| 名称 | 类型 | 默认值 | 说明 | +| --- | --- | --- | --- | +| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | 排列方向。`vertical` 时纵向贴合、按钮等宽 | + +### Slots + +| 名称 | 参数 | 说明 | +| --- | --- | --- | +| `default` | — | 组内的 `G3Button`。非按钮元素不会被索引到圆角规则里,请勿放置 | + +### 类型定义 + +```ts +export interface ButtonGroupProps { + orientation?: 'horizontal' | 'vertical' +} +``` + +## 实现说明 + +- 组内按钮通过 `margin-left: -1px` 让相邻边框重叠,避免出现 2px 的双线; +- 首尾按钮单独恢复圆角,因此**中间的按钮不要插非按钮元素**(会被 CSS 的 `:first-child` / `:last-child` 规则错位); +- 分组用 `role="group"` 标注,屏幕阅读器会把它们视为一组操作; +- 按钮聚焦时会 `z-index: 1` 浮到上层,避免焦点环被相邻按钮挡住。 diff --git a/code/g3soft-libs/docs/content/ui/2.general/button.md b/code/g3soft-libs/docs/content/ui/2.general/button.md index 5bb5dcc8..9f0b1189 100644 --- a/code/g3soft-libs/docs/content/ui/2.general/button.md +++ b/code/g3soft-libs/docs/content/ui/2.general/button.md @@ -1,42 +1,191 @@ --- title: Button 按钮 -description: 常用的操作按钮,支持多种视觉类型与状态 +description: 触发一个操作,支持 8 种视觉变体、3 档尺寸与加载态 --- # Button 按钮 -常用的操作按钮,支持 7 种视觉类型、3 种尺寸与加载、禁用等状态。 +按钮用于触发一个即时操作。它承载「点击后发生什么」,因此同一区域里应当只有一个视觉上最重的按钮,其余操作降级表达。 + +## 何时使用 + +- 用户点击后即时触发一个动作(提交、保存、删除、导出)时使用; +- 表单、对话框、工具条的最终动作使用 `primary`(或危险动作使用 `danger`); +- 面板头部、表格行内的图标类动作使用 `type="icon"`; +- 只是页面跳转且不需要按钮外观时,直接用 ``,或使用 `type="link"` 保持按钮语义。 ## 基础用法 -::demo{name="button/basic"} -:: +不传 `type` 时使用 `primary`;按钮内容写在默认插槽里。 -## 视觉类型 +:::demo{name="button/basic"} +::: -语义化类型用于表达操作的风险等级。 +按钮是原生 `