* feat: model hub revamp UI * chore: model description - consistent markdown css * chore: add model versions dropdown * chore: integrate APIs - model sources * chore: update model display name * chore: lint fix * chore: page transition animation * feat: model search dropdown - deeplink * chore: bump cortex version * chore: add remote model sources * chore: model download state * chore: fix model metadata label * chore: polish model detail page markdown * test: fix test cases * chore: initialize default Hub model sources * chore: fix model stats * chore: clean up click outside and inside hooks * feat: change hub banner * chore: lint fix * chore: fix css long model id
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { memo } from 'react'
|
|
|
|
import { usePath } from '@/hooks/usePath'
|
|
|
|
import { toGigabytes } from '@/utils/converter'
|
|
|
|
import Icon from '../FileUploadPreview/Icon'
|
|
|
|
const DocMessage = ({
|
|
id,
|
|
metadata,
|
|
}: {
|
|
id: string
|
|
metadata: Record<string, unknown> | undefined
|
|
}) => {
|
|
const { onViewFile } = usePath()
|
|
|
|
return (
|
|
<div className="group/file bg-secondary relative mb-2 inline-flex w-60 cursor-pointer gap-x-3 overflow-hidden rounded-lg p-4">
|
|
<div
|
|
className="absolute left-0 top-0 z-20 hidden h-full w-full bg-black/20 opacity-50 group-hover/file:inline-block"
|
|
onClick={() => onViewFile(`${id}.pdf`)}
|
|
/>
|
|
|
|
<Icon type="pdf" />
|
|
<div className="w-full">
|
|
<h6 className="line-clamp-1 w-4/5 overflow-hidden font-medium">
|
|
{metadata && 'filename' in metadata
|
|
? (metadata.filename as string)
|
|
: id}
|
|
</h6>
|
|
<p className="text-[hsla(var(--text-secondary)] line-clamp-1 overflow-hidden truncate">
|
|
{metadata && 'size' in metadata
|
|
? toGigabytes(Number(metadata.size))
|
|
: id}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default memo(DocMessage)
|