UNPKG

@atlaskit/avatar

Version:

An avatar is a visual representation of a user or entity.

88 lines 3.38 kB
/* avatar-content.tsx generated by @compiled/babel-plugin v0.36.1 */ import _extends from "@babel/runtime/helpers/extends"; 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'; const boxShadowCssVar = '--avatar-box-shadow'; const bgColorCssVar = '--avatar-bg-color'; const 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" }; const unboundStyles = { root: "_vchh1ntv _bfhkcxp3 _16qs1nhn", interactive: "_80omtlke _4tpu1g4v _ez1ykb7n _gcm1182g _eeh8kb7n _jlxit94y" }; const widthHeightMap = { xsmall: "_1bsb7vkz _4t3i7vkz", small: "_1bsb1tcg _4t3i1tcg", medium: "_1bsbzwfg _4t3izwfg", large: "_1bsb1ylp _4t3i1ylp", xlarge: "_1bsb16xz _4t3i16xz", xxlarge: "_1bsb1qr7 _4t3i1qr7" }; const 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 const AvatarContent = /*#__PURE__*/forwardRef(({ children }, ref) => { useEnsureIsInsideAvatar(); const { as: Container, appearance, avatarImage, // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix borderColor = fg('platform-component-visual-refresh') ? "var(--ds-surface, #FFFFFF)" : "var(--ds-surface-overlay, #FFFFFF)", href, isDisabled, label, onClick, ref: contextRef, tabIndex, target, testId, size, stackIndex } = useAvatarContent(); const isInteractive = Boolean(onClick || href || isDisabled); return /*#__PURE__*/React.createElement(Container, _extends({ style: { [bgColorCssVar]: borderColor, [boxShadowCssVar]: `0 0 0 2px ${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, 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); });