From 0805a2b50c28adebaaa256295f4c46585602c66d Mon Sep 17 00:00:00 2001 From: Danial Soheili <33312687+ds1371dani@users.noreply.github.com> Date: Tue, 31 Jan 2023 10:01:34 +0330 Subject: [PATCH] Feat/upload list shape (#40134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 💄 STYLE: add **picture-circle** to `listType` * 📖 DOC: update API table * Update components/upload/index.en-US.md Co-authored-by: lijianan <574980606@qq.com> * Update components/upload/index.zh-CN.md Co-authored-by: lijianan <574980606@qq.com> * Update components/upload/Upload.tsx Co-authored-by: Amumu * 👌 IMPROVE: classNames * 👌 IMPROVE: add missing className * 📖 DOC: update Upload demo for icons * 👌 IMPROVE: classNames order * 🧪 TEST: update snapshots * 👌 IMPROVE: Upload list classNames & snapshots * 📖 DOC: add new demo & revert previous ones * Update components/upload/index.zh-CN.md Co-authored-by: Amumu * Update components/upload/index.en-US.md Co-authored-by: Amumu * Update components/upload/index.zh-CN.md Co-authored-by: Amumu --------- Co-authored-by: lijianan <574980606@qq.com> Co-authored-by: Amumu --- components/upload/Upload.tsx | 7 +- components/upload/UploadList/ListItem.tsx | 19 +- components/upload/UploadList/index.tsx | 9 +- .../__snapshots__/demo-extend.test.ts.snap | 446 ++++++++++++++++-- .../__tests__/__snapshots__/demo.test.ts.snap | 422 +++++++++++++++-- components/upload/demo/avatar.tsx | 35 +- components/upload/demo/file-type.tsx | 2 +- components/upload/demo/picture-circle.md | 7 + components/upload/demo/picture-circle.tsx | 79 ++++ components/upload/index.en-US.md | 3 +- components/upload/index.zh-CN.md | 3 +- components/upload/interface.tsx | 2 +- components/upload/style/picture.ts | 24 +- 13 files changed, 931 insertions(+), 127 deletions(-) create mode 100644 components/upload/demo/picture-circle.md create mode 100644 components/upload/demo/picture-circle.tsx diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index c71d49b657c9..c90476172927 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -428,12 +428,15 @@ const InternalUpload: React.ForwardRefRenderFunction = (pr const uploadButton = renderUploadButton(children ? undefined : { display: 'none' }); - if (listType === 'picture-card') { + if (listType === 'picture-card' || listType === 'picture-circle') { return wrapSSR( {iconNode}; - if (listType === 'picture' || listType === 'picture-card') { + if (listType === 'picture' || listType === 'picture-card' || listType === 'picture-circle') { if (mergedStatus === 'uploading' || (!file.thumbUrl && !file.url)) { const uploadingClassName = classNames({ [`${prefixCls}-list-item-thumbnail`]: true, @@ -161,7 +161,7 @@ const ListItem = React.forwardRef( locale.downloadFile, ) : null; - const downloadOrDelete = listType !== 'picture-card' && ( + const downloadOrDelete = listType !== 'picture-card' && listType !== 'picture-circle' && ( ) : null; - const pictureCardActions = listType === 'picture-card' && mergedStatus !== 'uploading' && ( - - {previewIcon} - {mergedStatus === 'done' && downloadIcon} - {removeIcon} - - ); + const pictureCardActions = (listType === 'picture-card' || listType === 'picture-circle') && + mergedStatus !== 'uploading' && ( + + {previewIcon} + {mergedStatus === 'done' && downloadIcon} + {removeIcon} + + ); const { getPrefixCls } = React.useContext(ConfigContext); const rootPrefixCls = getPrefixCls(); diff --git a/components/upload/UploadList/index.tsx b/components/upload/UploadList/index.tsx index 5939f9627890..36af24e5cb30 100644 --- a/components/upload/UploadList/index.tsx +++ b/components/upload/UploadList/index.tsx @@ -48,7 +48,7 @@ const InternalUploadList: React.ForwardRefRenderFunction { - if (listType !== 'picture' && listType !== 'picture-card') { + if (listType !== 'picture' && listType !== 'picture-card' && listType !== 'picture-circle') { return; } (items || []).forEach((file: InternalUploadFile) => { @@ -107,7 +107,7 @@ const InternalUploadList: React.ForwardRefRenderFunction : ; if (listType === 'picture') { icon = isLoading ? : fileIcon; - } else if (listType === 'picture-card') { + } else if (listType === 'picture-card' || listType === 'picture-circle') { icon = isLoading ? locale.uploading : fileIcon; } return icon; @@ -172,7 +172,8 @@ const InternalUploadList: React.ForwardRefRenderFunction = { @@ -194,7 +195,7 @@ const InternalUploadList: React.ForwardRefRenderFunction -
- - -
- -
+ - -