signal-desktop/ts/components/conversation/media-gallery/DocumentListItem.tsx

58 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-01-03 11:55:46 -08:00
// Copyright 2018 Signal Messenger, LLC
2020-10-30 15:34:04 -05:00
// SPDX-License-Identifier: AGPL-3.0-only
2018-04-12 16:23:26 -04:00
import React from 'react';
2018-07-17 17:15:34 -07:00
import classNames from 'classnames';
2018-04-12 16:23:26 -04:00
import moment from 'moment';
import formatFileSize from 'filesize';
export type Props = {
// Required
timestamp: number;
// Optional
2019-01-14 13:49:58 -08:00
fileName?: string;
2018-04-12 16:23:26 -04:00
fileSize?: number;
2018-04-15 02:16:39 -04:00
onClick?: () => void;
shouldShowSeparator?: boolean;
};
2018-04-12 16:23:26 -04:00
export function DocumentListItem({
shouldShowSeparator = true,
fileName,
fileSize,
onClick,
timestamp,
}: Props): JSX.Element {
return (
<div
className={classNames(
'module-document-list-item',
shouldShowSeparator ? 'module-document-list-item--with-separator' : null
)}
>
2019-11-07 13:36:16 -08:00
<button
2020-09-14 12:51:27 -07:00
type="button"
2018-07-17 17:15:34 -07:00
className="module-document-list-item__content"
2020-09-14 12:51:27 -07:00
onClick={onClick}
>
2018-07-17 17:15:34 -07:00
<div className="module-document-list-item__icon" />
<div className="module-document-list-item__metadata">
<span className="module-document-list-item__file-name">
{fileName}
</span>
<span className="module-document-list-item__file-size">
2020-10-21 19:54:53 -04:00
{typeof fileSize === 'number'
? formatFileSize(fileSize, { round: 0 })
: ''}
2018-04-12 16:23:26 -04:00
</span>
</div>
2018-07-17 17:15:34 -07:00
<div className="module-document-list-item__date">
2018-04-12 17:22:26 -04:00
{moment(timestamp).format('ddd, MMM D, Y')}
2018-04-12 16:23:26 -04:00
</div>
2019-11-07 13:36:16 -08:00
</button>
</div>
);
2018-04-12 16:23:26 -04:00
}