控件行为层选型落地:Radix primitives(headless)+ 自有皮肤,原生控件清零,字段标题同时被对齐。
用户问「要不要换一套标准控件组」。答:要,但只买行为不买皮肤——antd/MUI/Arco 自带 token(控件高 32px) 与我们的 --ctl-h-main(38px)并存就是两套尺子,再加一份 preflight 跟 Tailwind v4 base 层抢深浅主题, 而深色 studio 视觉本来就得覆盖八成,省下的工时会全数还回去。选定 Radix primitives + CVA 皮肤 (即 shadcn 架构,源码 vendored 在 components/primitives/),Radix 管 portal/定位/翻边/视口避让/焦点圈定与归还/ 键盘/Esc 分层/锁滚动,尺寸配色仍只来自 tokens.css。 症状一:字段标题与控件不对齐,/review 同一列里控件左缘出现 1353/1425/1472 三种,最大右移 47.3px。 根因不是排版:Field 同时带 [&>*]:min-w-0(让长控件能收缩)与 min-w-(--label-w)(撑住标签列), 两条特指度都是 0-1-0,Tailwind 把 min-w-0 排在自定义值之后 → 66px 下限被无声清零,控件左缘跟着中文标签字数漂。 改法:下限换到压得住的选择器 [&>span:first-child]:min-w-(--label-w)(0-2-0),hint 栅格的标签列 从 auto 换成 minmax(var(--label-w),max-content);尺子补 --field-label-w:66px(全站 193 个行内标签的 p90) 与 --label-w 作用域开关(FormRow 抬起、Ctlbar/ChipBar/CardActions/Pager 压回 0,工具条不参与表单对齐; ≤560px 一行一个字段没有对齐对象,直接归 0)。 症状二:勾选框是 macOS 系统绿圆角块、滑杆是系统 range、分页还有个裸 select,深浅两版主题各长一个样; 「按一次 Esc,下拉连背后的抽屉一起没了」。改法:checkbox/range/menu/dialog 全部接进 primitives (Checkbox 尺寸收成 --check-size 14px、触摸档 18px),每层浮层带 data-nex-layer, 页面级快捷键第一行 if (floatingLayerOpen()) return,层级只用一套(遮罩 100/抽屉 101/模态 111/下拉 400); 手写的 use-outside-click 删掉,外点关闭交给 Radix。依赖清单同步等于实际 import:卸载 8 个装了没在用的 @radix-ui/*(tabs/tooltip/label/separator/progress/radio-group/switch/visually-hidden), 顺带删掉这条死链上唯一消费它们的 ui/Toggle.tsx(0 个用户),现在 5 个 radix 包全部有 import。 实测:nex_align4.py 全站 30 个表单字段,五项判据(同列控件左缘不一致 / 标签压控件 / 控件溢出字段盒 / 行内标签与控件中心不齐 / 同列 stack-inline 混用)全 0 组、0 console error;nex_ctl4.py 31 项控件行为回归 31/31(抽屉+下拉叠加、Esc 只关一层、锁滚动不横跳、点文字切勾选、滑杆键盘可调、菜单方向键与焦点归还、 真实鼠标开关抽屉滚动全程守恒 101→101→101);源码里裸 select/checkbox/range 残留 0(grep 仅剩 3 条注释); tsc --noEmit 与 npm run build 均 EXIT=0。main
parent
e70c508044
commit
670f4973e5
|
|
@ -10,7 +10,9 @@
|
|||
"dependencies": {
|
||||
"@radix-ui/react-checkbox": "^1.4.1",
|
||||
"@radix-ui/react-dialog": "^1.3.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.2.1",
|
||||
"@radix-ui/react-popover": "^1.3.1",
|
||||
"@radix-ui/react-slider": "^1.6.1",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
|
|
@ -402,6 +404,12 @@
|
|||
"url": "https://github.com/sponsors/oxc-project"
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/number": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/number/-/number-1.1.3.tgz",
|
||||
"integrity": "sha512-Road2bidD0uu/1BGDOWNdPI06g0lIRy6IF9GZcIrDK2KGItfor8IQwQa+yM2ERgHM1MmHxaxpTzk0/Jp42lNfA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@radix-ui/primitive": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.2.0.tgz",
|
||||
|
|
@ -460,6 +468,33 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-collection": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-collection/-/react-collection-1.2.0.tgz",
|
||||
"integrity": "sha512-+yiQzqcc7Sy7/5s0jrMCjpPRFB3538VNrXPWdTLZhE/SCfgEws4aI6lHWN/vvcnyhHndROWBzqmqB4QBrITZ9Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/react-compose-refs": "1.1.5",
|
||||
"@radix-ui/react-context": "1.3.0",
|
||||
"@radix-ui/react-primitive": "2.2.0",
|
||||
"@radix-ui/react-slot": "1.5.0",
|
||||
"@radix-ui/react-use-layout-effect": "1.1.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-compose-refs": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.5.tgz",
|
||||
|
|
@ -527,6 +562,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-direction": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-direction/-/react-direction-1.2.0.tgz",
|
||||
"integrity": "sha512-FtRA52a/r+LKStFT+neLUm+8vSe7wbzkbQGGeU8ixFiwC8NU14Evoq9ATECqL3eGbcUzJR4fyfA4KkK/q6dfqg==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-dismissable-layer": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.2.1.tgz",
|
||||
|
|
@ -554,6 +604,35 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-dropdown-menu": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-2.2.1.tgz",
|
||||
"integrity": "sha512-XsHcmYG2AcqnvTqrOXXWcMrhquEIlqucizuDH1MV/qMRW+DndpBCMvNeTRXOxqmG1H5j89M/+I0/34Zdd+zDcQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.2.0",
|
||||
"@radix-ui/react-compose-refs": "1.1.5",
|
||||
"@radix-ui/react-context": "1.3.0",
|
||||
"@radix-ui/react-id": "1.1.4",
|
||||
"@radix-ui/react-menu": "2.2.1",
|
||||
"@radix-ui/react-primitive": "2.2.0",
|
||||
"@radix-ui/react-use-controllable-state": "1.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-focus-guards": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-focus-guards/-/react-focus-guards-1.2.0.tgz",
|
||||
|
|
@ -612,6 +691,46 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-menu": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-menu/-/react-menu-2.2.1.tgz",
|
||||
"integrity": "sha512-G34BsU90SBj5foYpz8pQqq/Q0Dlfyyl6KitWEfRwXC0QvfwhWNAwS49DWP2+rRJ0iwv20Z2Qx7Sk+T03bGo5JA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.2.0",
|
||||
"@radix-ui/react-collection": "1.2.0",
|
||||
"@radix-ui/react-compose-refs": "1.1.5",
|
||||
"@radix-ui/react-context": "1.3.0",
|
||||
"@radix-ui/react-direction": "1.2.0",
|
||||
"@radix-ui/react-dismissable-layer": "1.2.1",
|
||||
"@radix-ui/react-focus-guards": "1.2.0",
|
||||
"@radix-ui/react-focus-scope": "1.3.1",
|
||||
"@radix-ui/react-id": "1.1.4",
|
||||
"@radix-ui/react-popper": "1.4.0",
|
||||
"@radix-ui/react-portal": "1.2.0",
|
||||
"@radix-ui/react-presence": "1.1.11",
|
||||
"@radix-ui/react-primitive": "2.2.0",
|
||||
"@radix-ui/react-roving-focus": "1.2.1",
|
||||
"@radix-ui/react-slot": "1.5.0",
|
||||
"@radix-ui/react-use-callback-ref": "1.1.5",
|
||||
"aria-hidden": "^1.2.4",
|
||||
"react-remove-scroll": "^2.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-popover": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-popover/-/react-popover-1.3.1.tgz",
|
||||
|
|
@ -752,6 +871,71 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-roving-focus": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-roving-focus/-/react-roving-focus-1.2.1.tgz",
|
||||
"integrity": "sha512-UwraORzVUeEPMclhO1p0vz0qI+TbdDLO9i+FiOqhJyHKwdpCRCck9yVEscUnAMIzCiuNoQa8D4A9bIpOPXGt6Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.2.0",
|
||||
"@radix-ui/react-collection": "1.2.0",
|
||||
"@radix-ui/react-compose-refs": "1.1.5",
|
||||
"@radix-ui/react-context": "1.3.0",
|
||||
"@radix-ui/react-direction": "1.2.0",
|
||||
"@radix-ui/react-id": "1.1.4",
|
||||
"@radix-ui/react-primitive": "2.2.0",
|
||||
"@radix-ui/react-use-callback-ref": "1.1.5",
|
||||
"@radix-ui/react-use-controllable-state": "1.3.0",
|
||||
"@radix-ui/react-use-is-hydrated": "0.1.3",
|
||||
"@radix-ui/react-use-layout-effect": "1.1.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-slider": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-slider/-/react-slider-1.6.1.tgz",
|
||||
"integrity": "sha512-IRNRR90moPqxfwCJ0XbMJIxo70W0/1ZExT/sNCxEHMaPx0SF9HoQrcPEC75+H28cFKa0b+KH63anfLYJmwKacw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/number": "1.1.3",
|
||||
"@radix-ui/primitive": "1.2.0",
|
||||
"@radix-ui/react-collection": "1.2.0",
|
||||
"@radix-ui/react-compose-refs": "1.1.5",
|
||||
"@radix-ui/react-context": "1.3.0",
|
||||
"@radix-ui/react-direction": "1.2.0",
|
||||
"@radix-ui/react-primitive": "2.2.0",
|
||||
"@radix-ui/react-use-controllable-state": "1.3.0",
|
||||
"@radix-ui/react-use-layout-effect": "1.1.4",
|
||||
"@radix-ui/react-use-size": "1.1.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-slot": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.5.0.tgz",
|
||||
|
|
@ -826,6 +1010,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-use-is-hydrated": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-use-is-hydrated/-/react-use-is-hydrated-0.1.3.tgz",
|
||||
"integrity": "sha512-umO/aJ+82CpOnhDZUTbILCQf7kU/g0iv+oGs/Q8jw7IkhWBzaEP4sA268PhFAJTFetbwp3ICc6ktpI4TqtxcIw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-use-layout-effect": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.1.4.tgz",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
"dependencies": {
|
||||
"@radix-ui/react-checkbox": "^1.4.1",
|
||||
"@radix-ui/react-dialog": "^1.3.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.2.1",
|
||||
"@radix-ui/react-popover": "^1.3.1",
|
||||
"@radix-ui/react-slider": "^1.6.1",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
|
|
|
|||
|
|
@ -3,18 +3,20 @@
|
|||
*
|
||||
* 环境自检不再常驻一列文字,只在真的有问题时到菜单里冒出来一次。
|
||||
* 换页后菜单里的高亮项、角色都可能变,直接收起最省事。
|
||||
*
|
||||
* 菜单行为在 primitives/Menu(Radix DropdownMenu):焦点圈定、方向键/首字母走选项、
|
||||
* Esc 关闭并把焦点还给胶囊、点外面关闭——以前是 div + useOutsideClick 手写的,
|
||||
* 那份实现 Tab 会跑到菜单背后,且每个使用点都得自己记得挂 hook。
|
||||
* 面板还 portal 到 body,不再被顶栏的层叠上下文和 z-index 排挤。
|
||||
*/
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link, NavLink, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { cn } from '../../lib/cn'
|
||||
import {
|
||||
logout, roleLabel, useAuthStore, useCanEdit, useDisplayName, useIsAdmin
|
||||
} from '../../stores/auth'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { useOutsideClick } from '../../hooks'
|
||||
|
||||
const ITEM = 'flex min-h-[32px] w-full items-center gap-[9px] rounded-[8px] border border-transparent bg-transparent px-[9px] py-[7px] text-left text-body text-ink-2 no-underline hover:border-line hover:bg-hover hover:text-ink'
|
||||
const ICON = 'w-[15px] flex-none text-center text-body text-muted'
|
||||
import { MENU_ICON, MenuItem, MenuNote, MenuRoot, MenuSeparator, MenuTrigger, MenuContent } from '../../components/primitives/Menu'
|
||||
|
||||
/** 环境自检结论:有问题才说,没问题时菜单里不占位置 */
|
||||
function envIssueOf(health: any): string {
|
||||
|
|
@ -34,10 +36,8 @@ export function UserMenu() {
|
|||
const canEdit = useCanEdit()
|
||||
const health = useSystemStore((s) => s.health)
|
||||
const [open, setOpen] = useState(false)
|
||||
const hostRef = useRef<HTMLDivElement | null>(null)
|
||||
const close = useCallback(() => setOpen(false), [])
|
||||
|
||||
useOutsideClick(hostRef, close, open)
|
||||
/* 换页后菜单里的高亮项、角色都可能变,直接收起最省事 */
|
||||
useEffect(close, [location.pathname, close])
|
||||
|
||||
|
|
@ -53,70 +53,76 @@ export function UserMenu() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div ref={hostRef} className="relative flex-none">
|
||||
<button type="button" onClick={() => setOpen(!open)} aria-expanded={open} aria-haspopup="menu"
|
||||
title={'账号菜单 · ' + displayName}
|
||||
className={cn('relative flex h-(--nex-ctl) items-center gap-2 rounded-pill border bg-sunken pl-1 pr-2 text-left text-ink-2 hover:border-line-bright hover:bg-hover hover:text-ink',
|
||||
mustChangePassword ? 'border-warn-line' : 'border-line', open && 'border-line-bright bg-hover text-ink')}>
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid max-w-[132px] min-w-0 leading-[1.25] max-narrow:hidden [&_b]:truncate [&_small]:truncate">
|
||||
<b className="text-label">{displayName}</b>
|
||||
<small className="text-tiny text-faint">{roleLabel(user.role)}{user.login_count ? ` · 第 ${user.login_count} 次登录` : ''}</small>
|
||||
</span>
|
||||
<span aria-hidden="true" className="flex-none text-caption text-faint transition-transform duration-[180ms]" style={{ transform: open ? 'rotate(180deg)' : undefined }}>⌄</span>
|
||||
{/* 待改密码的提醒不能只藏在菜单里:胶囊上先挂一个角标。
|
||||
角标挂在胶囊而不是头像上——头像是 27px 的正圆,绝对定位的角标会把
|
||||
它自己的 scrollWidth 撑到 30px(内容没被裁,但等于凭空多出横向溢出)。 */}
|
||||
{mustChangePassword && (
|
||||
<span aria-hidden="true" className="absolute -right-0.5 -top-[3px] grid h-[14px] w-[14px] place-items-center rounded-pill bg-warn-fill text-tiny font-bold text-warn-ink">!</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<div role="menu" className="absolute right-0 top-[calc(100%+8px)] z-70 grid w-[262px] gap-0.5 rounded-block border border-line-strong bg-panel p-[9px] shadow-[0_18px_44px_rgba(0,0,0,.44)]">
|
||||
<div className="flex items-center gap-[9px] border-b border-line-soft px-1 pb-[9px] pt-[3px]">
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid min-w-0 gap-0.5">
|
||||
<b className="truncate text-[12.5px]">{displayName}</b>
|
||||
<small className="truncate text-tiny text-faint">{user.username}{user.email ? ` · ${user.email}` : ''}</small>
|
||||
</span>
|
||||
<em className="ml-auto flex-none rounded-pill bg-hover px-[6px] py-0.5 text-tiny not-italic text-ink-2">{roleLabel(user.role)}</em>
|
||||
</div>
|
||||
|
||||
<MenuRoot open={open} onOpenChange={setOpen}>
|
||||
<MenuTrigger asChild title={'账号菜单 · ' + displayName}>
|
||||
<button type="button"
|
||||
className={cn('relative flex h-(--nex-ctl) items-center gap-2 rounded-pill border bg-sunken pl-1 pr-2 text-left text-ink-2 hover:border-line-bright hover:bg-hover hover:text-ink',
|
||||
mustChangePassword ? 'border-warn-line' : 'border-line', open && 'border-line-bright bg-hover text-ink')}>
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid max-w-[132px] min-w-0 leading-[1.25] max-narrow:hidden [&_b]:truncate [&_small]:truncate">
|
||||
<b className="text-label">{displayName}</b>
|
||||
<small className="text-tiny text-faint">{roleLabel(user.role)}{user.login_count ? ` · 第 ${user.login_count} 次登录` : ''}</small>
|
||||
</span>
|
||||
<span aria-hidden="true" className="flex-none text-caption text-faint transition-transform duration-[180ms]" style={{ transform: open ? 'rotate(180deg)' : undefined }}>⌄</span>
|
||||
{/* 待改密码的提醒不能只藏在菜单里:胶囊上先挂一个角标。
|
||||
角标挂在胶囊而不是头像上——头像是 27px 的正圆,绝对定位的角标会把
|
||||
它自己的 scrollWidth 撑到 30px(内容没被裁,但等于凭空多出横向溢出)。 */}
|
||||
{mustChangePassword && (
|
||||
<p className="m-0 rounded-[8px] bg-warn-tint px-[9px] py-[7px] text-tiny leading-[1.5] text-warn-bright [overflow-wrap:anywhere]">
|
||||
<Link to="/account?must=1" role="menuitem" onClick={close} className="text-inherit underline">初始密码尚未修改,点此设置新密码 →</Link>
|
||||
</p>
|
||||
<span aria-hidden="true" className="absolute -right-0.5 -top-[3px] grid h-[14px] w-[14px] place-items-center rounded-pill bg-warn-fill text-tiny font-bold text-warn-ink">!</span>
|
||||
)}
|
||||
{!canEdit && <p className="m-0 rounded-[8px] bg-hover px-[9px] py-[7px] text-tiny leading-[1.5] text-faint">观摩角色:只读,写操作会被后端拒绝</p>}
|
||||
</button>
|
||||
</MenuTrigger>
|
||||
|
||||
<div role="separator" className="my-[5px] mx-0.5 h-px bg-line-soft"></div>
|
||||
|
||||
<NavLink to="/account" role="menuitem" title="账号信息、修改密码与登录设备" className={ITEM} onClick={close}>
|
||||
<i className={ICON}>◍</i><span>我的账号</span>
|
||||
</NavLink>
|
||||
{isAdmin && (
|
||||
<NavLink to="/users" role="menuitem" title="账号、角色与配额" className={ITEM} onClick={close}>
|
||||
<i className={ICON}>▤</i><span>用户管理</span>
|
||||
</NavLink>
|
||||
)}
|
||||
|
||||
{envIssue && (
|
||||
<>
|
||||
<div role="separator" className="my-[5px] mx-0.5 h-px bg-line-soft"></div>
|
||||
<p className="m-0 rounded-[8px] bg-warn-tint px-[9px] py-[7px] text-tiny leading-[1.5] text-warn-bright [overflow-wrap:anywhere]">{envIssue}</p>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div role="separator" className="my-[5px] mx-0.5 h-px bg-line-soft"></div>
|
||||
|
||||
<button type="button" role="menuitem" title="退出当前会话" onClick={signOut}
|
||||
className={cn(ITEM, 'text-danger [&_i]:text-danger hover:border-danger-line hover:bg-danger-tint hover:text-danger-bright hover:[&_i]:text-danger-bright')}>
|
||||
<i className={ICON}>⏻</i><span>退出登录</span>
|
||||
</button>
|
||||
<MenuContent label="账号菜单" className="w-[262px] p-[9px]">
|
||||
<div className="flex items-center gap-[9px] border-b border-line-soft px-1 pb-[9px] pt-[3px]">
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid min-w-0 gap-0.5">
|
||||
<b className="truncate text-[12.5px]">{displayName}</b>
|
||||
<small className="truncate text-tiny text-faint">{user.username}{user.email ? ` · ${user.email}` : ''}</small>
|
||||
</span>
|
||||
<em className="ml-auto flex-none rounded-pill bg-hover px-[6px] py-0.5 text-tiny not-italic text-ink-2">{roleLabel(user.role)}</em>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{mustChangePassword && (
|
||||
<MenuItem className="block" asChild>
|
||||
<Link to="/account?must=1" onClick={close} className="text-inherit">
|
||||
<span className="w-full rounded-[6px] bg-warn-tint px-[7px] py-[5px] text-left text-tiny leading-[1.5] text-warn-bright [overflow-wrap:anywhere]">
|
||||
初始密码尚未修改,点此设置新密码 →
|
||||
</span>
|
||||
</Link>
|
||||
</MenuItem>
|
||||
)}
|
||||
{!canEdit && <MenuNote className="my-[6px]">观摩角色:只读,写操作会被后端拒绝</MenuNote>}
|
||||
|
||||
<MenuSeparator />
|
||||
|
||||
<MenuItem asChild onSelect={close}>
|
||||
<NavLink to="/account" title="账号信息、修改密码与登录设备">
|
||||
<i className={MENU_ICON}>◍</i><span>我的账号</span>
|
||||
</NavLink>
|
||||
</MenuItem>
|
||||
{isAdmin && (
|
||||
<MenuItem asChild onSelect={close}>
|
||||
<NavLink to="/users" title="账号、角色与配额">
|
||||
<i className={MENU_ICON}>▤</i><span>用户管理</span>
|
||||
</NavLink>
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
{envIssue && (
|
||||
<>
|
||||
<MenuSeparator />
|
||||
<MenuNote tone="warn" className="my-[6px]">{envIssue}</MenuNote>
|
||||
</>
|
||||
)}
|
||||
|
||||
<MenuSeparator />
|
||||
|
||||
<MenuItem danger onSelect={signOut} title="退出当前会话">
|
||||
<i className={cn(MENU_ICON, 'text-danger')}>⏻</i><span>退出登录</span>
|
||||
</MenuItem>
|
||||
</MenuContent>
|
||||
</MenuRoot>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import {
|
|||
import { pauseAudio, playAudio, stopAudio, toggleAudio, useAudioStore } from '../../stores/audio'
|
||||
import { Button, MUTED, Tag } from '../ui'
|
||||
import { Select } from '../forms'
|
||||
import { floatingLayerOpen } from '../primitives'
|
||||
import { VersionPanel } from './VersionPanel'
|
||||
|
||||
/** 格子上写「关键帧」就够,括注里的「(平台配音)/(模型原声)」留给 tooltip */
|
||||
|
|
@ -101,6 +102,8 @@ export function MediaLightbox() {
|
|||
function onKeydown(event: KeyboardEvent) {
|
||||
const tag = (event.target as HTMLElement | null)?.tagName
|
||||
if (tag && /^(INPUT|TEXTAREA|SELECT)$/.test(tag)) return
|
||||
// 面板里的「版本」下拉开着时,Esc 是收下拉,不是收预览器(预览器里确实有 Select)
|
||||
if (event.key === 'Escape' && floatingLayerOpen()) return
|
||||
const s = usePreviewStore.getState()
|
||||
const shown = selectShown(s)
|
||||
const pb = selectPeers(s)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
recordingBlockedReason, recordingSupported, type MicProbe, type Recording
|
||||
} from '../../lib/recorder'
|
||||
import { AudioPlay } from './AudioPlay'
|
||||
import { Checkbox } from '../primitives'
|
||||
|
||||
export type RecordPickMeta = {
|
||||
durationMs: number
|
||||
|
|
@ -388,7 +389,7 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
<datalist id={listId}>{knownNames.map((n) => <option key={n} value={n} />)}</datalist>
|
||||
</label>
|
||||
<label className="m-0 inline-flex w-fit cursor-pointer flex-row items-center gap-[7px] text-label text-ink-2">
|
||||
<input type="checkbox" className="h-auto w-auto" checked={setCurrent} onChange={(e) => setSetCurrent(e.target.checked)} />保存后设为当前版本
|
||||
<Checkbox checked={setCurrent} onCheckedChange={(v) => setSetCurrent(v === true)} />保存后设为当前版本
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
import * as RadixCheckbox from '@radix-ui/react-checkbox'
|
||||
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef, type ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 勾选框(Radix Checkbox)。
|
||||
*
|
||||
* 换掉的是 `<input type=checkbox>` + `accent-color`:那条路只能改颜色,改不了形状——
|
||||
* macOS 给的是 3px 圆角的系统绿块,Windows 是方角,表格行里并排看就是「控件不是一套」。
|
||||
* 更麻烦的是 Shift 范围选择与 `indeterminate`:原生 indeterminate 只能用 JS 设 property,
|
||||
* React 没有对应属性(旧代码为此写过 ref 副作用)。Radix 把三态放进 `checked` 的值里。
|
||||
*
|
||||
* 三态在这里是真实需求:素材库表头那颗「全选」在有部分行选中时必须是半选,
|
||||
* 画成「没勾」会让人再点一次变成全不选。
|
||||
*
|
||||
* 两个 Indicator 都 forceMount,靠各自的 data-state 显隐:
|
||||
* 只对 `props.checked` 做三元判断的写法在非受控(defaultChecked)时会画错半选。
|
||||
*
|
||||
* 皮肤:14px(触摸档 18px,见 tokens.css --check-size),描边 + 主色填充 + 白色对勾,
|
||||
* 半选用一条短横。焦点环走全局 :focus-visible,不额外画。
|
||||
*/
|
||||
export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof RadixCheckbox.Root>, 'children'> & {
|
||||
/** 只有画在选项行里的那些(MultiSelect)需要换尺寸 */
|
||||
size?: 'sm' | 'md'
|
||||
/** 换掉对勾:比如「展开/折叠」这种借用勾选框皮肤的开关 */
|
||||
icon?: ReactNode
|
||||
}
|
||||
|
||||
export const Checkbox = forwardRef<ElementRef<typeof RadixCheckbox.Root>, CheckboxProps>(
|
||||
({ size = 'md', icon, className, ...props }, ref) => (
|
||||
<RadixCheckbox.Root
|
||||
ref={ref}
|
||||
className={cn('flex-none grid place-items-center rounded-[4px] border border-line-strong bg-field '
|
||||
+ 'text-on-accent transition-colors duration-120 '
|
||||
+ 'data-[state=checked]:border-accent-fill data-[state=checked]:bg-accent-fill '
|
||||
+ 'data-[state=indeterminate]:border-accent-fill data-[state=indeterminate]:bg-accent-fill '
|
||||
+ 'disabled:opacity-40 disabled:cursor-not-allowed',
|
||||
size === 'sm' ? 'w-[13px] h-[13px]' : 'w-(--check-size) h-(--check-size)', className)}
|
||||
{...props}>
|
||||
<RadixCheckbox.Indicator forceMount
|
||||
className="grid place-items-center hidden data-[state=checked]:grid">
|
||||
{icon ?? <CheckIcon />}
|
||||
</RadixCheckbox.Indicator>
|
||||
<RadixCheckbox.Indicator forceMount aria-hidden
|
||||
className="grid place-items-center hidden data-[state=indeterminate]:grid">
|
||||
<span className="block w-[7px] h-[2px] rounded-pill bg-current" />
|
||||
</RadixCheckbox.Indicator>
|
||||
</RadixCheckbox.Root>
|
||||
))
|
||||
Checkbox.displayName = 'Checkbox'
|
||||
|
||||
function CheckIcon() {
|
||||
return (
|
||||
<svg viewBox="0 0 14 14" className="block w-[10px] h-[10px]" aria-hidden="true"
|
||||
fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M2.5 7.4 5.6 10.4 11.5 3.9" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
import * as RadixDialog from '@radix-ui/react-dialog'
|
||||
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 浮层行为层:Radix Dialog。
|
||||
*
|
||||
* 自己实现一份「浮层」要付的账(旧 Overlay.tsx 全踩过):
|
||||
* 焦点进不去、Tab 能跑到背后的页面上、Esc 靠 window 全局监听互相抢、
|
||||
* 滚动锁只写 body{overflow:hidden}(有滚动条的页面开抽屉会左右跳 15px)、
|
||||
* 读屏拿不到标题(role=dialog 却没有可关联的名字)。
|
||||
* Radix 把这五件事做完了,并且和 Popover / Menu 共用同一个 DismissableLayer 栈,
|
||||
* 「点下拉面板不算点外面」这类判断才有一个统一的地方。
|
||||
*
|
||||
* 皮肤仍然在我们的令牌里(tokens.css + Tailwind),Radix 只给 data-state。
|
||||
*
|
||||
* ⚠️ 可访问性名字必须显式给:Radix 找不到 <Dialog.Title> 又没看到
|
||||
* aria-label / aria-labelledby 就在控制台报警告。我们的标题是 <h2>{title}</h2>
|
||||
* 这种自带结构的节点(还常常套一层 <span title="…">),所以用 useId 把
|
||||
* id 牵到 aria-labelledby 上,而不是把 h2 塞进 Dialog.Title 里改排版;
|
||||
* 没有副标题时传 aria-describedby={undefined}(键存在就足够让警告闭嘴)。
|
||||
*/
|
||||
|
||||
export const DialogRoot = RadixDialog.Root
|
||||
export const DialogTrigger = RadixDialog.Trigger
|
||||
export const DialogClose = RadixDialog.Close
|
||||
export const DialogPortal = RadixDialog.Portal
|
||||
|
||||
/** 遮罩。层级低于面板、高于页面内容;下拉面板(Popup 的 400)再压在面板上 */
|
||||
export const scrimLayer = 'fixed inset-0 z-[100] bg-scrim backdrop-blur-[4px] data-[state=open]:animate-fade-in'
|
||||
|
||||
export function Scrim(props: ComponentPropsWithoutRef<typeof RadixDialog.Overlay>) {
|
||||
return <RadixDialog.Overlay {...props} className={cn(scrimLayer, props.className)} />
|
||||
}
|
||||
|
||||
/**
|
||||
* 「点外面」判定。
|
||||
*
|
||||
* 两种不关:① closeOnBackdrop=false(分镜那种要看旁边面板的浮层);
|
||||
* ② 点到的其实是浮层里那个下拉面板——Radix Popover 把面板 portal 到 body,
|
||||
* DOM 上不在 Content 里。Radix 自己的层栈能认出大多数情况,这里再兜一道,
|
||||
* 免得选中一项就把整个抽屉关掉(也顺便挡住焦点移出触发的 FocusOutside)。
|
||||
*/
|
||||
function floatingLayerOf(target: EventTarget | null) {
|
||||
const el = target instanceof Element ? target : null
|
||||
return !!el?.closest('[data-nex-layer],[data-radix-popper-content-wrapper]')
|
||||
}
|
||||
function keepOpen(closeOnBackdrop: boolean) {
|
||||
return <E extends { detail?: { originalEvent?: Event }; preventDefault(): void }>(e: E) => {
|
||||
const original = e.detail?.originalEvent
|
||||
if (!closeOnBackdrop || floatingLayerOf(original?.target ?? null)) e.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开时不把焦点丢进第一个输入框:抽屉里 autofokus 会顶掉页面滚动位置 */
|
||||
function holdFocus() {
|
||||
return (e: Event) => {
|
||||
e.preventDefault()
|
||||
;(e.currentTarget as HTMLElement | null)?.focus?.({ preventScroll: true })
|
||||
}
|
||||
}
|
||||
|
||||
/** 右侧抽屉的面板(配合 DrawerBody/DrawerActions 三段式皮肤) */
|
||||
export function SheetContent({ children, width, closeOnBackdrop = true, labelledBy, describedBy, label, className }: {
|
||||
children: ReactNode
|
||||
/** Tailwind 宽度类;默认 1360px 表单抽屉 */
|
||||
width?: string
|
||||
closeOnBackdrop?: boolean
|
||||
labelledBy?: string
|
||||
describedBy?: string
|
||||
label?: string
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<RadixDialog.Content
|
||||
aria-labelledby={labelledBy} aria-describedby={describedBy ?? undefined} aria-label={label}
|
||||
onOpenAutoFocus={holdFocus()} onCloseAutoFocus={(e) => e.preventDefault()}
|
||||
onInteractOutside={keepOpen(closeOnBackdrop)} onFocusOutside={keepOpen(closeOnBackdrop)}
|
||||
className={cn('fixed inset-y-0 right-0 z-[101] flex flex-col min-w-0 h-full border-l border-line-strong '
|
||||
+ 'bg-shell shadow-drawer data-[state=open]:animate-sheet-in',
|
||||
width || 'w-[min(1360px,calc(100vw-20px))] max-huge:w-[calc(100vw-16px)] max-short:w-screen', className)}>
|
||||
{children}
|
||||
</RadixDialog.Content>
|
||||
)
|
||||
}
|
||||
|
||||
/** 居中模态的面板:只放一两句确认文案 + 两个动作 */
|
||||
export function ModalContent({ children, width = 560, closeOnBackdrop = true, labelledBy, describedBy, label, className }: {
|
||||
children: ReactNode
|
||||
/** 像素宽度上限(窄屏由 calc(100vw-32px) 兜住) */
|
||||
width?: number
|
||||
closeOnBackdrop?: boolean
|
||||
labelledBy?: string
|
||||
describedBy?: string
|
||||
label?: string
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<RadixDialog.Content
|
||||
aria-labelledby={labelledBy} aria-describedby={describedBy ?? undefined} aria-label={label}
|
||||
onOpenAutoFocus={holdFocus()} onCloseAutoFocus={(e) => e.preventDefault()}
|
||||
onInteractOutside={keepOpen(closeOnBackdrop)} onFocusOutside={keepOpen(closeOnBackdrop)}
|
||||
style={{ maxWidth: `min(${width}px, calc(100vw - 32px))` }}
|
||||
className={cn('fixed left-1/2 top-1/2 z-[111] -translate-x-1/2 -translate-y-1/2 '
|
||||
+ 'flex max-h-[calc(100vh-32px)] w-full flex-col overflow-hidden rounded-float '
|
||||
+ 'border border-line-strong bg-shell shadow-pop data-[state=open]:animate-pop-in', className)}>
|
||||
{children}
|
||||
</RadixDialog.Content>
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
import * as RadixMenu from '@radix-ui/react-dropdown-menu'
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 菜单(Radix DropdownMenu):账号菜单、行内操作菜单共用。
|
||||
*
|
||||
* 换掉的是「div + useOutsideClick + role=menu」那套手写实现:它没有焦点圈定
|
||||
* (Tab 会跑到菜单背后)、方向键不能走选项、Esc 只关自己不管焦点归还,
|
||||
* 而且每个使用点都得自己记得挂 useOutsideClick,漏一个就是一处 bug。
|
||||
*
|
||||
* 皮肤档位与下拉面板同源(tokens:圆角 float / 描边 line-strong / 底 panel)。
|
||||
*/
|
||||
export const MenuRoot = RadixMenu.Root
|
||||
export const MenuTrigger = RadixMenu.Trigger
|
||||
export const MenuPortal = RadixMenu.Portal
|
||||
export const MenuGroup = RadixMenu.Group
|
||||
|
||||
const CONTENT = 'z-[400] min-w-[196px] rounded-float border border-line-strong bg-panel p-[7px] '
|
||||
+ 'shadow-pop data-[state=open]:animate-fade-in'
|
||||
const ITEM = 'flex min-h-[32px] w-full items-center gap-[9px] rounded-[8px] px-[9px] py-[7px] '
|
||||
+ 'text-left text-body text-ink-2 no-underline outline-none cursor-pointer '
|
||||
+ 'data-[highlighted]:bg-hover data-[highlighted]:text-ink '
|
||||
+ 'disabled:opacity-40 disabled:cursor-not-allowed'
|
||||
export const MENU_ITEM = ITEM
|
||||
export const MENU_ICON = 'w-[15px] flex-none text-center text-body text-muted'
|
||||
|
||||
export function MenuContent({ children, className, label, align = 'end', sideOffset = 8 }: {
|
||||
children: ReactNode; className?: string; label?: string
|
||||
align?: 'start' | 'center' | 'end'; sideOffset?: number
|
||||
}) {
|
||||
return (
|
||||
<RadixMenu.Portal>
|
||||
<RadixMenu.Content data-nex-layer="menu" aria-label={label} side="bottom" align={align} sideOffset={sideOffset}
|
||||
// 打开时焦点进菜单(DropdownMenu 没有 onOpenAutoFocus——它本来就
|
||||
// 把焦点交给面板,方向键/首字母定位由 Radix 接管),
|
||||
// 关闭时由 Radix 还给触发按钮。
|
||||
className={cn(CONTENT, className)}>
|
||||
{children}
|
||||
</RadixMenu.Content>
|
||||
</RadixMenu.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
/** 菜单项:asChild 时把语义挂到 Link / NavLink 上,路由跳转仍然由 React Router 负责 */
|
||||
export function MenuItem({ children, className, danger, asChild, ...props }:
|
||||
React.ComponentProps<typeof RadixMenu.Item> & { danger?: boolean }) {
|
||||
return (
|
||||
<RadixMenu.Item
|
||||
{...props} asChild={asChild}
|
||||
className={cn(ITEM, danger && 'text-danger data-[highlighted]:bg-danger-tint data-[highlighted]:text-danger-bright',
|
||||
className)}>
|
||||
{children}
|
||||
</RadixMenu.Item>
|
||||
)
|
||||
}
|
||||
|
||||
/** 菜单里的说明块(不可点:环境自检结论、权限提示) */
|
||||
export function MenuNote({ children, tone = 'muted', className }: {
|
||||
children: ReactNode; tone?: 'muted' | 'warn'; className?: string
|
||||
}) {
|
||||
return (
|
||||
<p className={cn('m-0 rounded-[8px] px-[9px] py-[7px] text-tiny leading-[1.5] [overflow-wrap:anywhere]',
|
||||
tone === 'warn' ? 'bg-warn-tint text-warn-bright' : 'bg-hover text-faint', className)}>
|
||||
{children}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
export function MenuSeparator({ className }: { className?: string }) {
|
||||
return <RadixMenu.Separator className={cn('my-[5px] mx-0.5 h-px bg-line-soft', className)} />
|
||||
}
|
||||
|
|
@ -40,6 +40,9 @@ export function Popup({ open, onOpenChange, anchor, anchorRef, children, classNa
|
|||
<RadixPopover.Anchor asChild>{anchor}</RadixPopover.Anchor>
|
||||
<RadixPopover.Portal>
|
||||
<RadixPopover.Content
|
||||
// 给 Dialog 的「点外面」判定认人用:面板 portal 在 body 上,
|
||||
// 抽屉需要知道「这点在我下拉里」,否则选中一项就把抽屉关了
|
||||
data-nex-layer="popup"
|
||||
aria-label={label}
|
||||
// 左对齐锚点、下沿 6px;离视口边留 8px,放不下由 Radix 翻到上方
|
||||
side="bottom" align="start" sideOffset={6} collisionPadding={8}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
import * as RadixSlider from '@radix-ui/react-slider'
|
||||
import type { ComponentPropsWithoutRef, ElementRef } from 'react'
|
||||
import { forwardRef } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 数值滑杆(Radix Slider)。
|
||||
*
|
||||
* 原生 `<input type=range>` 的 `accent-color` 只能改一个颜色:轨道粗细、滑块直径、
|
||||
* 已填充段全是系统画的(模型抽屉里 Temperature 那根 5px 灰线配一颗系统绿点,
|
||||
* 和旁边的自定义控件明显不是一套)。Radix 给出 track / range / thumb 三个槽,
|
||||
* 尺寸全部来自我们的令牌,键盘(← → Home End PageUp/Down)与 aria 值域也齐了。
|
||||
*
|
||||
* 命中区撑满 --ctl-h(肉眼看到的仍是 5px 细轨),拖动时不用瞄准。
|
||||
*/
|
||||
export type SliderProps = Omit<ComponentPropsWithoutRef<typeof RadixSlider.Root>, 'children'> & {
|
||||
trackClassName?: string
|
||||
/** 多段滑杆(起止时间)时才需要传第二个 thumb,Radix 按 value 数组长度画 */
|
||||
thumbs?: number
|
||||
}
|
||||
|
||||
export const Slider = forwardRef<ElementRef<typeof RadixSlider.Root>, SliderProps>(
|
||||
({ className, trackClassName, thumbs = 1, ...props }, ref) => (
|
||||
<RadixSlider.Root
|
||||
ref={ref}
|
||||
className={cn('relative flex items-center w-full min-w-0 h-(--ctl-h) touch-none select-none '
|
||||
+ 'disabled:opacity-45', className)}
|
||||
{...props}>
|
||||
<RadixSlider.Track
|
||||
className={cn('relative grow h-[5px] rounded-pill bg-active overflow-hidden', trackClassName)}>
|
||||
<RadixSlider.Range className="absolute inset-y-0 left-0 rounded-pill bg-accent-fill" />
|
||||
</RadixSlider.Track>
|
||||
{Array.from({ length: thumbs }, (_, i) => (
|
||||
<RadixSlider.Thumb key={i}
|
||||
className="block w-[14px] h-[14px] rounded-pill border-[3px] border-accent-fill bg-card" />
|
||||
))}
|
||||
</RadixSlider.Root>
|
||||
))
|
||||
Slider.displayName = 'Slider'
|
||||
|
|
@ -9,3 +9,7 @@
|
|||
export * from './layers'
|
||||
export * from './use-listbox'
|
||||
export * from './Popup'
|
||||
export * from './Dialog'
|
||||
export * from './Menu'
|
||||
export * from './Checkbox'
|
||||
export * from './Slider'
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@ import { cn } from '../../lib/cn'
|
|||
* 多出来的 86px 直接压住右边的字段标题。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 页面上是否有浮层(Dialog / 下拉面板 / 菜单)正开着。
|
||||
*
|
||||
* 页面级快捷键必须先看它一眼:Radix 的 Esc 只负责关自己那一层,
|
||||
* 而页面的 window keydown 是另挂的——「检查器 + 下拉」「预览器 + 版本下拉」
|
||||
* 叠在一起时,一次 Esc 会把两层全关掉(用户描述:「按 Esc 结果整个抽屉都没了」)。
|
||||
* 判据用我们自己在每层浮层上打的 data-nex-layer / Radix 的 data-state,
|
||||
* 不依赖 z-index,也不依赖组件实例间的 context。
|
||||
*/
|
||||
export function floatingLayerOpen(root: ParentNode = document): boolean {
|
||||
return !!root.querySelector('[data-nex-layer][data-state="open"], [role="dialog"][data-state="open"]')
|
||||
}
|
||||
|
||||
/** 触发器:高度只来自 --ctl-h(容器决定档位),组件内部不写死 px */
|
||||
export const triggerLayer = cva([
|
||||
'appearance-none flex items-center gap-2 w-full min-w-0 text-left outline-none',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { createContext, useContext } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Checkbox } from '../primitives'
|
||||
import { Select } from '../forms/Select'
|
||||
import { TAG_DENSE } from './Status'
|
||||
|
||||
/**
|
||||
|
|
@ -32,11 +34,11 @@ const LABEL_CHILD = '[&>label]:flex [&>label]:flex-row [&>label]:items-center [&
|
|||
* flex-1 的 flex-basis:0% 会接管高度——同一抽屉里 input 被拉到 46px、
|
||||
* 旁边那行又是 38px,就是用户截图中「第一行明显更高」的根因。
|
||||
*/
|
||||
const FIELD_INNER = '[&>*]:min-w-0 [&_span:first-child]:flex-none [&_input[type=checkbox]]:flex-none [&_input[type=checkbox]]:w-auto [&_input[type=radio]]:flex-none'
|
||||
const FIELD_INNER = '[&>*]:min-w-0 [&_span:first-child]:flex-none [&_[role=checkbox]]:flex-none [&_[role=radio]]:flex-none'
|
||||
|
||||
export function Ctlbar({ children, className, as: As = 'div' }: { children: ReactNode; className?: string; as?: any }) {
|
||||
return (
|
||||
<As className={cn('[--ctl-h:var(--ctl-h-md)] flex items-center flex-wrap gap-y-2 gap-x-[10px] min-w-0 mb-3',
|
||||
<As className={cn('[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center flex-wrap gap-y-2 gap-x-[10px] min-w-0 mb-3',
|
||||
'[&>*]:min-w-0', LABEL_CHILD, className)}>
|
||||
{children}
|
||||
</As>
|
||||
|
|
@ -46,7 +48,7 @@ export function Ctlbar({ children, className, as: As = 'div' }: { children: Reac
|
|||
/** 卡片内部的动作行:布局同 Ctlbar,但不带 12px 下边距(否则卡片里凭空多一段空白) */
|
||||
export function CardActions({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] flex items-center flex-wrap gap-y-2 gap-x-[10px] min-w-0 [&>*]:min-w-0', className)}>
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center flex-wrap gap-y-2 gap-x-[10px] min-w-0 [&>*]:min-w-0', className)}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
|
@ -69,6 +71,21 @@ const WIDTHS: Record<FieldWidth, string> = {
|
|||
/**
|
||||
* 行内标签字段:`<Field label="类型">…</Field>`;stack 场景交给 <FormRow stack> 统一翻向。
|
||||
* title 挂在外层 label 上:整块(标签 + 控件)都是悬停热区,和旧站 .fld[title] 一致。
|
||||
*
|
||||
* 标签列宽(对齐的关键):标签是 flex-none + nowrap,宽度就是文字本身,
|
||||
* 于是「显示名」的输入框比「角色」右移 14px——同一张表单里每条控件的左边缘都不同。
|
||||
* 现在标签至少占 --label-w:表单栅格(FormRow)把它抬到 --field-label-w=66px,
|
||||
* 同行同列共用一条控件左边界;筛选条这类贴边排版的容器把它压回 0px(保持老样子)。
|
||||
* 只给下限不给上限:超过 66px 的长标题(「覆盖负面提示词(可选)」)宁可把控件顶右,
|
||||
* 也不截断标题。宽度是量出来的,见 tokens.css --field-label-w。
|
||||
*
|
||||
* ⚠️ 下限必须写在**容器**上(`[&>span:first-child]`),不能只写在标签 span 自己那句
|
||||
* `min-w-(--label-w)` 里:同一个 Field 还带着 `[&>*]:min-w-0`(让长控件能收缩),
|
||||
* 它编译成 `.min-w-0 > *`,和 `.min-w-\(--label-w\)` 同为 0-1-0 特指度,
|
||||
* 而 Tailwind 把 `min-w-0` 排在自定义值之后 → 后者赢,标签的 66px 下限被无声清零。
|
||||
* /account 的「登录名 30.9 / 邮箱 20.6 / 当前密码 41.2」就是这么来的。
|
||||
* `span:first-child` 多一个伪类(0-2-1)才压得住;span 上那句留着,是为了
|
||||
* 让脱离 Field 复用 LABEL_CLS 的地方也有同一个下限。
|
||||
*/
|
||||
export function Field({ label, required, children, width = 'default', className, hint, title }: {
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth; className?: string; hint?: ReactNode
|
||||
|
|
@ -77,11 +94,14 @@ export function Field({ label, required, children, width = 'default', className,
|
|||
return (
|
||||
<label title={title} data-full={width === 'full' ? '' : undefined}
|
||||
className={cn(LABEL, FIELD_INNER, WIDTHS[width], 'min-w-0',
|
||||
// 标签列宽的下限(写法原因见上面的 ⚠️):只有真的传了 label 才加,
|
||||
// 否则无标签字段的第一个 span 会被当成标签列撑到 66px。
|
||||
label && '[&>span:first-child]:min-w-(--label-w)',
|
||||
// 带 hint 的字段翻成两列栅格:标签在左上、控件在右上、说明贴在控件下面。
|
||||
// 不能只是 flex-wrap——base.css 里控件是 w-full,一换行控件就被整体挤到第二行,
|
||||
// 标签跑回上面,同一栅格里就成了「一个横排、两个竖排」的混排(规范 R3)。
|
||||
hint && 'grid grid-cols-[auto_minmax(0,1fr)]', className)}>
|
||||
{label && <span className="flex-none">{label}{required && <Req />}</span>}
|
||||
hint && 'grid grid-cols-[minmax(var(--label-w),max-content)_minmax(0,1fr)]', className)}>
|
||||
{label && <span className="flex-none min-w-(--label-w)">{label}{required && <Req />}</span>}
|
||||
{children}
|
||||
{hint && (
|
||||
<span className="col-start-2 w-full pt-[3px] text-faint text-tiny leading-[1.5] font-normal tracking-[0]">
|
||||
|
|
@ -104,7 +124,7 @@ export function FieldBlock({ label, required, children, className, title }: {
|
|||
title?: string
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('[--ctl-h:var(--ctl-h-main)] flex flex-col gap-[5px] mb-[10px] min-w-0', className)}>
|
||||
<label title={title} className={cn('[--ctl-h:var(--ctl-h-main)] [--label-w:0px] flex flex-col gap-[5px] mb-[10px] min-w-0', className)}>
|
||||
<span className="flex items-center gap-1 text-muted text-tiny tracking-[.3px] flex-wrap whitespace-nowrap">
|
||||
{label}{required && <Req />}
|
||||
</span>
|
||||
|
|
@ -168,6 +188,8 @@ const LATTICE: Record<number, string> = {
|
|||
* 表单容器显式声明自己是主尺寸(38px):抽屉/对话框里的字段永远同一档,
|
||||
* 不会因为外面套了一层紧凑档工具条(Ctlbar / ChipBar / 抽屉动作条)
|
||||
* 就整排缩水成 31px——一个容器只有一个 --ctl-h 档位。
|
||||
* 同理在这里抬 --label-w:标签列宽是「表单才需要」的规则,
|
||||
* 由行作用域下发,页面永远不必自己写宽度。
|
||||
*/
|
||||
export function FormRow({ children, cols, tight, stack, className }: {
|
||||
children: ReactNode
|
||||
|
|
@ -179,7 +201,7 @@ export function FormRow({ children, cols, tight, stack, className }: {
|
|||
className?: string
|
||||
}) {
|
||||
const grid = useContext(FormGridCtx)
|
||||
const shared = '[--ctl-h:var(--ctl-h-main)] grid mb-[10px] min-w-0 [&>*]:min-w-0 '
|
||||
const shared = '[--ctl-h:var(--ctl-h-main)] [--label-w:var(--field-label-w)] grid mb-[10px] min-w-0 [&>*]:min-w-0 '
|
||||
// 每个字段贴到自己格子的顶端:否则带 hint 的字段把行撑高之后,
|
||||
// 旁边没 hint 的字段会被垂直居中,同一行三个输入框错开半行(规范 R3)。
|
||||
+ '[&>*]:self-start '
|
||||
|
|
@ -217,7 +239,7 @@ export function FormRow({ children, cols, tight, stack, className }: {
|
|||
/** chip / 标签行(规范 §2):与下方内容强制呼吸 12px */
|
||||
export function ChipBar({ children, label, className, top }: { children: ReactNode; label?: ReactNode; className?: string; top?: boolean }) {
|
||||
return (
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] flex items-center gap-1.5 flex-wrap mb-3 min-w-0', top && 'mt-3', className)}>
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center gap-1.5 flex-wrap mb-3 min-w-0', top && 'mt-3', className)}>
|
||||
{label && <span className="flex-none text-muted text-tiny tracking-[.6px] font-bold">{label}</span>}
|
||||
{children}
|
||||
</div>
|
||||
|
|
@ -289,18 +311,21 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra,
|
|||
}) {
|
||||
const last = Math.max(1, pages)
|
||||
return (
|
||||
<div className="[--ctl-h:var(--ctl-h-md)] flex items-center justify-center gap-[10px] flex-wrap mt-3 text-dim text-tiny">
|
||||
<button type="button" className="h-(--ctl-h-md) px-2 rounded-control border border-line-strong bg-raise text-ink-3 text-tiny disabled:opacity-35"
|
||||
<div className="[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center justify-center gap-[10px] flex-wrap mt-3 text-dim text-tiny">
|
||||
<button type="button" className="h-(--ctl-h-md) px-2 rounded-control border border-line-strong bg-raise text-ink-3 text-body disabled:opacity-35"
|
||||
disabled={page <= 1} onClick={() => onPage(page - 1)}>上一页</button>
|
||||
<span>{page} / {last}{total !== undefined ? ` · 共 ${total} 条` : ''}</span>
|
||||
<button type="button" className="h-(--ctl-h-md) px-2 rounded-control border border-line-strong bg-raise text-ink-3 text-tiny disabled:opacity-35"
|
||||
<button type="button" className="h-(--ctl-h-md) px-2 rounded-control border border-line-strong bg-raise text-ink-3 text-body disabled:opacity-35"
|
||||
disabled={page >= last} onClick={() => onPage(page + 1)}>下一页</button>
|
||||
{onPageSize && (
|
||||
<label className="flex items-center gap-1.5 m-0 text-muted text-tiny whitespace-nowrap">
|
||||
<span className="flex-none">每页</span>
|
||||
<select value={pageSize} onChange={(e) => onPageSize(Number(e.target.value))} className="w-auto min-w-[64px]">
|
||||
{sizes.map((n) => <option key={n} value={n}>{n || '全部'}</option>)}
|
||||
</select>
|
||||
{/* 分页条是全站最后一个裸 <select>:系统箭头 + 系统弹单,和旁边 31px 的按钮不成一套。
|
||||
换成 forms/Select(同一套 Radix Popover 皮肤);选项最多 8 条,不配过滤框。 */}
|
||||
<Select size="sm" ariaLabel="每页条数" searchThreshold={0} placeholder="全部"
|
||||
value={pageSize} onChange={(v) => onPageSize(Number(v))}
|
||||
className="w-auto min-w-[64px]"
|
||||
options={sizes.map((n) => ({ value: n, label: String(n || '全部') }))} />
|
||||
</label>
|
||||
)}
|
||||
{extra}
|
||||
|
|
@ -308,13 +333,21 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra,
|
|||
)
|
||||
}
|
||||
|
||||
/** 复选(.check):勾选框 + 文案,整块可点 */
|
||||
/**
|
||||
* 复选(.check):勾选框 + 文案,整块可点。
|
||||
*
|
||||
* 勾选框本体是 primitives/Checkbox(Radix),不再是 `<input type=checkbox>` + `accent-color`:
|
||||
* 系统控件只有 3px 圆角的绿块能改颜色,形状、描边、三态都改不了,
|
||||
* 和同排的自定义控件并排就是两套东西(模型抽屉的「启用模型」是现场证据)。
|
||||
* 文案留在外层 <label> 里:button 属于 HTML 的 labelable 元素,
|
||||
* 点文字会转成点控件,热区比原来大,同时给控件读出这个名字(不需要再写 aria-label)。
|
||||
*/
|
||||
export function Check({ checked, onChange, children, disabled, className, title }: {
|
||||
checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean; className?: string; title?: string
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('inline-flex flex-row items-center gap-[7px] text-caption text-ink-3 cursor-pointer flex-none whitespace-nowrap', className)}>
|
||||
<input type="checkbox" className="w-auto" checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} />
|
||||
<Checkbox checked={checked} disabled={disabled} onCheckedChange={(v) => onChange(v === true)} />
|
||||
{children}
|
||||
</label>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useEffect, type ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { useId, type ReactNode } from 'react'
|
||||
import { DialogPortal, DialogRoot, ModalContent, Scrim, SheetContent } from '../primitives/Dialog'
|
||||
|
||||
/**
|
||||
* 浮层:抽屉(右滑全高)与居中模态。
|
||||
|
|
@ -8,35 +8,11 @@ import { cn } from '../../lib/cn'
|
|||
* 三处 padding、两处宽度、四种关闭条件互不相同;抽屉内控件高度也因此
|
||||
* 各写各的 --ctl-h(历史散落在 MediaLightbox / AssetLibrary / ModelCenter)。
|
||||
* 现在宽度、留白、高度档只在这里有一份,页面只提供内容。
|
||||
*
|
||||
* 行为(焦点圈定、背后滚动锁、Esc、外点关闭、读屏名字)在 primitives/Dialog(Radix),
|
||||
* 这里只剩三段式皮肤与业务参数——页面 API 一个都没变。
|
||||
*/
|
||||
|
||||
/** Esc 关闭 + 锁定背后页面滚动(多个浮层叠加时用引用计数,关掉一个不会误放开) */
|
||||
function useOverlay(open: boolean, onClose: () => void, closeOnEsc = true) {
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
if (closeOnEsc) {
|
||||
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') { e.stopPropagation(); onClose() } }
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}
|
||||
return undefined
|
||||
}, [open, onClose, closeOnEsc])
|
||||
}
|
||||
|
||||
let locked = 0
|
||||
function useScrollLock(open: boolean) {
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
locked += 1
|
||||
const prev = document.body.style.overflow
|
||||
document.body.style.overflow = 'hidden'
|
||||
return () => {
|
||||
locked = Math.max(0, locked - 1)
|
||||
if (locked === 0) document.body.style.overflow = prev
|
||||
}
|
||||
}, [open])
|
||||
}
|
||||
|
||||
/* ── 抽屉三段式的皮肤(UI规范 §3)────────────────────────────────────────
|
||||
<Drawer> 一处用它们时,类名写死在 JSX 里就够了;分镜「检查器」是第二处:
|
||||
它刻意不做成 Drawer(Drawer 是模态——遮罩会吞掉左边看板的点击、Esc 一按就关,
|
||||
|
|
@ -57,7 +33,8 @@ export const DRAWER_ACTIONS = 'flex-none flex flex-wrap items-center gap-2 p-[14
|
|||
/**
|
||||
* 浮层右上角的 ✕。抽屉、模态、分镜检查器各抄过一份,
|
||||
* 其中模态那份就漏了 hover 描边——同一个动作长三种样子,这里收成一个。
|
||||
* 提示统一带「(Esc)」:浮层一律 Esc 可关(见 useOverlay),别让人去猜。
|
||||
* 提示统一带「(Esc)」:浮层一律 Esc 可关(Radix 的 dismissable 层负责),
|
||||
* 别让人去猜。
|
||||
*/
|
||||
export function CloseButton({ onClose, label = '关闭' }: { onClose: () => void; label?: string }) {
|
||||
return (
|
||||
|
|
@ -66,6 +43,12 @@ export function CloseButton({ onClose, label = '关闭' }: { onClose: () => void
|
|||
)
|
||||
}
|
||||
|
||||
/** 标题/副标题与面板的关联:Radix 只认 aria-labelledby / aria-label,没有就控制台告警 */
|
||||
function useNames() {
|
||||
const uid = useId()
|
||||
return { titleId: `${uid}-t`, subId: `${uid}-d` }
|
||||
}
|
||||
|
||||
export function Drawer({ open, onClose, title, sub, children, actions, width, closeOnBackdrop = true, label }: {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
|
|
@ -80,32 +63,32 @@ export function Drawer({ open, onClose, title, sub, children, actions, width, cl
|
|||
closeOnBackdrop?: boolean
|
||||
label?: string
|
||||
}) {
|
||||
useOverlay(open, onClose)
|
||||
useScrollLock(open)
|
||||
if (!open) return null
|
||||
const { titleId, subId } = useNames()
|
||||
return (
|
||||
<div className="fixed inset-0 z-[100] flex justify-end bg-scrim backdrop-blur-[4px]"
|
||||
onMouseDown={(e) => { if (closeOnBackdrop && e.target === e.currentTarget) onClose() }}>
|
||||
<section role="dialog" aria-modal="true" aria-label={typeof label === 'string' ? label : undefined}
|
||||
className={cn('flex flex-col min-w-0 h-screen border-l border-line-strong bg-shell shadow-drawer',
|
||||
width || 'w-[min(1360px,calc(100vw-20px))] max-huge:w-[calc(100vw-16px)] max-short:w-screen')}>
|
||||
<header className={DRAWER_HEAD}>
|
||||
<div className="min-w-0">
|
||||
<h2 className="text-lg font-bold mt-0 mb-0">{title}</h2>
|
||||
{sub && <p className="mt-[5px] mb-0 text-tiny text-dim leading-[1.6]">{sub}</p>}
|
||||
<DialogRoot open={open} onOpenChange={(next) => { if (!next) onClose() }}>
|
||||
<DialogPortal>
|
||||
<Scrim />
|
||||
<SheetContent width={width} closeOnBackdrop={closeOnBackdrop}
|
||||
labelledBy={titleId} describedBy={sub ? subId : undefined}
|
||||
label={typeof label === 'string' ? label : undefined}>
|
||||
<header className={DRAWER_HEAD}>
|
||||
<div className="min-w-0">
|
||||
<h2 id={titleId} className="text-lg font-bold mt-0 mb-0">{title}</h2>
|
||||
{sub && <p id={subId} className="mt-[5px] mb-0 text-tiny text-dim leading-[1.6]">{sub}</p>}
|
||||
</div>
|
||||
<CloseButton onClose={onClose} />
|
||||
</header>
|
||||
<div className={DRAWER_BODY}>
|
||||
{children}
|
||||
</div>
|
||||
<CloseButton onClose={onClose} />
|
||||
</header>
|
||||
<div className={DRAWER_BODY}>
|
||||
{children}
|
||||
</div>
|
||||
{actions && (
|
||||
<footer className={DRAWER_ACTIONS}>
|
||||
{actions}
|
||||
</footer>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
{actions && (
|
||||
<footer className={DRAWER_ACTIONS}>
|
||||
{actions}
|
||||
</footer>
|
||||
)}
|
||||
</SheetContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -120,26 +103,26 @@ export function Modal({ open, onClose, title, children, footer, width = 560, clo
|
|||
closeOnBackdrop?: boolean
|
||||
label?: string
|
||||
}) {
|
||||
useOverlay(open, onClose)
|
||||
useScrollLock(open)
|
||||
if (!open) return null
|
||||
const { titleId, subId } = useNames()
|
||||
return (
|
||||
<div className="fixed inset-0 z-[110] grid place-items-center p-4 bg-scrim backdrop-blur-[4px]"
|
||||
onMouseDown={(e) => { if (closeOnBackdrop && e.target === e.currentTarget) onClose() }}>
|
||||
<section role="dialog" aria-modal="true" aria-label={label}
|
||||
style={{ maxWidth: width }}
|
||||
className="w-full max-w-full bg-shell border border-line-strong rounded-float shadow-pop overflow-hidden max-h-[calc(100vh-32px)] flex flex-col">
|
||||
{title && (
|
||||
<header className="flex-none flex items-center justify-between gap-3 p-[14px_18px] border-b border-[--c-bg-emphasis] bg-[linear-gradient(120deg,var(--c-bg-raised),var(--c-bg-panel)_55%)]">
|
||||
<div className="min-w-0">
|
||||
<h2 className="text-md font-bold m-0">{title}</h2>
|
||||
</div>
|
||||
<CloseButton onClose={onClose} />
|
||||
</header>
|
||||
)}
|
||||
<div className="flex-1 min-w-0 overflow-y-auto scrollbar-slim p-[18px] [scrollbar-gutter:stable]">{children}</div>
|
||||
{footer && <footer className="flex-none flex items-center justify-end gap-2 p-[12px_18px] border-t border-line bg-raised [--ctl-h:var(--ctl-h-md)]">{footer}</footer>}
|
||||
</section>
|
||||
</div>
|
||||
<DialogRoot open={open} onOpenChange={(next) => { if (!next) onClose() }}>
|
||||
<DialogPortal>
|
||||
<Scrim />
|
||||
<ModalContent width={width} closeOnBackdrop={closeOnBackdrop}
|
||||
labelledBy={title ? titleId : undefined} describedBy={subId}
|
||||
label={label}>
|
||||
{title && (
|
||||
<header className="flex-none flex items-center justify-between gap-3 p-[14px_18px] border-b border-[--c-bg-emphasis] bg-[linear-gradient(120deg,var(--c-bg-raised),var(--c-bg-panel)_55%)]">
|
||||
<div className="min-w-0">
|
||||
<h2 id={titleId} className="text-md font-bold m-0">{title}</h2>
|
||||
</div>
|
||||
<CloseButton onClose={onClose} />
|
||||
</header>
|
||||
)}
|
||||
<div id={subId} className="flex-1 min-w-0 overflow-y-auto scrollbar-slim p-[18px] [scrollbar-gutter:stable]">{children}</div>
|
||||
{footer && <footer className="flex-none flex items-center justify-end gap-2 p-[12px_18px] border-t border-line bg-raised [--ctl-h:var(--ctl-h-md)]">{footer}</footer>}
|
||||
</ModalContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { type ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Slider as RadixSlider } from '../primitives/Slider'
|
||||
import { LABEL_CLS } from './Controls'
|
||||
|
||||
/**
|
||||
|
|
@ -7,6 +8,9 @@ import { LABEL_CLS } from './Controls'
|
|||
*
|
||||
* 旧站滑杆散在 ModelCenter / Timeline 里各自写 height:5px + accent-color,
|
||||
* 值只出现在 label 里,拖动时看不到反馈。这里把「值」和「尺子」绑在一起。
|
||||
* 滑杆本体是 primitives/Slider(Radix)——原生 `<input type=range>` 只有
|
||||
* 轨道粗细、滑块直径、已填充段全是系统画的(模型抽屉里那根绿色系统滑块),
|
||||
* 命中区也只有 5px,拖动要先瞄准。
|
||||
*/
|
||||
export function Slider({ value, min = 0, max = 1, step = 0.01, onChange, label, hint, format, disabled, className }: {
|
||||
value: number
|
||||
|
|
@ -22,10 +26,11 @@ export function Slider({ value, min = 0, max = 1, step = 0.01, onChange, label,
|
|||
}) {
|
||||
return (
|
||||
<label className={cn('flex items-center gap-2 min-w-0', className)}>
|
||||
{label && <span className={cn('flex-none', LABEL_CLS)}>{label}</span>}
|
||||
<input type="range" min={min} max={max} step={step} value={value} disabled={disabled}
|
||||
onChange={(e) => onChange(Number(e.target.value))}
|
||||
className="min-w-0 flex-1 h-[5px] p-0 m-0 border-0 accent-[--c-accent-fill]" />
|
||||
{label && <span className={cn('flex-none min-w-(--label-w)', LABEL_CLS)}>{label}</span>}
|
||||
<RadixSlider value={[value]} min={min} max={max} step={step} disabled={disabled}
|
||||
onValueChange={([next]) => onChange(next)}
|
||||
aria-label={typeof label === 'string' ? label : undefined}
|
||||
className="min-w-0 flex-1" />
|
||||
<b className="flex-none w-[42px] text-right text-body font-mono text-ink-2 tabular-nums">
|
||||
{format ? format(value) : value}
|
||||
</b>
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
import { cn } from '../../lib/cn'
|
||||
|
||||
/** 开关(是/否二选一):勾选框表达不了「立刻生效」的开关语义,这里给一颗明确的滑块 */
|
||||
export function Toggle({ checked, onChange, disabled, label, className }: {
|
||||
checked: boolean; onChange: (next: boolean) => void; disabled?: boolean; label?: string; className?: string
|
||||
}) {
|
||||
return (
|
||||
<label className={cn('inline-flex flex-row items-center gap-2 text-caption text-ink-3 cursor-pointer flex-none whitespace-nowrap', disabled && 'opacity-40 cursor-not-allowed', className)}>
|
||||
<button type="button" role="switch" aria-checked={checked} disabled={disabled}
|
||||
onClick={() => onChange(!checked)}
|
||||
className={cn('relative w-[34px] h-[19px] flex-none rounded-pill border transition-colors',
|
||||
checked ? 'bg-accent-fill border-accent-fill' : 'bg-active border-line-strong')}>
|
||||
<i className={cn('absolute top-[2px] w-[13px] h-[13px] rounded-full bg-card transition-[left]', checked ? 'left-[17px]' : 'left-[2px]')} />
|
||||
</button>
|
||||
{label}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
|
@ -8,5 +8,4 @@ export * from './Overlay'
|
|||
export * from './Steps'
|
||||
export * from './Rows'
|
||||
export * from './Tabs'
|
||||
export * from './Toggle'
|
||||
export * from './Slider'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
export * from './use-async'
|
||||
export * from './use-polling'
|
||||
export * from './use-outside-click'
|
||||
export * from './use-local-storage'
|
||||
export * from './use-auto-refresh'
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
/** 点击(或 Esc)落在 ref 之外时回调:下拉、弹出菜单、抽屉的统一收口方式 */
|
||||
import { useEffect, type RefObject } from 'react'
|
||||
|
||||
export function useOutsideClick(ref: RefObject<HTMLElement | null>, onOutside: () => void, active = true) {
|
||||
useEffect(() => {
|
||||
if (!active) return
|
||||
const onDown = (event: MouseEvent | TouchEvent) => {
|
||||
const node = ref.current
|
||||
if (!node) return
|
||||
if (!node.contains(event.target as Node)) onOutside()
|
||||
}
|
||||
const onKey = (event: KeyboardEvent) => { if (event.key === 'Escape') onOutside() }
|
||||
document.addEventListener('mousedown', onDown)
|
||||
document.addEventListener('touchstart', onDown)
|
||||
document.addEventListener('keydown', onKey)
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', onDown)
|
||||
document.removeEventListener('touchstart', onDown)
|
||||
document.removeEventListener('keydown', onKey)
|
||||
}
|
||||
}, [ref, onOutside, active])
|
||||
}
|
||||
|
|
@ -45,6 +45,7 @@ import {
|
|||
FilePick, FormGrid, FormRow, Grid, LINK_CLS, Modal, MONO, MUTED, MUTED_MONO, Notice, PageHead, Pager, Panel, PanelHead,
|
||||
Row, SectionTitle, Spinner, Tag, TagGroup, TEXTAREA_TALL, ViewBtn
|
||||
} from '../components/ui'
|
||||
import { Checkbox } from '../components/primitives'
|
||||
|
||||
type AssetType = 'human' | 'scene' | 'voice'
|
||||
type ViewMode = 'grid' | 'list' | 'media'
|
||||
|
|
@ -1187,9 +1188,8 @@ export default function AssetLibrary() {
|
|||
className={cn('relative flex flex-col gap-[5px] p-[7px_7px_8px] rounded-[10px] bg-card border border-emphasis',
|
||||
selectedMedia.has(media.id) && 'border-accent-line shadow-[0_0_0_1px_var(--c-accent-tint)]')}>
|
||||
<label title="勾选后可批量删除(Shift 范围选择)" className={cn(PICK, 'left-[12px] top-[12px]')}>
|
||||
<input type="checkbox" checked={selectedMedia.has(media.id)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onChange={(e) => toggleMedia(media, idx, (e.nativeEvent as MouseEvent).shiftKey)} />
|
||||
<Checkbox checked={selectedMedia.has(media.id)}
|
||||
onClick={(e) => { e.stopPropagation(); toggleMedia(media, idx, e.shiftKey) }} />
|
||||
</label>
|
||||
<MediaThumb item={wallQueue[idx]} size="sm" radius={8} queue={wallQueue} index={idx}
|
||||
title={`${media.name || media.kind_label} · ${media.owner_name}`} />
|
||||
|
|
@ -1236,10 +1236,8 @@ export default function AssetLibrary() {
|
|||
row.duplicate_of?.length && 'border-warn-line')}>
|
||||
<label className="contents max-short:hidden"
|
||||
title={isSelected(row) ? '取消选择' : '勾选后可批量引入 / 打标签 / 删除(Shift 范围选择)'}>
|
||||
<input type="checkbox" checked={isSelected(row)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onChange={(e) => toggleSelect(row, idx, (e.nativeEvent as MouseEvent).shiftKey)}
|
||||
className="self-center flex-none w-[14px] h-[14px] m-0 accent-accent cursor-pointer" />
|
||||
<Checkbox checked={isSelected(row)} className="self-center cursor-pointer"
|
||||
onClick={(e) => { e.stopPropagation(); toggleSelect(row, idx, e.shiftKey) }} />
|
||||
</label>
|
||||
<Portrait name={row.name} sm />
|
||||
<div className="row-main min-w-0">
|
||||
|
|
@ -1315,9 +1313,8 @@ export default function AssetLibrary() {
|
|||
row.duplicate_of?.length && 'border-warn-line')}>
|
||||
<label className={PICK}
|
||||
title={isSelected(row) ? '取消选择' : '勾选后可批量引入 / 打标签 / 删除(Shift 范围选择)'}>
|
||||
<input type="checkbox" checked={isSelected(row)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onChange={(e) => toggleSelect(row, idx, (e.nativeEvent as MouseEvent).shiftKey)} />
|
||||
<Checkbox checked={isSelected(row)}
|
||||
onClick={(e) => { e.stopPropagation(); toggleSelect(row, idx, e.shiftKey) }} />
|
||||
</label>
|
||||
<div className="flex items-start gap-2.5 pl-[22px] min-w-0">
|
||||
<Portrait name={row.name} />
|
||||
|
|
@ -2000,7 +1997,7 @@ function MediaTile({ media, size = 'sm', radius = 7, width, queue, index, onRemo
|
|||
/** 缩略图左上角的勾选框:压在图上,所以自带一层半透明底板 */
|
||||
const PICK = 'absolute left-2 top-2 z-[3] grid place-items-center w-[21px] h-[21px] m-0 p-0 rounded-[6px] '
|
||||
+ 'bg-[color-mix(in_srgb,var(--c-bg-shell)_74%,transparent)] '
|
||||
+ '[&>input]:w-[13px] [&>input]:h-[13px] [&>input]:m-0 [&>input]:p-0'
|
||||
+ '[&>[role=checkbox]]:w-[13px] [&>[role=checkbox]]:h-[13px]'
|
||||
/** 缩略图右上角的删除叉:不能压住 MediaThumb 左下的版本角标 */
|
||||
const MEDIA_REMOVE = 'absolute right-[3px] top-[3px] grid place-items-center w-5 h-5 p-0 rounded-full '
|
||||
+ 'border border-danger-line text-danger-bright text-[15px] leading-none hover:bg-danger-line '
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { Checkbox } from '../../components/primitives'
|
||||
|
||||
const QUEUE_STATUSES = ['planned', 'queued', 'running', 'retrying', 'succeeded', 'failed', 'cancelled', 'skipped']
|
||||
const QUEUE_KINDS = ['generate_shot', 'voiceover', 'qc_shot', 'compose', 'import', 'asset']
|
||||
|
|
@ -233,9 +234,9 @@ export default function Dispatch() {
|
|||
{(plan?.shots || []).map((s: any) => (
|
||||
<tr key={s.shot_id}>
|
||||
<td className={cellCenter}>
|
||||
<input type="checkbox" className="w-auto" aria-label={`选择镜头 ${s.order_index}`}
|
||||
checked={shotIds.includes(s.shot_id)} disabled={s.action === 'skip' && !switches.force}
|
||||
onChange={() => toggleShot(s.shot_id)} />
|
||||
<Checkbox className="mx-auto" aria-label={`选择镜头 ${s.order_index}`}
|
||||
checked={shotIds.includes(s.shot_id)} disabled={s.action === 'skip' && !switches.force}
|
||||
onCheckedChange={() => toggleShot(s.shot_id)} />
|
||||
</td>
|
||||
<td><b>#{s.order_index}</b> {s.title}<div className={MUTED_MONO}>shot#{s.shot_id}</div></td>
|
||||
<td><Tag tone={s.action === 'enqueue' ? 'ok' : s.action === 'needs_attention' ? 'bad' : 'warn'}>{actionLabel(s.action)}</Tag></td>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import {
|
|||
import { useSystemStore } from '../../stores/system'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { Checkbox } from '../../components/primitives'
|
||||
|
||||
type GenType = 'human' | 'scene' | 'voice'
|
||||
type PanelKey = GenType | 'project'
|
||||
|
|
@ -1345,20 +1346,20 @@ export default function Library() {
|
|||
const PICKED = 'border-l-2 border-l-accent-line -ml-[12px] pl-[10px] rounded-[6px] bg-accent-tint'
|
||||
|
||||
/**
|
||||
* 卡片 / 表格行首的裸勾选框(.lib-pick)。
|
||||
* 卡片 / 表格行首的勾选框(.lib-pick):primitives/Checkbox。
|
||||
*
|
||||
* 不放可见文字,选的是谁由 aria-label 说明;Shift 连选读的是原生事件的
|
||||
* shiftKey,所以把 onChange 的 nativeEvent 原样交给上层的 togglePick,
|
||||
* 别在这里换算成布尔值。(受控 checkbox 必须挂 onChange,只写 onClick 会被
|
||||
* React 当成只读字段,每个渲染周期往控制台刷一条 error。)
|
||||
* 不放可见文字,选的是谁由 aria-label 说明;Shift 连选读的是**鼠标事件**的 shiftKey,
|
||||
* 而 Radix 的 onCheckedChange 不带事件(键盘 Space 也会走到它),所以 Shift 判定挂在
|
||||
* onClick 上——Radix 先调用我们的 onClick 再决定翻转,中间 stopPropagation 不影响它切换。
|
||||
* 尺寸来自 --check-size,不再是 accent-color 染出来的系统绿块。
|
||||
*/
|
||||
function PickBox({ checked, label, className, onToggle }: {
|
||||
checked: boolean; label: string; className?: string; onToggle: (ev?: { shiftKey?: boolean }) => void
|
||||
}) {
|
||||
return (
|
||||
<input type="checkbox" checked={checked} aria-label={label}
|
||||
onChange={(e) => onToggle(e.nativeEvent as MouseEvent)}
|
||||
className={cn('flex-none w-[14px] h-[14px] m-0 accent-accent cursor-pointer', className)} />
|
||||
<Checkbox checked={checked} aria-label={label}
|
||||
onClick={(e) => onToggle(e)}
|
||||
className={cn('cursor-pointer', className)} />
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import {
|
|||
buttonCls, cellCenter, cellRight, cellWrap, CloseButton, DRAWER_ACTIONS, DRAWER_BODY,
|
||||
DRAWER_HEAD
|
||||
} from '../../components/ui'
|
||||
import { Checkbox, floatingLayerOpen } from '../../components/primitives'
|
||||
|
||||
type ViewMode = 'grid' | 'table'
|
||||
type InspectorTab = 'shot' | 'assets' | 'prompt' | 'output'
|
||||
|
|
@ -1031,6 +1032,8 @@ export default function Storyboard() {
|
|||
if (ev.key === 'Escape') {
|
||||
// 预览器自己处理 Esc,别连带把检查器也关掉
|
||||
if (live.current.previewIsOpen) return
|
||||
// 抽屉/检查器里的下拉、菜单开着时,这一下是收浮层,不是关检查器
|
||||
if (floatingLayerOpen()) return
|
||||
if (!typing) {
|
||||
setShowImport(false)
|
||||
void fns.current.closeInspector()
|
||||
|
|
@ -1344,9 +1347,8 @@ export default function Storyboard() {
|
|||
s.id === selectedId && checked.has(s.id) && '[&>td]:bg-accent-tint',
|
||||
dragOver === s.id && '[&>td]:border-t [&>td]:border-dashed [&>td]:border-sky [&>td]:bg-hover')}>
|
||||
<td onClick={(ev) => ev.stopPropagation()}>
|
||||
<input type="checkbox" checked={checked.has(s.id)}
|
||||
aria-label={`选择镜头 ${s.code || s.order_index}`}
|
||||
onChange={(ev) => toggleCheck(s.id, (ev.nativeEvent as MouseEvent).shiftKey)} />
|
||||
<Checkbox checked={checked.has(s.id)} aria-label={`选择镜头 ${s.code || s.order_index}`}
|
||||
onClick={(ev) => toggleCheck(s.id, ev.shiftKey)} />
|
||||
</td>
|
||||
<td className={cellCenter}><Mono>{s.order_index}</Mono></td>
|
||||
<td>
|
||||
|
|
@ -1940,12 +1942,10 @@ function ShotCard({
|
|||
)}
|
||||
<span className={THUMB_ORDINAL}>{String(s.order_index).padStart(2, '0')}</span>
|
||||
<span className={THUMB_DUR}>{s.duration}s</span>
|
||||
<input type="checkbox" checked={picked}
|
||||
className="absolute top-[8px] right-[8px] h-[15px] w-[15px] cursor-pointer accent-(--c-accent)"
|
||||
title="勾选后可批量操作(快捷键 X)"
|
||||
aria-label={`选择镜头 ${s.code || s.order_index}`}
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
onChange={(ev) => onCheck((ev.nativeEvent as MouseEvent).shiftKey)} />
|
||||
<Checkbox checked={picked} title="勾选后可批量操作(快捷键 X)"
|
||||
className="absolute top-[8px] right-[8px] cursor-pointer"
|
||||
aria-label={`选择镜头 ${s.code || s.order_index}`}
|
||||
onClick={(ev) => { ev.stopPropagation(); onCheck(ev.shiftKey) }} />
|
||||
{s.output_url
|
||||
? <Tag size="sm" tone="ok" className="absolute bottom-2 left-[7px]">已生成</Tag>
|
||||
: (s.mode !== 't2v' && !s.keyframe_url
|
||||
|
|
|
|||
|
|
@ -173,6 +173,26 @@
|
|||
--tag-px: var(--tag-px-main);
|
||||
--tag-gap: var(--tag-gap-main);
|
||||
--tag-text: var(--tag-text-main);
|
||||
/* 字段标签列宽(ui/Controls.tsx 的 Field)。
|
||||
症状:同一张表单里「显示名」的输入框和「角色」的输入框左边缘差 8px——
|
||||
标签是 auto 宽的,中文标签 2~5 字,控件起点自然跟着字数漂。
|
||||
做法:表单作用域(FormRow)把标签列钉成 var(--field-label-w),
|
||||
同行/同列的所有控件共用一条左边界;筛选条这类贴边排版由 Ctlbar 把它压回 0
|
||||
(= minmax(0,max-content),回到标签挨着控件的老样子)。
|
||||
取 66px 是量出来的:全站 193 个行内字段标签的 p90 是 62px,
|
||||
比它长的(「覆盖负面提示词(可选)」这类)由 minmax(--,max-content) 自己撑开,
|
||||
宁可那一格控件右移,也不把标题截断。 */
|
||||
--field-label-w: 66px;
|
||||
/* 勾选框边长(primitives/Checkbox)。原生 checkbox 在 macOS 是 14px 系统绿圆角块、
|
||||
在 Windows 是方角,同一张表里并排就是两套控件;换成自绘后尺寸收成这一个令牌,
|
||||
触摸档抬到 18px(仍然小于 --ctl-h-md,不会把行高顶开)。 */
|
||||
--check-size: 14px;
|
||||
/* 标签列宽的作用域开关(不是尺寸,尺寸是上面的 --field-label-w)。
|
||||
默认 0px = 「标签挨着控件排」,这是筛选条/工具条要的;
|
||||
FormRow 在自己的作用域里把它抬到 var(--field-label-w),整表单共用一条控件左边界。
|
||||
写成开关而不是让 Field 直接读 --field-label-w,是为了让 Ctlbar 这类
|
||||
容器有明确的「压回」动作,而不是靠继承顺序碰运气。 */
|
||||
--label-w: 0px;
|
||||
/* 裸 <select> 的下拉箭头:base.css 把 select 的 appearance 抹掉了,
|
||||
不自己画就变成一个「没有 ▼ 的文本框」(分页条的「每页」正是这样)。
|
||||
几何与 components/forms/Caret.tsx 完全一致,只有颜色跟着主题翻。 */
|
||||
|
|
@ -183,7 +203,12 @@
|
|||
--nex-ctl: var(--ctl-h);
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
:root { --ctl-h-main: 40px; --ctl-h-md: 36px }
|
||||
:root {
|
||||
--ctl-h-main: 40px; --ctl-h-md: 36px;
|
||||
/* 手机档一行只有一个字段,标签列没有对齐对象,直接挨着控件排 */
|
||||
--field-label-w: 0px;
|
||||
--check-size: 18px;
|
||||
}
|
||||
}
|
||||
/* 浅色主题下箭头要更深一档,否则在白底上几乎看不见 */
|
||||
[data-theme="light"] {
|
||||
|
|
@ -336,9 +361,14 @@
|
|||
/* 动效 */
|
||||
--animate-spin-slow: nex-spin .8s linear infinite;
|
||||
--animate-pulse-soft: nex-pulse 1.6s ease-in-out infinite;
|
||||
/* 弹层出现:只做淡入。面板向上翻边时靠 transform:translateY(-100%) 定位,
|
||||
/* 弹层出现:下拉面板只做淡入。面板向上翻边时靠 transform:translateY(-100%) 定位,
|
||||
位移类动画会和它打架(面板会跳一下)。 */
|
||||
--animate-fade-in: nex-fade-in .12s ease-out;
|
||||
/* 抽屉 / 模态(Radix Dialog)的入场:位移写在 translate / scale 这两个独立属性上,
|
||||
不碰 transform——Tailwind v4 的定位(模态的 -translate-x-1/2)走的也是 translate,
|
||||
关键帧里再动 transform 才会互相覆盖。 */
|
||||
--animate-sheet-in: nex-sheet-in .18s cubic-bezier(.22,.8,.32,1);
|
||||
--animate-pop-in: nex-pop-in .14s ease-out;
|
||||
|
||||
/* 项目总控台(LLM 编排)的四个状态动画。
|
||||
它们表达的是「服务端还在干活」,不是装饰:控制台一打开就要让人看出
|
||||
|
|
@ -352,6 +382,8 @@
|
|||
|
||||
@keyframes nex-spin { to { transform: rotate(360deg) } }
|
||||
@keyframes nex-fade-in { from { opacity: 0 } }
|
||||
@keyframes nex-sheet-in { from { opacity: 0; translate: 24px 0 } }
|
||||
@keyframes nex-pop-in { from { opacity: 0; scale: .98 } }
|
||||
@keyframes nex-pulse { 50% { opacity: .45 } }
|
||||
@keyframes nex-agent-in { from { opacity: 0; transform: translateY(8px) } }
|
||||
@keyframes nex-agent-pulse {
|
||||
|
|
|
|||
Loading…
Reference in New Issue