@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
22 lines • 1.05 kB
JavaScript
import React from 'react';
import { MAX_INITIALS_PERSON, MAX_INITIALS_SPACE, TYPES } from './Avatar.constants';
/**
* The Initials component, rendering the passed in initials in a span
* and throws console warnings in case the initials length is too big for the
* specified type.
*/
var Initials = function (props) {
var initials = props.initials, type = props.type, className = props.className;
// Error handling for initials length
if (initials) {
type === TYPES.person &&
initials.length > MAX_INITIALS_PERSON &&
console.warn("Avatar with type person should not have more than ".concat(MAX_INITIALS_PERSON, " initials."));
type === TYPES.space &&
initials.length > MAX_INITIALS_SPACE &&
console.warn("Avatar with type space should not have more than ".concat(MAX_INITIALS_SPACE, " initials."));
}
return (React.createElement("span", { className: className, "aria-hidden": "true" }, initials));
};
export default Initials;
//# sourceMappingURL=Initials.js.map