playerRelativeTime.tsx 893 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import styled from '@emotion/styled';
  2. import DateTime from 'sentry/components/dateTime';
  3. import Tooltip from 'sentry/components/tooltip';
  4. import {showPlayerTime} from './utils';
  5. type Props = {
  6. relativeTime: number | undefined;
  7. timestamp: string | undefined;
  8. };
  9. const PlayerRelativeTime = ({relativeTime, timestamp}: Props) => {
  10. if (!timestamp || !relativeTime) {
  11. return <div />;
  12. }
  13. return (
  14. <Tooltip
  15. title={<DateTime date={timestamp} seconds />}
  16. disabled={!timestamp}
  17. skipWrapper
  18. disableForVisualTest
  19. underlineColor="gray300"
  20. showUnderline
  21. >
  22. <Value>{showPlayerTime(timestamp, relativeTime)}</Value>
  23. </Tooltip>
  24. );
  25. };
  26. const Value = styled('p')`
  27. color: ${p => p.theme.subText};
  28. font-size: ${p => p.theme.fontSizeSmall};
  29. font-variant-numeric: tabular-nums;
  30. margin-bottom: 0;
  31. `;
  32. export default PlayerRelativeTime;