@pantheon-systems/design-toolkit-react
Version:
Pantheon's React Design Toolkit
77 lines (72 loc) • 3.17 kB
JavaScript
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
import _extends from '@babel/runtime/helpers/extends';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { faUser, faUsers } from '@fortawesome/pro-solid-svg-icons';
import PropTypes from 'prop-types';
import Icon from '../Icons/Icon.js';
import { FAIcon } from '../lib/customPropTypes.js';
import { jsx } from 'react/jsx-runtime';
var _excluded = ["icon", "imgAltText", "imgSrc", "size"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var avatarContainer = 'bg-gray-2 rounded-full text-gray-5 inline-flex justify-center items-center overflow-hidden text-center';
var fontSize = {
small: 'text-sm',
"default": 'text-base',
large: 'text-xl',
xlarge: 'text-2xl'
};
var heightWidth = {
small: 'h-4 w-4',
"default": 'h-6 w-6',
large: 'h-8 w-8',
xlarge: 'h-10 w-10'
};
var Avatar = function Avatar(_ref) {
var icon = _ref.icon,
imgAltText = _ref.imgAltText,
imgSrc = _ref.imgSrc,
size = _ref.size,
rest = _objectWithoutProperties(_ref, _excluded);
var avatar = /*#__PURE__*/jsx(Icon, _objectSpread({
alt: imgAltText,
icon: icon,
transform: "shrink-2"
}, rest));
if (imgSrc) {
avatar = /*#__PURE__*/jsx("img", _objectSpread({
alt: imgAltText,
className: "align-middle ".concat(heightWidth[size]),
src: imgSrc
}, rest));
}
return /*#__PURE__*/jsx("div", {
className: "".concat(avatarContainer, " ").concat(heightWidth[size], " ").concat(fontSize[size]),
children: avatar
});
};
Avatar.defaultProps = {
icon: faUser,
imgAltText: '',
imgSrc: undefined,
size: 'default'
};
Avatar.propTypes = {
icon: FAIcon,
imgAltText: PropTypes.string,
imgSrc: PropTypes.string,
size: PropTypes.oneOf(['small', 'default', 'large', 'xlarge'])
};
// Team variant
// TODO: no need for a unique React component, should be deprecated in favor of <Avatar />
var AvatarTeam = function AvatarTeam(_ref2) {
var props = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
return /*#__PURE__*/jsx(Avatar, _objectSpread({}, props));
};
AvatarTeam.defaultProps = {
icon: faUsers
};
var Avatar$1 = Avatar;
export { AvatarTeam, Avatar$1 as default };
//# sourceMappingURL=Avatar.js.map