fileSize.tsx 615 B

1234567891011121314151617181920212223242526272829
  1. import styled from '@emotion/styled';
  2. import {formatBytesBase2, formatBytesBase10} from 'sentry/utils';
  3. import getDynamicText from 'sentry/utils/getDynamicText';
  4. type Props = {
  5. bytes: number;
  6. base?: 2 | 10;
  7. className?: string;
  8. };
  9. function FileSize(props: Props) {
  10. const {className, bytes, base} = props;
  11. return (
  12. <Span className={className}>
  13. {getDynamicText({
  14. value: base === 10 ? formatBytesBase10(bytes) : formatBytesBase2(bytes),
  15. fixed: 'xx KB',
  16. })}
  17. </Span>
  18. );
  19. }
  20. const Span = styled('span')`
  21. font-variant-numeric: tabular-nums;
  22. `;
  23. export default FileSize;