From 9c9d5c3a03831ec381cbffe4a7cf68af5a04855e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Wed, 20 Apr 2022 16:05:18 +0300 Subject: [PATCH] Fixed #2401 - FileUpload | Customizable Icons --- api-generator/components/fileupload.js | 18 +++++++++++++++ src/components/fileupload/FileUpload.d.ts | 12 ++++++++++ src/components/fileupload/FileUpload.vue | 28 +++++++++++++++++------ src/views/fileupload/FileUploadDoc.vue | 18 +++++++++++++++ 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/api-generator/components/fileupload.js b/api-generator/components/fileupload.js index 33ec8e724..7b30267b4 100644 --- a/api-generator/components/fileupload.js +++ b/api-generator/components/fileupload.js @@ -113,6 +113,24 @@ const FileUploadProps = [ default: "true", description: "Whether to cancel the upload button." }, + { + name: "chooseIcon", + type: "string", + default: "pi pi-plus", + description: "Icon of the choose button." + }, + { + name: "uploadIcon", + type: "string", + default: "pi pi-upload", + description: "Icon of the upload button." + }, + { + name: "cancelIcon", + type: "string", + default: "pi pi-times", + description: "Icon of the cancel button." + }, { name: "style", type: "any", diff --git a/src/components/fileupload/FileUpload.d.ts b/src/components/fileupload/FileUpload.d.ts index d01fbab3a..24f3aef6c 100755 --- a/src/components/fileupload/FileUpload.d.ts +++ b/src/components/fileupload/FileUpload.d.ts @@ -178,6 +178,18 @@ export interface FileUploadProps { * Default value is true. */ showCancelButton?: boolean | undefined; + /** + * Icon of the choose button. + */ + chooseIcon?: string | undefined; + /** + * Icon of the upload button. + */ + uploadIcon?: string | undefined; + /** + * Icon of the cancel button. + */ + cancelIcon?: string | undefined; /** * Inline style of the component. */ diff --git a/src/components/fileupload/FileUpload.vue b/src/components/fileupload/FileUpload.vue index 2c69e8512..5b9a500b0 100755 --- a/src/components/fileupload/FileUpload.vue +++ b/src/components/fileupload/FileUpload.vue @@ -3,11 +3,11 @@
- + {{chooseButtonLabel}} - - + +
@@ -130,6 +130,18 @@ export default { type: Boolean, default: true }, + chooseIcon: { + type: String, + default: 'pi pi-plus' + }, + uploadIcon: { + type: String, + default: 'pi pi-upload' + }, + cancelIcon: { + type: String, + default: 'pi pi-times' + }, style: null, class: null }, @@ -424,11 +436,13 @@ export default { 'p-focus': this.focused }]; }, + advancedChooseIconClass() { + return ['p-button-icon p-button-icon-left pi-fw', this.chooseIcon]; + }, basicChooseButtonIconClass() { - return ['p-button-icon p-button-icon-left pi', { - 'pi-plus': !this.hasFiles || this.auto, - 'pi-upload': this.hasFiles && !this.auto - }]; + return ['p-button-icon p-button-icon-left', + !this.hasFiles || this.auto ? this.uploadIcon : this.chooseIcon + ]; }, basicChooseButtonLabel() { return this.auto ? this.chooseButtonLabel : (this.hasFiles ? this.files.map(f => f.name).join(', ') : this.chooseButtonLabel); diff --git a/src/views/fileupload/FileUploadDoc.vue b/src/views/fileupload/FileUploadDoc.vue index f1bafcbcf..f7ff080f4 100755 --- a/src/views/fileupload/FileUploadDoc.vue +++ b/src/views/fileupload/FileUploadDoc.vue @@ -222,6 +222,24 @@ myUploader(event) { true Whether to show the cancel button. + + chooseIcon + string + pi pi-plus + Icon of the choose button. + + + uploadIcon + string + pi pi-upload + Icon of the upload button. + + + cancelIcon + string + pi pi-times + Icon of the cancel button. + style any