Skip to content

Commit

Permalink
feat(file-upload-item): добавлен пропс download (#844)
Browse files Browse the repository at this point in the history
Co-authored-by: Pavel <Strizhakov>
  • Loading branch information
Rabamidab committed Oct 12, 2021
1 parent f021bbf commit db2a4ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/file-upload-item/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const fileProps = {
uploadDate: '22.01.2018',
size: 45000,
downloadLink: '/link',
download: 'новое_название_файла',
uploadStatus: 'SUCCESS' as FileStatuses,
showDelete: true,
};
Expand Down
16 changes: 14 additions & 2 deletions packages/file-upload-item/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export type FileUploadItemProps = {
*/
downloadLink?: string;

/**
* Рекомендует браузеру скачивать контент по ссылке.
* В проп может быть передано рекомендуемое название скачиваемого файла.
*/
download?: string | true;

/**
* Отображение кнопки удаления
*/
Expand Down Expand Up @@ -110,6 +116,7 @@ export const FileUploadItem: React.FC<FileUploadItemProps> = ({
icon: Icon = fileIcon(name),
uploadDate,
downloadLink,
download,
uploadStatus,
uploadPercent = 0,
error = uploadStatus === 'ERROR' ? 'Не удалось загрузить файл' : undefined,
Expand Down Expand Up @@ -157,15 +164,20 @@ export const FileUploadItem: React.FC<FileUploadItemProps> = ({
() => (
<div className={styles.name}>
{downloadLink ? (
<Link pseudo={true} href={downloadLink} onClick={handleDownload}>
<Link
pseudo={true}
href={downloadLink}
onClick={handleDownload}
download={download}
>
{name}
</Link>
) : (
name
)}
</div>
),
[downloadLink, handleDownload, name],
[downloadLink, handleDownload, download, name],
);

const showMeta = !showRestore && (!uploadStatus || uploadStatus === 'SUCCESS');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Object {
>
<a
class="component primary pseudo"
download="новое_название_файла"
href="/link"
>
<span
Expand Down Expand Up @@ -110,6 +111,7 @@ Object {
>
<a
class="component primary pseudo"
download="новое_название_файла"
href="/link"
>
<span
Expand Down

0 comments on commit db2a4ca

Please sign in to comment.