"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Root = exports.Avatar = void 0;

var _styles = require("../styles");

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
function getSize(props) {
  var $size = props.$size,
      $theme = props.$theme;
  var defaultSize = $theme.sizing.scale1000;
  var size = $size || defaultSize;
  return $theme.sizing[size] || size;
}

var Avatar = (0, _styles.styled)('img', function (props) {
  var themedSize = getSize(props);
  return {
    borderRadius: '50%',
    boxSizing: 'border-box',
    display: 'block',
    height: themedSize,
    width: themedSize
  };
});
exports.Avatar = Avatar;
var Root = (0, _styles.styled)('div', function (props) {
  var $didImageFailToLoad = props.$didImageFailToLoad;
  var themedSize = getSize(props);
  return {
    backgroundColor: props.$theme.colors.mono400,
    borderRadius: '50%',
    boxSizing: 'border-box',
    display: 'inline-block',
    // image previously set the root height/width
    // since image is not rendered, set the height/width
    height: $didImageFailToLoad ? themedSize : null,
    width: $didImageFailToLoad ? themedSize : null
  };
});
exports.Root = Root;