# YCode 界面基础组件规范(2026-10-18) 本文件是第一轮组件统一的接口契约。后续子代理按此实现,不得各写一套。 ## 总则 - YCode 自有界面只消费 `--yc-*`;`--wb-*` 只允许出现在恢复模块的兼容层。 - 组件样式只能写 `var(--yc-*)`,组件内部不得写裸 hex、裸 `px`、`!important`。 - 组件不得带外部 margin;间距由调用方决定。 - 每个组件顶层元素必须接受并合并 `className`。 - 第一轮不引入第三方 UI 库,不引入 Tailwind,不引入 `clsx`。 - 组件用显式 variant/size props,禁止调用方拼 `wb-button--*` 类名。 ## 命名 ```text --yc--[-][-] ``` 示例: ```text --yc-button-primary-bg --yc-button-primary-bg-hover --yc-button-height-md --yc-input-height-md --yc-switch-track-width-lg ``` 组件 token 定义在 `src/renderer/src/styles/tokens.css` 或独立的 `src/renderer/src/ui/tokens.css`,二者只能有一处。页面作用域不得重定义。 ## 需要补的 L0 基础色 现有 `styles/tokens.css` 缺少原版控件的部分透明度阶。第一轮组件需要补齐: | token | 浅色 | 深色来源 | | --- | --- | --- | | `--yc-black-90` | `rgba(0, 0, 0, 0.9)` | `rgba(255, 255, 255, 0.9)` 由组件层重映射 | | `--yc-black-75` | `rgba(0, 0, 0, 0.75)` | `rgba(255, 255, 255, 0.75)` 由组件层重映射 | | `--yc-white-90` | `rgba(255, 255, 255, 0.9)` | 同 | | `--yc-white-75` | `rgba(255, 255, 255, 0.75)` | 同 | | `--yc-white-30` | `rgba(255, 255, 255, 0.3)` | 同 | | `--yc-white-20` | `rgba(255, 255, 255, 0.2)` | 同 | | `--yc-white-10` | `rgba(255, 255, 255, 0.1)` | 同 | 这些值来自当前 `--wb-palette-*` 实际使用值,不是新设计。 ## P1 组件 ### Button 接口: ```ts type ButtonVariant = 'primary' | 'secondary' | 'grey' | 'ghost' | 'link' | 'danger' type ButtonSize = 'sm' | 'md' | 'lg' interface ButtonProps extends React.ButtonHTMLAttributes { variant?: ButtonVariant size?: ButtonSize iconOnly?: boolean loading?: boolean iconLeft?: React.ReactNode iconRight?: React.ReactNode } ``` 当前对应的 `wb-button` 类名到 props 的映射: | 现类名 | 新写法 | | --- | --- | | `wb-button wb-button--primary wb-button--medium` | `