您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AbstractStatelessAvatar.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  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. * Parses an icon out of a specially constructed icon URL and returns the icon name.
  32. *
  33. * @param {string?} url - The url to parse.
  34. * @returns {string?}
  35. */
  36. _parseIconUrl(url: ?string): ?string {
  37. const match = url && url.match(/icon:\/\/(.+)/i);
  38. return (match && match[1]) || undefined;
  39. }
  40. }