diamondStatus.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import styled from '@emotion/styled';
  2. import {IconDiamond} from 'sentry/icons';
  3. import {SVGIconProps} from 'sentry/icons/svgIcon';
  4. import {ColorOrAlias} from 'sentry/utils/theme';
  5. interface DiamondStatusProps extends React.HTMLAttributes<HTMLDivElement> {
  6. /**
  7. * Color of the diamond
  8. */
  9. color: ColorOrAlias;
  10. /**
  11. * Icon component to render inside of the diamond
  12. */
  13. icon: React.ComponentType<SVGIconProps>;
  14. }
  15. /**
  16. * A status indicator that renders a icon within a diamond
  17. */
  18. function DiamondStatus({color, icon: Icon, ...props}: DiamondStatusProps) {
  19. return (
  20. <StatusWrapper role="presentation" color={color} {...props}>
  21. <DiamondBackground color={color} />
  22. <Icon color="white" />
  23. </StatusWrapper>
  24. );
  25. }
  26. export {DiamondStatus};
  27. const DiamondBackground = styled(IconDiamond)`
  28. width: 36px;
  29. height: 36px;
  30. `;
  31. const StatusWrapper = styled('div')<{color: ColorOrAlias}>`
  32. width: 36px;
  33. height: 36px;
  34. position: relative;
  35. svg:last-child {
  36. width: 16px;
  37. z-index: 2;
  38. position: absolute;
  39. top: 0;
  40. bottom: 0;
  41. left: 0;
  42. right: 0;
  43. margin: auto;
  44. }
  45. `;