123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.prepareComponentToken = exports.default = void 0;
- var _cssinjs = require("@ant-design/cssinjs");
- var _style = require("../../style");
- var _internal = require("../../theme/internal");
- const genBaseStyle = token => {
- const {
- antCls,
- componentCls,
- iconCls,
- avatarBg,
- avatarColor,
- containerSize,
- containerSizeLG,
- containerSizeSM,
- textFontSize,
- textFontSizeLG,
- textFontSizeSM,
- iconFontSize,
- iconFontSizeLG,
- iconFontSizeSM,
- borderRadius,
- borderRadiusLG,
- borderRadiusSM,
- lineWidth,
- lineType
- } = token;
- // Avatar size style
- const avatarSizeStyle = (size, fontSize, iconFontSize, radius) => ({
- width: size,
- height: size,
- borderRadius: '50%',
- fontSize,
- [`&${componentCls}-square`]: {
- borderRadius: radius
- },
- [`&${componentCls}-icon`]: {
- fontSize: iconFontSize,
- [`> ${iconCls}`]: {
- margin: 0
- }
- }
- });
- return {
- [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
- position: 'relative',
- display: 'inline-flex',
- justifyContent: 'center',
- alignItems: 'center',
- overflow: 'hidden',
- color: avatarColor,
- whiteSpace: 'nowrap',
- textAlign: 'center',
- verticalAlign: 'middle',
- background: avatarBg,
- border: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} transparent`,
- '&-image': {
- background: 'transparent'
- },
- [`${antCls}-image-img`]: {
- display: 'block'
- }
- }), avatarSizeStyle(containerSize, textFontSize, iconFontSize, borderRadius)), {
- '&-lg': Object.assign({}, avatarSizeStyle(containerSizeLG, textFontSizeLG, iconFontSizeLG, borderRadiusLG)),
- '&-sm': Object.assign({}, avatarSizeStyle(containerSizeSM, textFontSizeSM, iconFontSizeSM, borderRadiusSM)),
- '> img': {
- display: 'block',
- width: '100%',
- height: '100%',
- objectFit: 'cover'
- }
- })
- };
- };
- const genGroupStyle = token => {
- const {
- componentCls,
- groupBorderColor,
- groupOverlapping,
- groupSpace
- } = token;
- return {
- [`${componentCls}-group`]: {
- display: 'inline-flex',
- [componentCls]: {
- borderColor: groupBorderColor
- },
- '> *:not(:first-child)': {
- marginInlineStart: groupOverlapping
- }
- },
- [`${componentCls}-group-popover`]: {
- [`${componentCls} + ${componentCls}`]: {
- marginInlineStart: groupSpace
- }
- }
- };
- };
- const prepareComponentToken = token => {
- const {
- controlHeight,
- controlHeightLG,
- controlHeightSM,
- fontSize,
- fontSizeLG,
- fontSizeXL,
- fontSizeHeading3,
- marginXS,
- marginXXS,
- colorBorderBg
- } = token;
- return {
- containerSize: controlHeight,
- containerSizeLG: controlHeightLG,
- containerSizeSM: controlHeightSM,
- textFontSize: fontSize,
- textFontSizeLG: fontSize,
- textFontSizeSM: fontSize,
- iconFontSize: Math.round((fontSizeLG + fontSizeXL) / 2),
- iconFontSizeLG: fontSizeHeading3,
- iconFontSizeSM: fontSize,
- groupSpace: marginXXS,
- groupOverlapping: -marginXS,
- groupBorderColor: colorBorderBg
- };
- };
- exports.prepareComponentToken = prepareComponentToken;
- var _default = exports.default = (0, _internal.genStyleHooks)('Avatar', token => {
- const {
- colorTextLightSolid,
- colorTextPlaceholder
- } = token;
- const avatarToken = (0, _internal.mergeToken)(token, {
- avatarBg: colorTextPlaceholder,
- avatarColor: colorTextLightSolid
- });
- return [genBaseStyle(avatarToken), genGroupStyle(avatarToken)];
- }, prepareComponentToken);
|