You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractStatelessAvatar.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // @flow
  2. import { PureComponent } from 'react';
  3. export type Props = {
  4. /**
  5. * Color of the (initials based) avatar, if needed.
  6. */
  7. color?: string,
  8. /**
  9. * Initials to be used to render the initials based avatars.
  10. */
  11. initials?: string,
  12. /**
  13. * Callback to signal the failure of the loading of the URL.
  14. */
  15. onAvatarLoadError?: Function,
  16. /**
  17. * Expected size of the avatar.
  18. */
  19. size?: number;
  20. /**
  21. * The URL of the avatar to render.
  22. */
  23. url?: ?string | Object
  24. };
  25. /**
  26. * Implements an abstract stateless avatar component that renders an avatar purely from what gets passed through
  27. * props.
  28. */
  29. export default class AbstractStatelessAvatar<P: Props> extends PureComponent<P> {
  30. /**
  31. * Checks if the passed prop is a loaded icon or not.
  32. *
  33. * @param {string? | Object?} iconProp - The prop to check.
  34. * @returns {boolean}
  35. */
  36. _isIcon(iconProp: ?string | ?Object): boolean {
  37. return Boolean(iconProp) && (typeof iconProp === 'object' || typeof iconProp === 'function');
  38. }
  39. }