errorLevel.tsx 735 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import styled from '@emotion/styled';
  2. import {Level} from 'app/types';
  3. const DEFAULT_SIZE = '13px';
  4. function getLevelColor({level = '', theme}) {
  5. const COLORS = {
  6. error: theme.orange400,
  7. info: theme.blue300,
  8. warning: theme.orange300,
  9. fatal: theme.red300,
  10. sample: theme.purple300,
  11. };
  12. return `background-color: ${COLORS[level] || theme.orange400};`;
  13. }
  14. type Props = {
  15. size?: string;
  16. level?: Level;
  17. };
  18. const ErrorLevel = styled('span')<Props>`
  19. padding: 0;
  20. position: relative;
  21. width: ${p => p.size || DEFAULT_SIZE};
  22. height: ${p => p.size || DEFAULT_SIZE};
  23. text-indent: -9999em;
  24. display: inline-block;
  25. border-radius: 50%;
  26. flex-shrink: 0;
  27. ${getLevelColor}
  28. `;
  29. export default ErrorLevel;