bruno/renderer/components/ResponsePane/ResponseSize/index.js
2022-03-07 17:52:35 +05:30

21 lines
508 B
JavaScript

import React from 'react';
import StyledWrapper from './StyledWrapper';
const ResponseSize = ({size}) => {
let sizeToDisplay = ''
if(size > 1024 ) { // size is greater than 1kb
let kb = Math.floor(size / 1024);
let decimal = ((size % 1024) / 1024).toFixed(2) * 100;
sizeToDisplay = kb + '.' + decimal + 'KB';
} else {
sizeToDisplay = size + 'B'
}
return (
<StyledWrapper className="mt-3 ml-4">
{sizeToDisplay}
</StyledWrapper>
)
};
export default ResponseSize;