@atlaskit/avatar
Version:
An avatar is a visual representation of a user or entity.
84 lines • 3.9 kB
JavaScript
/* avatar-content.tsx generated by @compiled/babel-plugin v0.36.1 */
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import "./avatar-content.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { forwardRef } from 'react';
import { fg } from '@atlaskit/platform-feature-flags';
import { useAvatarContent, useEnsureIsInsideAvatar } from './context';
var boxShadowCssVar = '--avatar-box-shadow';
var bgColorCssVar = '--avatar-bg-color';
var styles = {
root: "_19itglyw _12ji1r31 _1qu2glyw _12y31o36 _1reo15vq _18m915vq _v564ieh6 _1e0c1txw _kqswpfqs _4cvr1fhb _1bah1h6o _2lx21bp4 _80om1kw7 _6rthv77o _1pfhv77o _12l2v77o _ahbqv77o _85i5ze3t _1q51ze3t _y4tize3t _bozgze3t _t9ec1aqe _9v7aze3t _qc5o1p41 _z0ai1osq _18postnw _1hfk1j28 _aetrf705 _1peqidpf _11fnglyw _1ejjglyw _mizu194a _1ah3v77o _ra3xnqa1 _128m1bk5 _4dave4h9",
circle: "_2rko1q5u _14mj1q5u",
positionRelative: "_kqswh2mm",
disabled: "_80om13gf _1hfkvuon _1peqs237"
};
var unboundStyles = {
root: "_vchh1ntv _bfhkcxp3 _16qs1nhn",
interactive: "_80omtlke _4tpu1g4v _ez1ykb7n _gcm1182g _eeh8kb7n _jlxit94y"
};
var widthHeightMap = {
xsmall: "_1bsb7vkz _4t3i7vkz",
small: "_1bsb1tcg _4t3i1tcg",
medium: "_1bsbzwfg _4t3izwfg",
large: "_1bsb1ylp _4t3i1ylp",
xlarge: "_1bsb16xz _4t3i16xz",
xxlarge: "_1bsb1qr7 _4t3i1qr7"
};
var borderRadiusMap = {
xsmall: "_2rkoyh40 _14mjyh40",
small: "_2rkoyh40 _14mjyh40",
medium: "_2rko1l7b _14mj1l7b",
large: "_2rko1l7b _14mj1l7b",
xlarge: "_2rkoi2wt _14mji2wt",
xxlarge: "_2rko1crf _14mj1crf"
};
/**
* __Avatar content__
*
* Avatar content renders the avatar content. It can be composed with the Avatar component
* to create a custom avatar.
*
* - [Examples](https://atlassian.design/components/avatar/examples)
* - [Code](https://atlassian.design/components/avatar/code)
* - [Usage](https://atlassian.design/components/avatar/usage)
*/
export var AvatarContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
var children = _ref.children;
useEnsureIsInsideAvatar();
var _useAvatarContent = useAvatarContent(),
Container = _useAvatarContent.as,
appearance = _useAvatarContent.appearance,
avatarImage = _useAvatarContent.avatarImage,
_useAvatarContent$bor = _useAvatarContent.borderColor,
borderColor = _useAvatarContent$bor === void 0 ? fg('platform-component-visual-refresh') ? "var(--ds-surface, #FFFFFF)" : "var(--ds-surface-overlay, #FFFFFF)" : _useAvatarContent$bor,
href = _useAvatarContent.href,
isDisabled = _useAvatarContent.isDisabled,
label = _useAvatarContent.label,
onClick = _useAvatarContent.onClick,
contextRef = _useAvatarContent.ref,
tabIndex = _useAvatarContent.tabIndex,
target = _useAvatarContent.target,
testId = _useAvatarContent.testId,
size = _useAvatarContent.size,
stackIndex = _useAvatarContent.stackIndex;
var isInteractive = Boolean(onClick || href || isDisabled);
return /*#__PURE__*/React.createElement(Container, _extends({
style: _defineProperty(_defineProperty({}, bgColorCssVar, borderColor), boxShadowCssVar, "0 0 0 2px ".concat(borderColor)),
ref: ref || contextRef,
"aria-label": isInteractive ? label : undefined,
onClick: onClick,
tabIndex: tabIndex,
"data-testid": testId,
disabled: isDisabled,
type: Container === 'button' ? 'button' : undefined
}, href && {
href: href,
target: target,
rel: target === '_blank' ? 'noopener noreferrer' : undefined
}, {
className: ax([unboundStyles.root, styles.root, borderRadiusMap[size], appearance === 'circle' && styles.circle, widthHeightMap[size], stackIndex !== undefined && styles.positionRelative, isInteractive && !isDisabled && unboundStyles.interactive, isDisabled && styles.disabled])
}), children || avatarImage);
});