Files
gsfdc/demo-dify/dify/web/app/components/detail-sidebar/toggle-button.tsx
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

54 lines
1.7 KiB
TypeScript

import type { ReactNode } from 'react'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Kbd, KbdGroup } from '@langgenius/dify-ui/kbd'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { formatForDisplay } from '@tanstack/react-hotkeys'
import { useTranslation } from 'react-i18next'
import { DETAIL_SIDEBAR_TOGGLE_HOTKEY } from './hotkeys'
type DetailSidebarToggleButtonProps = {
expand: boolean
onToggle: () => void
className?: string
icon?: ReactNode
}
export function DetailSidebarToggleButton({
expand,
onToggle,
className,
icon,
}: DetailSidebarToggleButtonProps) {
const { t } = useTranslation(['layout'])
const label = expand
? t(($) => $['sidebar.collapseSidebar'], { ns: 'layout' })
: t(($) => $['sidebar.expandSidebar'], { ns: 'layout' })
return (
<Tooltip>
<TooltipTrigger
render={
<IconButton size="lg" aria-label={label} onClick={onToggle} className={className}>
<span aria-hidden className="inline-flex">
{icon ??
(expand ? (
<span className="i-ri-arrow-left-s-line size-4" />
) : (
<span className="i-ri-arrow-right-s-line size-4" />
))}
</span>
</IconButton>
}
/>
<TooltipContent side="right" className="flex items-center gap-1">
<span className="px-0.5">{label}</span>
<KbdGroup>
{formatForDisplay(DETAIL_SIDEBAR_TOGGLE_HOTKEY, { parts: true }).map((key) => (
<Kbd key={key}>{key}</Kbd>
))}
</KbdGroup>
</TooltipContent>
</Tooltip>
)
}