statusIndicator.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import styled from '@emotion/styled';
  2. import Tooltip from 'sentry/components/tooltip';
  3. type Props = {
  4. status: string;
  5. tooltipTitle: string;
  6. };
  7. /**
  8. * A badge/indicator at the beginning of the row that displays
  9. * the color of the status level (Warning, Error, Success, etc)
  10. *
  11. */
  12. function StatusIndicator({status, tooltipTitle}: Props) {
  13. let color: string = 'error';
  14. if (status === 'muted') {
  15. color = 'muted';
  16. } else if (status === 'info') {
  17. color = 'info';
  18. } else if (status === 'warning') {
  19. color = 'warning';
  20. } else if (status === 'success' || status === 'resolved') {
  21. color = 'success';
  22. }
  23. return (
  24. <Tooltip title={tooltipTitle} skipWrapper>
  25. <StatusLevel color={color} />
  26. </Tooltip>
  27. );
  28. }
  29. export default StatusIndicator;
  30. const StatusLevel = styled('div')<{color: string}>`
  31. position: absolute;
  32. left: -1px;
  33. width: 9px;
  34. height: 15px;
  35. border-radius: 0 3px 3px 0;
  36. background-color: ${p => p.theme.alert[p.color].background};
  37. & span {
  38. display: block;
  39. width: 9px;
  40. height: 15px;
  41. }
  42. `;