throughputCell.tsx 934 B

123456789101112131415161718192021222324252627282930313233
  1. import styled from '@emotion/styled';
  2. import {t} from 'sentry/locale';
  3. import {space} from 'sentry/styles/space';
  4. import {formatAbbreviatedNumber, formatPercentage} from 'sentry/utils/formatters';
  5. import {ComparisonLabel} from 'sentry/views/starfish/components/samplesTable/common';
  6. type Props = {
  7. delta?: number;
  8. throughputPerSecond?: number;
  9. };
  10. export default function ThroughputCell({throughputPerSecond, delta}: Props) {
  11. const throughput = throughputPerSecond ? throughputPerSecond.toFixed(2) : '--';
  12. return (
  13. <Container>
  14. <span>{`${formatAbbreviatedNumber(throughput)}/${t('s')}`}</span>
  15. {delta ? (
  16. <ComparisonLabel value={delta * -1}>
  17. {delta > 0 ? '+' : ''}
  18. {formatPercentage(delta)}
  19. </ComparisonLabel>
  20. ) : null}
  21. </Container>
  22. );
  23. }
  24. const Container = styled('div')`
  25. display: flex;
  26. width: 100%;
  27. justify-content: space-between;
  28. gap: ${space(1)};
  29. `;