dify/web/app/components/workflow/shortcuts-name.tsx

38 lines
868 B
TypeScript
Raw Normal View History

2024-05-09 17:18:51 +08:00
import { memo } from 'react'
import { getKeyboardKeyNameBySystem } from './utils'
import cn from '@/utils/classnames'
2024-05-09 17:18:51 +08:00
type ShortcutsNameProps = {
keys: string[]
className?: string
textColor?: 'default' | 'secondary'
2024-05-09 17:18:51 +08:00
}
const ShortcutsName = ({
keys,
className,
textColor = 'default',
2024-05-09 17:18:51 +08:00
}: ShortcutsNameProps) => {
return (
<div className={cn(
'flex items-center gap-0.5',
2024-05-09 17:18:51 +08:00
className,
)}>
{
keys.map(key => (
<div
key={key}
className={cn(
'system-kbd flex h-4 min-w-4 items-center justify-center rounded-[4px] bg-components-kbd-bg-gray capitalize',
textColor === 'secondary' && 'text-text-tertiary',
)}
2024-05-09 17:18:51 +08:00
>
{getKeyboardKeyNameBySystem(key)}
</div>
))
}
</div>
)
}
export default memo(ShortcutsName)