status.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import styled from '@emotion/styled';
  2. import {IconCheckmark, IconFire, IconWarning} from 'app/icons';
  3. import {t} from 'app/locale';
  4. import space from 'app/styles/space';
  5. import {Incident, IncidentStatus} from './types';
  6. type Props = {
  7. className?: string;
  8. incident: Incident;
  9. /**
  10. * Use inherited color for icons
  11. */
  12. disableIconColor?: boolean;
  13. };
  14. const Status = ({className, incident, disableIconColor}: Props) => {
  15. const {status} = incident;
  16. const isResolved = status === IncidentStatus.CLOSED;
  17. const isWarning = status === IncidentStatus.WARNING;
  18. const icon = isResolved ? (
  19. <IconCheckmark color={disableIconColor ? undefined : 'green300'} />
  20. ) : isWarning ? (
  21. <IconWarning color={disableIconColor ? undefined : 'orange400'} />
  22. ) : (
  23. <IconFire color={disableIconColor ? undefined : 'red300'} />
  24. );
  25. const text = isResolved ? t('Resolved') : isWarning ? t('Warning') : t('Critical');
  26. return (
  27. <Wrapper className={className}>
  28. <Icon>{icon}</Icon>
  29. {text}
  30. </Wrapper>
  31. );
  32. };
  33. export default Status;
  34. const Wrapper = styled('div')`
  35. display: grid;
  36. grid-auto-flow: column;
  37. align-items: center;
  38. grid-template-columns: auto 1fr;
  39. grid-gap: ${space(0.75)};
  40. `;
  41. const Icon = styled('span')`
  42. margin-bottom: -3px;
  43. `;