errorPanel.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import styled from '@emotion/styled';
  2. import {IconWarning} from 'sentry/icons';
  3. import {space} from 'sentry/styles/space';
  4. import {DEEMPHASIS_COLOR_NAME} from 'sentry/views/dashboards/widgets/bigNumberWidget/settings';
  5. import type {StateProps} from 'sentry/views/dashboards/widgets/common/types';
  6. import {X_GUTTER, Y_GUTTER} from './settings';
  7. interface ErrorPanelProps {
  8. error: StateProps['error'];
  9. }
  10. export function ErrorPanel({error}: ErrorPanelProps) {
  11. return (
  12. <Panel>
  13. <NonShrinkingWarningIcon color={DEEMPHASIS_COLOR_NAME} size="md" />
  14. <ErrorText>{error?.toString()}</ErrorText>
  15. </Panel>
  16. );
  17. }
  18. const Panel = styled('div')<{height?: string}>`
  19. container-type: size;
  20. container-name: error-panel;
  21. position: absolute;
  22. inset: 0;
  23. padding: ${X_GUTTER} ${Y_GUTTER};
  24. display: flex;
  25. gap: ${space(1)};
  26. overflow: hidden;
  27. color: ${p => p.theme[DEEMPHASIS_COLOR_NAME]};
  28. `;
  29. const NonShrinkingWarningIcon = styled(IconWarning)`
  30. flex-shrink: 0;
  31. `;
  32. const ErrorText = styled('span')`
  33. font-size: ${p => p.theme.fontSizeSmall};
  34. @container error-panel (min-width: 360px) {
  35. font-size: ${p => p.theme.fontSizeMedium};
  36. }
  37. `;