diff --git a/index.d.ts b/index.d.ts index 5619e4d..f3bd08c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -42,11 +42,11 @@ export interface ReactAvatarProps { /** * The alt attribute used on the avatar img tag. If not set we will fallback to either name or value */ - alt?: string; + alt?: string | boolean; /** * The title attribute used on the avatar img tag. If not set we will fallback to either name or value */ - title?: string; + title?: string | boolean; /** * Used in combination with `name` and `value`. Give the background a fixed color with a hex like for example #FF0000 */ diff --git a/src/components/image.js b/src/components/image.js index a3f7b4c..157c8c2 100644 --- a/src/components/image.js +++ b/src/components/image.js @@ -8,7 +8,10 @@ export default class AvatarImage extends React.PureComponent { static propTypes = { - alt: PropTypes.string, + alt: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.bool + ]), title: PropTypes.oneOfType([ PropTypes.string, PropTypes.bool diff --git a/src/utils.js b/src/utils.js index a7c4255..d86a735 100644 --- a/src/utils.js +++ b/src/utils.js @@ -169,7 +169,7 @@ function setGroupedTimeout(fn, ttl) { export function getNullableText(...args) { for (const arg of args) { - if (arg) + if (arg || arg === '') return arg; if (arg === false || arg === null)