durationCell.tsx 829 B

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