circleIndicator.tsx 764 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import styled from '@emotion/styled';
  2. import {Theme} from 'sentry/utils/theme';
  3. const defaultProps = {
  4. enabled: true,
  5. size: 14,
  6. };
  7. type DefaultProps = Readonly<typeof defaultProps>;
  8. type Props = {
  9. color?: string;
  10. } & Partial<DefaultProps>;
  11. const getBackgroundColor = (p: Props & {theme: Theme}) => {
  12. if (p.color) {
  13. return `background: ${p.color};`;
  14. }
  15. return `background: ${p.enabled ? p.theme.success : p.theme.error};`;
  16. };
  17. const getSize = (p: Props) => `
  18. height: ${p.size}px;
  19. width: ${p.size}px;
  20. `;
  21. const CircleIndicator = styled('div')<Props>`
  22. display: inline-block;
  23. position: relative;
  24. border-radius: 50%;
  25. ${getSize};
  26. ${getBackgroundColor};
  27. `;
  28. CircleIndicator.defaultProps = defaultProps;
  29. export default CircleIndicator;