feat(ui): 新增站点外壳组件 Brand / SearchField / Ticker
把应用里各自手写的三块收进库,风格沿用前台、行为参数化: - Brand:logo 图片或首字圆形标记 + 名称,href 决定是链接还是纯展示,size/tone 可选 - SearchField:语义版搜索框(onChange 直接给字符串),variant 切 plain / card, 支持 shortcut 提示与 hotkey 聚焦 - Ticker:无限滚动信息条,内部三份内容按实测宽度位移,循环不跳帧; speed / paused / label 可配 - 令牌补展示级字号 --su-font-size-2xl / --su-line-height-2xl(32 / 40) - 展示页新增 #site-chrome(Brand / Ticker / SearchField),COMPONENTS.md 补契约与 changelog
This commit is contained in:
@@ -30,6 +30,9 @@
|
||||
| `Tabs` | L2 | ✅ | 页内分区切换 | `items` `activeKey` `onChange` `variant` |
|
||||
| `Menu` | L2 | ✅ | 侧栏两级菜单(可折叠动画) | `items` `activeKey` `onSelect` `itemHeight` |
|
||||
| `Breadcrumb` | L3 | ✅ | 路径导航 | `items` `separator` |
|
||||
| `Brand` | L2 | ✅ | 品牌标识:logo / 首字标记 + 名称 | `name` `mark` `logo` `href` `size` `tone` |
|
||||
| `SearchField` | L2 | ✅ | 搜索框(语义版 Input,对外只给字符串) | `value` `onChange` `variant` `size` `hotkey` |
|
||||
| `Ticker` | L3 | ✅ | 无限滚动的信息条 | `children` `speed` `paused` `label` |
|
||||
| `Layout` | L3 | ✅ | 页面骨架:页头 / 侧栏 / 内容 / 页脚 | `header` `sider` `aside` `maxWidth` `gap` `height` |
|
||||
| `Card` | L3 | ✅ | 白色容器(1px 极浅描边) | `as` `padding` `hoverable` |
|
||||
| `Cover` | L3 | ✅ | 比例封面卡(2:3 / 4:3 / 16:9 + 标题遮罩) | `ratio` `src` `caption` `lift` `onClick` |
|
||||
@@ -601,6 +604,66 @@
|
||||
- **规则**:`onChange` 是原生事件(与 `Input` 一致),Enter 提交用 `onKeyDown`;切换按钮必须带 `aria-pressed` 与「显示/隐藏密码」名称,焦点环不得移除。
|
||||
- **展示页**:`#inputs`
|
||||
|
||||
### 3.43 Brand ✅
|
||||
|
||||
- **用途**:页头左侧的品牌标识——图片 logo 或首字圆形标记 + 品牌文字。
|
||||
- **不该用在哪**:头像(用 `Avatar`);纯文字标题(用 `Title`)。
|
||||
- **解剖**:`inline-flex` 容器;`logo` 有值时渲染 `<img>`,否则渲染首字标记;`href` 有值时整体是 `<a>`,否则是 `<span>`。
|
||||
- **Props**:
|
||||
|
||||
| prop | 类型 | 默认 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `name` | `string` | `''` | 品牌文字,可留空只显示标记 |
|
||||
| `mark` | `string` | `''` | 标记里的字,留空取 `name` 首字 |
|
||||
| `logo` | `string` | `''` | logo 图片地址;留空用 `mark` |
|
||||
| `href` | `string` | — | 传了渲染成链接 |
|
||||
| `size` | `'sm' \| 'md'` | `'md'` | 标记 24 / 32 |
|
||||
| `tone` | `'solid' \| 'soft'` | `'solid'` | 深底白字 / 主色浅底 |
|
||||
| `label` | `string` | — | 链接的无障碍名称 |
|
||||
|
||||
- **规则**:品牌名可空(只有标记也要能读出来,用 `label`);图片的 `alt` 留空,名称由文字节点承担。
|
||||
- **展示页**:`#site-chrome`
|
||||
|
||||
### 3.44 Ticker ✅
|
||||
|
||||
- **用途**:横向无限滚动的信息条(页头运行状态这类)。
|
||||
- **不该用在哪**:需要用户逐条阅读的长文本(用 `Text`);通知(用 `Notice` / `Toast`)。
|
||||
- **解剖**:容器 `overflow: hidden` + 两端 `mask` 渐隐;内部三份相同内容,按**第一份的实测宽度**做 `translateX`,所以循环处不跳帧;宽度变化由 `ResizeObserver` 重新测量。
|
||||
- **Props**:
|
||||
|
||||
| prop | 类型 | 默认 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `children` | `ReactNode` | 必填 | 一组内容,组件负责复制三份 |
|
||||
| `speed` | `number` | `24` | 一份内容滚完的秒数 |
|
||||
| `paused` | `boolean` | `false` | 暂停但保留进度 |
|
||||
| `label` | `string` | — | 读屏用的整体描述 |
|
||||
|
||||
- **规则**:只复制不改造 `children`;后两份带 `aria-hidden`,读屏只读一遍;`prefers-reduced-motion` 下不滚。
|
||||
- **展示页**:`#site-chrome`
|
||||
|
||||
### 3.45 SearchField ✅
|
||||
|
||||
- **用途**:搜索框——语义版 `Input`,对外只给字符串。
|
||||
- **不该用在哪**:普通表单输入(用 `Input`);需要自定义后缀的场景(用 `Input` + `suffix`)。
|
||||
- **解剖**:外层定宽容器 + `Input size="lg"`(搜索图标、清空按钮、快捷键提示);`variant="card"` 只换描边/圆角/阴影,不换结构。
|
||||
- **Props**:
|
||||
|
||||
| prop | 类型 | 默认 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `value` | `string` | 必填 | 受控值 |
|
||||
| `onChange` | `(value: string) => void` | 必填 | 直接给字符串 |
|
||||
| `placeholder` | `string` | `'搜索…'` | 占位文案,同时作为无障碍名称 |
|
||||
| `size` | `'md' \| 'lg'` | `'lg'` | 36 / 44 高 |
|
||||
| `variant` | `'plain' \| 'card'` | `'plain'` | 普通输入框 / 实底 + 柔和阴影 |
|
||||
| `maxWidth` | `number \| string` | `480` | 最大宽度 |
|
||||
| `shortcut` | `string` | — | 右侧快捷键提示(仅展示) |
|
||||
| `hotkey` | `string` | — | Ctrl/Cmd + 该键聚焦并全选(需同时传 `inputRef`) |
|
||||
| `clearOnEscape` | `boolean` | `true` | Esc 清空 |
|
||||
| `inputRef` | `Ref<HTMLInputElement>` | — | 透传内部输入框 |
|
||||
|
||||
- **规则**:`onChange` 给字符串而不是事件——这是它和 `Input` 唯一的语义差别,别在组件里做过滤/请求。
|
||||
- **展示页**:`#site-chrome`
|
||||
|
||||
---
|
||||
|
||||
## 4. 组合模式(不进库,但必须照这个拼)
|
||||
@@ -703,3 +766,4 @@
|
||||
| 2026-10-29 | 新增 `PasswordInput`(`icon` / `size` / `toggle`):锁图标 + 显隐切换 + `aria-pressed`,事件语义与 `Input` 一致。兼容性:纯新增 |
|
||||
| 2026-10-30 | **修复**:`PasswordInput` 的眼睛按钮移入输入框内部(`Input` 新增 `suffix` 插槽);`Input` 隐藏 Edge 原生 `::-ms-reveal` / `::-ms-clear`,避免与自带显隐按钮叠成两个眼睛。兼容性:`Input` 新增可选 prop,无破坏性;`PasswordInput` API 不变、仅外观变化 |
|
||||
| 2026-10-31 | `Layout` 新增 `toolbar` 插槽:页头与页身之间的一条真实占位带(搜索 / 筛选 / 操作),宽度跟随容器(`contained` 时与侧栏 + 内容同宽),在 `height="screen"` 下不参与内部滚动。用它替代「搜索框 fixed + `contentOffset` 让位」的写法,页面不再需要用 JS 改 DOM 尺寸。兼容性:纯新增可选 prop,`contentOffset` 行为不变 |
|
||||
| 2026-11-01 | 新增三个「站点外壳」组件,把应用里各自手写的一套收进库:`Brand`(logo / 首字标记 + 名称,`href` 可选)、`Ticker`(无限滚动信息条,按实测宽度位移,循环不跳帧)、`SearchField`(语义版搜索框,`variant` 切普通 / 悬浮条)。同时新增展示级令牌 `--su-font-size-2xl` / `--su-line-height-2xl`(32 / 40)。兼容性:纯新增,无破坏 |
|
||||
|
||||
Reference in New Issue
Block a user