add file sign and some refactoring
This commit is contained in:
1 parent
58bcd8b857
commit
3a1b4354db
14 files changed
+830
-118
No files matched your search
@@ -1,30 +0,0 @@
|
||||
import * as React from 'react'
|
||||
import { ext, size } from '../../lib/file'
|
||||
import { titleCase } from '../../lib/string'
|
||||
|
||||
export interface IDocumentListItemProps {
|
||||
title: string
|
||||
url: string
|
||||
imageUrl: string
|
||||
fileUrl: string
|
||||
fileName: string
|
||||
fileSize: number
|
||||
}
|
||||
|
||||
export const DocumentListItem: React.FC<IDocumentListItemProps> = props => (
|
||||
<div className="document-row">
|
||||
<a href={props.url} className="invisible">
|
||||
<div className="document-row__image">
|
||||
<img src={props.imageUrl} alt={props.title} />
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div className="document-row__file">
|
||||
<a href={props.url}>{titleCase(props.title)}</a>
|
||||
</div>
|
||||
|
||||
<div className="document-row__file-info">
|
||||
<a href={props.fileUrl} target="_blank">{ext(props.fileName)} ({size(props.fileSize)})</a>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
import s from './signature.module.css'
|
||||
|
||||
import { Sign } from '@/types'
|
||||
import { FiShield } from 'react-icons/fi'
|
||||
import Tooltip from 'rc-tooltip'
|
||||
|
||||
export type SignatureProps = Sign
|
||||
export const Signature: React.FC<SignatureProps> = props => {
|
||||
const content = (
|
||||
<ul className={s.signature}>
|
||||
<li>Дата и время подписания: {props.date}</li>
|
||||
<li>ФИО подписавшего документ: {props.person}</li>
|
||||
<li>Должность: {props.position}</li>
|
||||
<li>Уникальный программный ключ: {props.key}</li>
|
||||
</ul>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip overlayClassName={'hudozka'} placement="left" trigger={['click']} overlay={content}>
|
||||
<FiShield className={s.secure} size={20} />
|
||||
</Tooltip>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
.file {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
margin-bottom: var(--size-l);
|
||||
}
|
||||
|
||||
.image {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.name {
|
||||
margin-left: var(--size-m);
|
||||
flex-grow: 7;
|
||||
}
|
||||
|
||||
.info {
|
||||
flex-grow: 1;
|
||||
font-size: var(--font-size-second);
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import s from './filecard.module.css'
|
||||
|
||||
import Image from 'next/image'
|
||||
import { FileTokenData, Sign } from '@/types'
|
||||
import { size, ext } from '@/lib/file'
|
||||
import { getResizedUrl } from '@/lib/image'
|
||||
import { Signature } from './Signature'
|
||||
|
||||
export type FileCardProps = FileTokenData & {
|
||||
sign?: Sign
|
||||
}
|
||||
|
||||
export const FileCard: React.FC<FileCardProps> = props => {
|
||||
const fileSize = size(props.file_size)
|
||||
const format = ext(props.file_format)
|
||||
|
||||
return (
|
||||
<div className={s.file}>
|
||||
<a href={props.url} className="invisible">
|
||||
<div className={s.image}>
|
||||
<Image
|
||||
className={s.image}
|
||||
loader={({ src, width, quality }) => {
|
||||
return getResizedUrl(src, {
|
||||
width: 200,
|
||||
height: 200,
|
||||
n: 1,
|
||||
})
|
||||
}}
|
||||
src={props.image_url}
|
||||
width={100}
|
||||
height={100}
|
||||
objectFit={'contain'}
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div className={s.name}>
|
||||
<span style={{
|
||||
display: 'flex',
|
||||
}}>
|
||||
{!props.sign ? null : (
|
||||
<Signature
|
||||
{...props.sign}
|
||||
/>
|
||||
)}
|
||||
<a href={props.url}>{props.title}</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className={s.info}>
|
||||
<a href={props.file_url} target="_blank">
|
||||
{format} ({fileSize})
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
.secure {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.signature{
|
||||
list-style: none;
|
||||
}
|
||||
Reference in new issue
Block a user