backgroundAvatar.tsx 944 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {forwardRef} from 'react';
  2. import styled from '@emotion/styled';
  3. import {imageStyle} from 'sentry/components/avatar/styles';
  4. import theme from 'sentry/utils/theme';
  5. type Props = {
  6. forwardedRef?: React.Ref<SVGSVGElement>;
  7. round?: boolean;
  8. suggested?: boolean;
  9. };
  10. type BackgroundAvatarProps = React.ComponentProps<'svg'> & Props;
  11. /**
  12. * Creates an avatar placeholder that is used when showing multiple
  13. * suggested assignees
  14. */
  15. const BackgroundAvatar = styled(
  16. ({round: _round, forwardedRef, ...props}: BackgroundAvatarProps) => (
  17. <svg ref={forwardedRef} viewBox="0 0 120 120" {...props}>
  18. <rect x="0" y="0" width="120" height="120" rx="15" ry="15" fill={theme.purple100} />
  19. </svg>
  20. )
  21. )<Props>`
  22. ${imageStyle};
  23. `;
  24. BackgroundAvatar.defaultProps = {
  25. round: false,
  26. suggested: true,
  27. };
  28. export default forwardRef<SVGSVGElement, Props>((props, ref) => (
  29. <BackgroundAvatar forwardedRef={ref} {...props} />
  30. ));