nex_animation/frontend/src/app/layout/AppBar.tsx

59 lines
3.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* 顶部应用栏:品牌在左,流程控制台居中,账号胶囊 / 模式 / 手册固定在右上。
*
* · 结构:外壳是 flex-wrap:wrap 的容器,顶栏 flex:0 0 100% 独占第一行,
* 侧栏与主内容留在第二行 —— 这样侧栏/主区的 sticky 与 calc() 宽度
* 规则继续生效,不必逐条搬运。
* · align-content:flex-start 必需:默认 stretch 会把多出来的竖向高度
* 平摊给两行,短页面下顶栏会被拉成几百像素高。
* · 品牌块与工具块都 flex:1 1 0 各占一半剩余空间(内容再各自贴左/贴右),
* 中间的控制台因此严格落在「页面正中」。不要用 margin-inline:auto:
* 那样居中的是「品牌右缘↔工具左缘」这段空档的中点,工具区比品牌区宽
* ~140px,控制台会整体偏左 70px。
* · z-66:高于分镜检查器(60),保证面板展开时右上角胶囊/模式始终可用;
* 低于抽屉(100)、灯箱(220)、下拉弹层(400),不打断真正的模态。
*/
import { NavLink } from 'react-router-dom'
import { cn } from '../../lib/cn'
import { toggleTheme, useAppliedTheme } from '../../stores/theme'
import PipelineConsole from './PipelineConsole'
import UserMenu from './UserMenu'
/** 顶栏控件(手册 / 主题 / 胶囊)统一高度取 --nex-ctl,即规范主尺寸 */
const TOOL = 'group flex h-(--nex-ctl) flex-none items-center gap-1.5 rounded-[8px] border border-line bg-transparent px-[9px] text-body font-semibold text-ink-3 whitespace-nowrap no-underline hover:border-line-bright hover:bg-hover hover:text-ink max-nav:justify-center max-nav:w-(--nex-ctl) max-nav:px-0 max-nav:[&>span]:hidden'
export function AppBar({ projectId }: { projectId: string }) {
const isLight = useAppliedTheme() === 'light'
return (
<header className="sticky top-0 z-66 flex min-h-(--nex-bar) w-full flex-none basis-full flex-nowrap items-center gap-2.5 border-b border-emphasis bg-shell px-4 py-[7px]">
<NavLink to="/" title="长视频编导平台 · 返回项目总览"
className="flex flex-[1_1_0] min-w-max items-center justify-start gap-[9px] text-body tracking-[.6px] text-ink no-underline">
<b aria-hidden="true" className="grid h-[31px] w-[31px] place-items-center rounded-tile bg-accent-fill text-[17px] text-on-accent">N</b>
<span className="max-nav:hidden">长视频编导平台
<small className="mt-[3px] block text-tiny font-normal tracking-[.4px] text-faint">NEX ANIMATION STUDIO</small>
</span>
</NavLink>
{projectId && <PipelineConsole projectId={projectId} />}
<div className="flex flex-[1_1_0] items-center justify-end gap-[7px]">
<a className={cn(TOOL)} href="/help" target="_blank" rel="noopener" title="使用手册 · 全流程操作截图(新窗口打开)">
<i aria-hidden="true" className="text-ui not-italic text-muted group-hover:text-accent">🛈</i><span>手册</span>
</a>
<button type="button" className={cn(TOOL, 'cursor-pointer')} onClick={toggleTheme}
aria-label={'切换明暗主题,当前为' + (isLight ? '浅色' : '深色')}
title={'显示模式:' + (isLight ? '浅色' : '深色') + '(⌘/Ctrl+Shift+L 切换)'}>
<i aria-hidden="true"
className={cn('grid h-[17px] w-[17px] place-items-center rounded-[6px] bg-accent-fill text-tiny text-on-accent transition-transform duration-[180ms]',
isLight && 'rotate-[-18deg]')}>{isLight ? '☀' : '☾'}</i>
<span>{isLight ? '浅色' : '深色'}</span>
</button>
<UserMenu />
</div>
</header>
)
}
export default AppBar