Files
dify/web/app/components/app-sidebar/app-info/app-info-trigger.tsx
yyh af7d5e60b4 feat(ui): scaffold @langgenius/dify-ui and migrate design tokens (#35256)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-15 13:11:20 +00:00

68 lines
2.3 KiB
TypeScript

import type { App, AppSSO } from '@/types/app'
import { cn } from '@langgenius/dify-ui/cn'
import { RiEqualizer2Line } from '@remixicon/react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import AppIcon from '../../base/app-icon'
import { getAppModeLabel } from './app-mode-labels'
type AppInfoTriggerProps = {
appDetail: App & Partial<AppSSO>
expand: boolean
onClick: () => void
}
const AppInfoTrigger = ({ appDetail, expand, onClick }: AppInfoTriggerProps) => {
const { t } = useTranslation()
const modeLabel = getAppModeLabel(appDetail.mode, t)
return (
<button
type="button"
onClick={onClick}
className="block w-full"
aria-label={!expand ? `${appDetail.name} - ${modeLabel}` : undefined}
>
<div className="flex flex-col gap-2 rounded-lg p-1 hover:bg-state-base-hover">
<div className="flex items-center gap-1">
<div className={cn(!expand && 'ml-1')}>
<AppIcon
size={expand ? 'large' : 'small'}
iconType={appDetail.icon_type}
icon={appDetail.icon}
background={appDetail.icon_background}
imageUrl={appDetail.icon_url}
/>
</div>
{expand && (
<div className="ml-auto flex items-center justify-center rounded-md p-0.5">
<div className="flex h-5 w-5 items-center justify-center">
<RiEqualizer2Line className="h-4 w-4 text-text-tertiary" />
</div>
</div>
)}
</div>
{!expand && (
<div className="flex items-center justify-center">
<div className="flex h-5 w-5 items-center justify-center rounded-md p-0.5">
<RiEqualizer2Line className="h-4 w-4 text-text-tertiary" />
</div>
</div>
)}
{expand && (
<div className="flex flex-col items-start gap-1">
<div className="flex w-full">
<div className="truncate system-md-semibold whitespace-nowrap text-text-secondary">{appDetail.name}</div>
</div>
<div className="system-2xs-medium-uppercase whitespace-nowrap text-text-tertiary">
{getAppModeLabel(appDetail.mode, t)}
</div>
</div>
)}
</div>
</button>
)
}
export default React.memo(AppInfoTrigger)