UNPKG

3.01 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _react = _interopRequireDefault(require("react"));
9
10var _propTypes = _interopRequireDefault(require("prop-types"));
11
12var _withStyles = require("../helpers/withStyles");
13
14var _Shimmer = _interopRequireDefault(require("./Shimmer"));
15
16var _reactWithStyles = require("react-with-styles");
17
18function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
20function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
21
22function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
24var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
25 inline: _propTypes.default.bool,
26 large: _propTypes.default.bool,
27 loading: _propTypes.default.bool,
28 micro: _propTypes.default.bool,
29 small: _propTypes.default.bool,
30 source: _propTypes.default.string,
31 square: _propTypes.default.string
32});
33
34var Avatar = function Avatar(_ref) {
35 var css = _ref.css,
36 inline = _ref.inline,
37 large = _ref.large,
38 loading = _ref.loading,
39 micro = _ref.micro,
40 small = _ref.small,
41 source = _ref.source,
42 square = _ref.square,
43 styles = _ref.styles;
44 return _react.default.createElement("div", css(styles.avatar, inline && styles.avatar_inline, large && styles.avatar_large, micro && styles.avatar_micro, small && styles.avatar_small, square && styles.avatar_square, {
45 backgroundImage: "url(".concat(source, ")")
46 }), loading && _react.default.createElement(_Shimmer.default, {
47 width: "100%",
48 height: "100%"
49 }));
50};
51
52Avatar.propTypes = propTypes;
53var AvatarWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
54 var color = _ref2.color,
55 units = _ref2.units,
56 radius = _ref2.radius;
57 return {
58 avatar: {
59 borderRadius: '50%',
60 overflow: 'hidden',
61 width: units(3.5),
62 height: units(3.5),
63 backgroundSize: 'cover',
64 backgroundColor: color.gray,
65 backgroundPosition: 'center'
66 },
67 avatar_inline: {
68 display: 'inline-block'
69 },
70 avatar_micro: {
71 width: units(1.5),
72 height: units(1.5)
73 },
74 avatar_small: {
75 width: units(2.5),
76 height: units(2.5)
77 },
78 avatar_large: {
79 width: units(5),
80 height: units(5)
81 },
82 avatar_square: {
83 borderRadius: radius
84 }
85 };
86})(Avatar);
87var _default = AvatarWithStyles;
88exports.default = _default;
\No newline at end of file