Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AbstractStatelessAvatar.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. * Additional parameters to be passed to onAvatarLoadError function.
  18. */
  19. onAvatarLoadErrorParams?: Object,
  20. /**
  21. * Expected size of the avatar.
  22. */
  23. size?: number;
  24. /**
  25. * The URL of the avatar to render.
  26. */
  27. url?: ?string | Object
  28. };
  29. /**
  30. * Implements an abstract stateless avatar component that renders an avatar purely from what gets passed through
  31. * props.
  32. */
  33. export default class AbstractStatelessAvatar<P: Props> extends PureComponent<P> {
  34. /**
  35. * Checks if the passed prop is a loaded icon or not.
  36. *
  37. * @param {string? | Object?} iconProp - The prop to check.
  38. * @returns {boolean}
  39. */
  40. _isIcon(iconProp: ?string | ?Object): boolean {
  41. return Boolean(iconProp) && (typeof iconProp === 'object' || typeof iconProp === 'function');
  42. }
  43. }