Files
2024-02-15 17:01:50 +00:00

73 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import styled from '@emotion/styled';
import {Button} from 'sentry/components/button';
import {IconClose, IconInfo} from 'sentry/icons';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import useDismissAlert from 'sentry/utils/useDismissAlert';
const LOCAL_STORAGE_KEY = 'replay-player-dom-alert-dismissed';
function PlayerDOMAlert() {
const {dismiss, isDismissed} = useDismissAlert({key: LOCAL_STORAGE_KEY});
if (isDismissed) {
return null;
}
return (
<DOMAlertContainer data-test-id="player-dom-alert">
<DOMAlert>
<StyledIconInfo size="xs" />
<div>{t('Right click & inspect your app’s DOM with your browser')}</div>
<DismissButton
priority="link"
size="sm"
icon={<IconClose />}
aria-label={t('Close Alert')}
onClick={dismiss}
/>
</DOMAlert>
</DOMAlertContainer>
);
}
export default PlayerDOMAlert;
const DOMAlertContainer = styled('div')`
position: absolute;
bottom: ${space(1)};
left: 0;
width: 100%;
text-align: center;
font-size: ${p => p.theme.fontSizeMedium};
pointer-events: none;
`;
const DOMAlert = styled('div')`
display: inline-flex;
align-items: flex-start;
justify-items: center;
padding: ${space(1)} ${space(2)};
margin: 0 ${space(1)};
color: ${p => p.theme.white};
background-color: ${p => p.theme.blue400};
border-radius: ${p => p.theme.borderRadius};
gap: 0 ${space(1)};
line-height: 1em;
`;
const StyledIconInfo = styled(IconInfo)`
margin-top: 1px;
min-width: 12px; /* Prevnt the icon from scaling down whenever text wraps */
`;
const DismissButton = styled(Button)`
color: ${p => p.theme.white};
pointer-events: all;
&:hover {
color: ${p => p.theme.white};
opacity: 0.5;
}
`;