jumpButtons.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import styled from '@emotion/styled';
  2. import {Button} from 'sentry/components/button';
  3. import {t} from 'sentry/locale';
  4. import toPixels from 'sentry/utils/number/toPixels';
  5. interface Props {
  6. jump: undefined | 'up' | 'down';
  7. onClick: () => void;
  8. tableHeaderHeight: number;
  9. }
  10. const offsetFromEdge = 5;
  11. export default function JumpButtons({jump, onClick, tableHeaderHeight}: Props) {
  12. if (jump === 'up') {
  13. return (
  14. <JumpButton
  15. onClick={onClick}
  16. aria-label={t('Jump Up')}
  17. priority="primary"
  18. size="xs"
  19. style={{top: toPixels(tableHeaderHeight + offsetFromEdge)}}
  20. >
  21. {t('↑ Jump to current timestamp')}
  22. </JumpButton>
  23. );
  24. }
  25. if (jump === 'down') {
  26. return (
  27. <JumpButton
  28. onClick={onClick}
  29. aria-label={t('Jump Down')}
  30. priority="primary"
  31. size="xs"
  32. style={{bottom: toPixels(offsetFromEdge)}}
  33. >
  34. {t('↓ Jump to current timestamp')}
  35. </JumpButton>
  36. );
  37. }
  38. return null;
  39. }
  40. const JumpButton = styled(Button)`
  41. position: absolute;
  42. justify-self: center;
  43. `;