badge.tsx 837 B

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