dify/web/app/components/plugins/card/base/description.tsx

32 lines
683 B
TypeScript
Raw Normal View History

2024-10-10 10:40:26 +08:00
import type { FC } from 'react'
import React, { useMemo } from 'react'
import cn from '@/utils/classnames'
type Props = {
className?: string
text: string
descriptionLineRows: number
}
const Description: FC<Props> = ({
className,
text,
descriptionLineRows,
}) => {
const lineClassName = useMemo(() => {
if (descriptionLineRows === 1)
2024-10-10 17:47:04 +08:00
return 'h-4 truncate'
2024-10-10 10:40:26 +08:00
else if (descriptionLineRows === 2)
2024-10-10 17:47:04 +08:00
return 'h-8 line-clamp-2'
2024-10-10 10:40:26 +08:00
else
2024-10-10 17:47:04 +08:00
return 'h-12 line-clamp-3'
2024-10-10 10:40:26 +08:00
}, [descriptionLineRows])
return (
<div className={cn('text-text-tertiary system-xs-regular', lineClassName, className)}>
{text}
</div>
)
}
export default Description