Skip to content

Commit fed6fa0

Browse files
committed
[REF]: Hide size formatted if not set or false
1 parent 56fa572 commit fed6fa0

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

src/files-ui/components/file-card/FileCard.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => {
147147
videoUrl
148148
);
149149
//The size formatted and rounded in 2 decimals
150-
const sizeFormatted: string = localSize
151-
? fileSizeFormater(localSize)
152-
: "0 KB";
150+
const sizeFormatted: string | undefined = fileSizeFormater(localSize);
153151

154152
//alwaysActive
155153
const [showInfo, setShowInfo] = React.useState<boolean>(false);

src/files-ui/components/file-mosaic/components/FileMosaicInfoLayer/FileMosaicInfoLayerProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export type FileMosaicInfoLayerProps = {
88
onCloseInfo?:Function;
99

1010
localName: string;
11-
sizeFormatted: string;
11+
sizeFormatted?: string;
1212
localType?: string;
1313
}

src/files-ui/components/file-mosaic/components/FileMosaicMainLayer.tsx/FileMosaicMainLayer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = (
1414
props: FileMosaicMainLayerProps
1515
) => {
1616
const {
17-
darkMode,deleteIcon,
17+
darkMode,
18+
deleteIcon,
1819
downloadIcon,
1920
imageIcon,
2021
infoIcon,
@@ -52,7 +53,9 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = (
5253
uploadStatus={uploadStatus}
5354
localization={localization}
5455
/>
55-
{isActive && <FileMosaicSize sizeFormatted={sizeFormatted} />}
56+
{isActive && sizeFormatted && (
57+
<FileMosaicSize sizeFormatted={sizeFormatted} />
58+
)}
5659
</div>
5760
<div className="file-mosaic-footer-right">
5861
{isActive && (

src/files-ui/components/file-mosaic/components/FileMosaicMainLayer.tsx/FileMosaicMainLayerProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface FileMosaicMainLayerProps {
1010
uploadStatus?: UPLOADSTATUS;
1111
localization?: Localization;
1212

13-
sizeFormatted: string;
13+
sizeFormatted?: string;
1414

1515
imageIcon: boolean;
1616
onSee: ((imageSource: string | undefined) => void) | undefined;

src/files-ui/components/file-mosaic/components/file-mosaic/FileMosaic.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
6565
onDoubleClick,
6666
onClick,
6767
onRightClick,
68-
smartImgFit="orientation",
68+
smartImgFit = "orientation",
6969
} = props;
70-
//localizers
71-
70+
//localizers
7271

7372
//ref for anchor download element
7473
const downloadRef = React.useRef<HTMLAnchorElement>(null);
@@ -116,10 +115,7 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
116115
);
117116

118117
//The size formatted and rounded in 2 decimals
119-
const sizeFormatted: string = localSize
120-
? fileSizeFormater(localSize)
121-
: "0 KB";
122-
118+
const sizeFormatted: string| undefined = fileSizeFormater(localSize);
123119
//alwaysActive
124120
const [showInfo, setShowInfo] = React.useState<boolean>(false);
125121

@@ -210,7 +206,6 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
210206
onAbort?.(id);
211207
};
212208

213-
214209
if (isReady)
215210
return (
216211
<div

src/files-ui/core/utils/fileSizeFormatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* Gives a XX.XX format in Bytes KB, MB, GB or TB
33
* @param fileSize file size to give format in Bytes
44
*/
5-
export const fileSizeFormater = (fileSize?: number): string => {
5+
export const fileSizeFormater = (fileSize?: number | false): string| undefined => {
66
let result = "";
77
if (!fileSize) {
8-
return 0 + " Bytes";
8+
return undefined;
99
}
1010
if (fileSize < 1024) {
1111
result = fileSize + " Bytes"

0 commit comments

Comments
 (0)