UNPKG

2.93 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.Root = exports.Initials = exports.Avatar = void 0;
7
8var _index = require("../styles/index.js");
9
10function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
11
12function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
14function _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; }
15
16function getSize(props) {
17 var $size = props.$size,
18 $theme = props.$theme;
19 var defaultSize = $theme.sizing.scale1000;
20 var size = $size || defaultSize;
21 return $theme.sizing[size] || size;
22}
23
24var Avatar = (0, _index.styled)('img', function (props) {
25 var themedSize = getSize(props);
26 return {
27 borderTopLeftRadius: '50%',
28 borderTopRightRadius: '50%',
29 borderBottomRightRadius: '50%',
30 borderBottomLeftRadius: '50%',
31 boxSizing: 'border-box',
32 display: 'block',
33 height: themedSize,
34 width: themedSize,
35 objectFit: 'cover'
36 };
37});
38exports.Avatar = Avatar;
39Avatar.displayName = "Avatar";
40var Initials = (0, _index.styled)('div', function (props) {
41 return _objectSpread({}, props.$theme.typography.font300, {
42 color: props.$theme.colors.mono100,
43 alignItems: 'center',
44 display: 'flex',
45 justifyContent: 'center',
46 height: '100%'
47 });
48});
49exports.Initials = Initials;
50Initials.displayName = "Initials";
51var Root = (0, _index.styled)('div', function (props) {
52 var $didImageFailToLoad = props.$didImageFailToLoad;
53 var themedSize = getSize(props);
54 return {
55 backgroundColor: $didImageFailToLoad ? props.$theme.colors.primary : null,
56 borderTopLeftRadius: '50%',
57 borderTopRightRadius: '50%',
58 borderBottomRightRadius: '50%',
59 borderBottomLeftRadius: '50%',
60 boxSizing: 'border-box',
61 display: 'inline-block',
62 // image previously set the root height/width
63 // since image is not rendered, set the height/width
64 height: $didImageFailToLoad ? themedSize : null,
65 width: $didImageFailToLoad ? themedSize : null
66 };
67});
68exports.Root = Root;
69Root.displayName = "Root";
\No newline at end of file