playerDOMAlert.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import styled from '@emotion/styled';
  2. import {Button} from 'sentry/components/button';
  3. import {IconClose, IconInfo} from 'sentry/icons';
  4. import {t} from 'sentry/locale';
  5. import {space} from 'sentry/styles/space';
  6. import useDismissAlert from 'sentry/utils/useDismissAlert';
  7. const LOCAL_STORAGE_KEY = 'replay-player-dom-alert-dismissed';
  8. function PlayerDOMAlert() {
  9. const {dismiss, isDismissed} = useDismissAlert({key: LOCAL_STORAGE_KEY});
  10. if (isDismissed) {
  11. return null;
  12. }
  13. return (
  14. <DOMAlertContainer data-test-id="player-dom-alert">
  15. <DOMAlert>
  16. <StyledIconInfo size="xs" />
  17. <div>{t('Right click & inspect your app’s DOM with your browser')}</div>
  18. <DismissButton
  19. priority="link"
  20. size="sm"
  21. icon={<IconClose size="xs" />}
  22. aria-label={t('Close Alert')}
  23. onClick={dismiss}
  24. />
  25. </DOMAlert>
  26. </DOMAlertContainer>
  27. );
  28. }
  29. export default PlayerDOMAlert;
  30. const DOMAlertContainer = styled('div')`
  31. position: absolute;
  32. bottom: ${space(1)};
  33. left: 0;
  34. width: 100%;
  35. text-align: center;
  36. font-size: ${p => p.theme.fontSizeMedium};
  37. pointer-events: none;
  38. `;
  39. const DOMAlert = styled('div')`
  40. display: inline-flex;
  41. align-items: flex-start;
  42. justify-items: center;
  43. padding: ${space(1)} ${space(2)};
  44. margin: 0 ${space(1)};
  45. color: ${p => p.theme.white};
  46. background-color: ${p => p.theme.blue400};
  47. border-radius: ${p => p.theme.borderRadius};
  48. gap: 0 ${space(1)};
  49. line-height: 1em;
  50. `;
  51. const StyledIconInfo = styled(IconInfo)`
  52. margin-top: 1px;
  53. min-width: 12px; /* Prevnt the icon from scaling down whenever text wraps */
  54. `;
  55. const DismissButton = styled(Button)`
  56. color: ${p => p.theme.white};
  57. pointer-events: all;
  58. &:hover {
  59. color: ${p => p.theme.white};
  60. opacity: 0.5;
  61. }
  62. `;