bruno/renderer/components/ResponsePane/ResponseSize/index.js

21 lines
508 B
JavaScript
Raw Normal View History

import React from 'react';
import StyledWrapper from './StyledWrapper';
2022-01-01 20:39:54 +01:00
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 (
2022-01-01 19:42:38 +01:00
<StyledWrapper className="mt-3 ml-4">
2022-01-01 20:39:54 +01:00
{sizeToDisplay}
</StyledWrapper>
)
};
export default ResponseSize;