Skip to content

Commit 62e867e

Browse files
chore: changing the download to be on the label
1 parent 4ccdda4 commit 62e867e

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

shesha-reactjs/src/components/fileUpload/index.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const FileUpload: FC<IFileUploadProps> = ({
7070
model: {
7171
layout: listType === 'thumbnail' && !isDragger,
7272
isDragger,
73+
hideFileName,
7374
},
7475
};
7576
const { styles } = useStyles(props);
@@ -150,11 +151,17 @@ export const FileUpload: FC<IFileUploadProps> = ({
150151
<DeleteOutlined title="Remove" />
151152
</a>
152153
)}
153-
{
154+
{isImageType(fileInfo?.type) ? (
154155
<a onClick={onPreview} style={{ color: color }}>
155156
<EyeOutlined title="Preview" />
156157
</a>
157-
}
158+
) : (
159+
hideFileName && (
160+
<a onClick={() => downloadFile({ fileId: fileInfo?.id, fileName: fileInfo?.name })} style={{ color: color }}>
161+
<DownloadOutlined title="Download" />
162+
</a>
163+
)
164+
)}
158165
</Space>
159166
);
160167
};
@@ -163,7 +170,7 @@ export const FileUpload: FC<IFileUploadProps> = ({
163170
const { type, name } = fileInfo;
164171
if (isImageType(type)) {
165172
if (listType === 'thumbnail' && !isDragger) {
166-
return <Image src={imageUrl} alt={name} preview={false} className={styles.thumbnailControls}/>;
173+
return <Image src={imageUrl} alt={name} preview={false} className={styles.thumbnailControls} />;
167174
}
168175
}
169176

@@ -175,7 +182,9 @@ export const FileUpload: FC<IFileUploadProps> = ({
175182
fileInfo && (
176183
<div className={styles.styledFileControls}>
177184
{iconRender(fileInfo)}
178-
<div className={styles.overlayThumbnailControls} style={{fontSize: '15px'}}>{fileControls('#fff')}</div>
185+
<div className={styles.overlayThumbnailControls} style={{ fontSize: '15px' }}>
186+
{fileControls('#fff')}
187+
</div>
179188
</div>
180189
)
181190
);
@@ -191,12 +200,14 @@ export const FileUpload: FC<IFileUploadProps> = ({
191200
<a title={file.name}>
192201
<Space>
193202
{isUploading ? (
194-
<span><SyncOutlined spin /></span>
203+
<span>
204+
<SyncOutlined spin />
205+
</span>
195206
) : (
196-
<>
197-
{(listType === 'text' || !hideFileName) && `${file.name} (${filesize(file.size)})`}
207+
<div className="thumbnail-item-name">
208+
{(listType === 'text' || !hideFileName) && <a onClick={() => downloadFile({ fileId: file.id, fileName: file.name })}>{`${file.name} (${filesize(file.size)})`}</a>}
198209
{showTextControls && fileControls(theme.application.primaryColor)}
199-
</>
210+
</div>
200211
)}
201212
</Space>
202213
</a>
@@ -239,7 +250,6 @@ export const FileUpload: FC<IFileUploadProps> = ({
239250
</Button>
240251
);
241252

242-
243253
const renderStub = () => {
244254
if (isDragger) {
245255
return (
@@ -249,11 +259,22 @@ export const FileUpload: FC<IFileUploadProps> = ({
249259
);
250260
}
251261

252-
return <div className={listType === 'thumbnail' ? 'ant-upload-list-item-name ant-upload-list-item-name-stub thumbnail-stub' : ''}>{uploadButton}</div>;
262+
return (
263+
<>
264+
<div
265+
className={
266+
listType === 'thumbnail' ? 'ant-upload-list-item-name ant-upload-list-item-name-stub thumbnail-stub' : ''
267+
}
268+
>
269+
{uploadButton}
270+
</div>
271+
{listType === 'thumbnail' ? <div className="thumbnail-item-name">File name</div> : null}
272+
</>
273+
);
253274
};
254275

255276
const renderUploader = () => {
256-
const antListType = listType === 'thumbnail' ? 'picture-card' : 'text';
277+
const antListType = listType === 'thumbnail' ? 'picture-card' : 'text';
257278
if (isDragger && allowUpload) {
258279
return (
259280
<Dragger {...fileProps}>

shesha-reactjs/src/components/fileUpload/styles/styles.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
4242

4343
} = style || {};
4444

45-
const { layout, isDragger } = model;
45+
const { layout, isDragger, hideFileName } = model;
4646

4747
const antUploadDragIcon = `${prefixCls}-upload-drag-icon`;
4848
const antUploadText = `${prefixCls}-upload-text`;
@@ -67,7 +67,6 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
6767
font-weight: ${fontWeight};
6868
text-align: ${textAlign};
6969
`;
70-
7170
const shaStoredFilesRenderer = cx(
7271
'sha-stored-files-renderer',
7372
css`
@@ -103,7 +102,7 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
103102
}
104103
105104
.ant-upload-list-picture-card {
106-
height: calc(var(--thumbnail-height) + ${fontSize} * 2 + 32px) !important;
105+
height: ${hideFileName ? 'var(--thumbnail-height) )' : `calc(var(--thumbnail-height) + ${fontSize} * 2 + 32px)`} !important;
107106
padding-bottom: 1rem;
108107
}
109108
@@ -138,12 +137,10 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
138137
.ant-upload-list-item-thumbnail {
139138
border-radius: ${borderRadius} !important;
140139
padding: 0 !important;
141-
background: ${background ?? backgroundImage ?? backgroundColor} !important;
142140
${commonBorderStyles}
143141
}
144142
145143
.ant-upload-list-item-name {
146-
display: block;
147144
${commonTextStyles}
148145
padding: 0 8px !important;
149146
width: ${(layout && width) ?? '54px'} !important;
@@ -153,6 +150,10 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
153150
max-width: 100%;
154151
}
155152
153+
.thumbnail-item-name{
154+
${commonTextStyles}
155+
}
156+
156157
.thumbnail-stub {
157158
display: flex;
158159
flex-direction: column;
@@ -201,6 +202,7 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
201202
}
202203
203204
.ant-upload-list-item-container {
205+
background: ${backgroundImage ?? (backgroundColor || '#fff')} !important;
204206
width: var(--thumbnail-width) !important;
205207
height: var(--thumbnail-height) !important;
206208
border-radius: ${borderRadius} !important;
@@ -258,17 +260,19 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
258260
padding: 4px;
259261
260262
.ant-space {
261-
display: grid !important;
262-
grid-template-columns: repeat(2, minmax(24px, auto)) !important;
263+
display: flex !important;
264+
flex-wrap: wrap !important;
265+
justify-content: center !important;
266+
align-items: center !important;
263267
gap: 4px !important;
264-
place-items: center !important;
265-
place-content: center !important;
268+
width: 100% !important;
266269
}
267270
268271
.ant-space-item {
269272
display: flex;
270273
justify-content: center;
271274
align-items: center;
275+
flex: 0 0 auto;
272276
}
273277
274278
a {

shesha-reactjs/src/designer-components/link/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const LinkComponent: IToolboxComponent<ILinkProps> = {
114114
return containerHolder();
115115
}
116116
return (
117-
<a href={href} target={target} className="sha-link" style={getStyle(style, data)}>
117+
<a href={href} target={target} className="sha-link">
118118
{containerHolder()}
119119
</a>
120120
);

0 commit comments

Comments
 (0)