Repository navigation
Expand file tree
/
Copy pathiniticon.min.js
More file actions
1 lines (1 loc) · 3.51 KB
/
Copy pathiniticon.min.js
File metadata and controls
1 lines (1 loc) · 3.51 KB
1
"use strict";function getBackgroundColor(props){var seed=props.seed,saturation=props.saturation,brightness=props.brightness,color=props.color;if(color)return color;var hue=Math.sin(seed);return hue=hue<0?-hue:hue,"hsl("+(hue=Math.round(359*hue)+1)+","+saturation+","+brightness+")"}function getFontSize(props){return props.single?props.size/1.7:(props.size-5)/2}function getInitials(props){var text=props.text,single=props.single;return null!==text&&"object"===(void 0===text?"undefined":_typeof(text))?text:text.indexOf(" ")>0&&!single?text.split(" ")[0].charAt(0)+text.split(" ")[1].charAt(0):text.charAt(0)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},defaultProps={size:75,saturation:"80%",brightness:"40%",color:!1,single:!1};"undefined"!=typeof exports&&(exports.getBackgroundColor=getBackgroundColor,exports.getFontSize=getFontSize,exports.getInitials=getInitials,exports.defaultProps=defaultProps);var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();if("undefined"!=typeof require)var React=require("react"),_require=require("./shared"),getBackgroundColor=_require.getBackgroundColor,getFontSize=_require.getFontSize,getInitials=_require.getInitials,defaultProps=_require.defaultProps,PropTypes=require("prop-types");var Initicon=function(_React$Component){function Initicon(){return _classCallCheck(this,Initicon),_possibleConstructorReturn(this,(Initicon.__proto__||Object.getPrototypeOf(Initicon)).apply(this,arguments))}return _inherits(Initicon,_React$Component),_createClass(Initicon,[{key:"render",value:function(){var props=this.props;return React.createElement("div",{style:{backgroundColor:getBackgroundColor(props),height:this.props.size+"px",width:this.props.size+"px",fontSize:getFontSize(props)+"px",lineHeight:this.props.size+"px",borderRadius:"50%",display:"inline-block",textAlign:"center",color:"#ffffff"}},getInitials(props))}}]),Initicon}(React.Component);Initicon.propTypes={text:PropTypes.any.isRequired,size:PropTypes.any.isRequired,seed:PropTypes.number,color:PropTypes.any,single:PropTypes.bool,saturation:PropTypes.string,brightness:PropTypes.string},Initicon.defaultProps=defaultProps,"undefined"!=typeof module&&(module.exports=Initicon);