badge.tsx 805 B

12345678910111213141516171819202122232425262728293031
  1. import styled from '@emotion/styled';
  2. import space from 'sentry/styles/space';
  3. import type {Theme} from 'sentry/utils/theme';
  4. interface Props extends React.HTMLAttributes<HTMLSpanElement> {
  5. text?: string | number | null;
  6. type?: keyof Theme['badge'];
  7. }
  8. const Badge = styled(({children, text, ...props}: Props) => (
  9. <span {...props}>{children ?? text}</span>
  10. ))<Props>`
  11. display: inline-block;
  12. height: 20px;
  13. min-width: 20px;
  14. line-height: 20px;
  15. border-radius: 20px;
  16. padding: 0 5px;
  17. margin-left: ${space(0.5)};
  18. font-size: 75%;
  19. font-weight: 600;
  20. text-align: center;
  21. color: ${p => p.theme.badge[p.type ?? 'default'].color};
  22. background: ${p => p.theme.badge[p.type ?? 'default'].background};
  23. transition: background 100ms linear;
  24. position: relative;
  25. `;
  26. export default Badge;