Skip to content

Commit

Permalink
[Upload] fix upload put into form width when theme=single-input (#1999)
Browse files Browse the repository at this point in the history
* fix(upload): theme=single-input width

* feat: update common
  • Loading branch information
chaishi authored Jan 3, 2023
1 parent d609227 commit 4179b63
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/upload/themes/normal-file.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent } from '@vue/composition-api';
import { defineComponent, computed } from '@vue/composition-api';
import {
CloseIcon as TdCloseIcon,
TimeFilledIcon as TdTimeFilledIcon,
Expand Down Expand Up @@ -36,9 +36,12 @@ const NormalFile = defineComponent({
CloseCircleFilledIcon: TdCloseCircleFilledIcon,
});

const uploadPrefix = `${props.classPrefix}-upload`;
const uploadPrefix = computed(() => `${props.classPrefix}-upload`);

const classes = computed(() => [`${uploadPrefix.value}__single`, `${uploadPrefix.value}__single-${props.theme}`]);

return {
classes,
uploadPrefix,
icons,
};
Expand Down Expand Up @@ -138,10 +141,9 @@ const NormalFile = defineComponent({
},

render() {
const classes = [`${this.uploadPrefix}__single`, `${this.uploadPrefix}__single-${this.theme}`];
const fileListDisplay = renderTNodeJSX(this, 'fileListDisplay', { params: { files: this.displayFiles } });
return (
<div class={classes}>
<div class={this.classes}>
{this.theme === 'file-input' && this.renderFilePreviewAsInput()}

{this.$scopedSlots.default?.(null)}
Expand Down
10 changes: 9 additions & 1 deletion src/upload/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ export default defineComponent({
},
}));

const uploadClasses = computed(() => [
`${classPrefix.value}-upload`,
{
[`${classPrefix.value}-upload--theme-${props.theme}`]: props.theme === 'file-input',
},
]);

return {
...uploadData,
commonDisplayFileProps,
dragProps,
uploadClasses,
};
},

Expand Down Expand Up @@ -190,7 +198,7 @@ export default defineComponent({

render() {
return (
<div class={`${this.classPrefix}-upload`}>
<div class={this.uploadClasses}>
<input
ref="inputRef"
type="file"
Expand Down

0 comments on commit 4179b63

Please sign in to comment.