card 支持 avtarText

This commit is contained in:
2betop 2020-03-05 20:36:07 +08:00
parent 965296f9c3
commit 7cfea50897
2 changed files with 30 additions and 3 deletions

View File

@ -66,6 +66,21 @@
} }
} }
&-avtarText {
background-color: $primary;
color: $white;
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
vertical-align: middle;
border-radius: 500px;
float: left;
margin-right: $gap-base;
font-size: $fontSizeXl;
text-transform: uppercase();
}
&-meta { &-meta {
display: block; display: block;
height: 100%; height: 100%;

View File

@ -280,9 +280,12 @@ export class Card extends React.Component<CardProps> {
subTitleClassName, subTitleClassName,
descClassName, descClassName,
checkOnItemClick, checkOnItemClick,
avatarClassName,
checkable, checkable,
classnames: cx, classnames: cx,
classPrefix: ns classPrefix: ns,
imageClassName,
avatarTextClassName
} = this.props; } = this.props;
let heading = null; let heading = null;
@ -291,8 +294,7 @@ export class Card extends React.Component<CardProps> {
const { const {
highlight: highlightTpl, highlight: highlightTpl,
avatar: avatarTpl, avatar: avatarTpl,
avatarClassName, avatarText: avatarTextTpl,
imageClassName,
title: titleTpl, title: titleTpl,
subTitle: subTitleTpl, subTitle: subTitleTpl,
subTitlePlaceholder, subTitlePlaceholder,
@ -302,6 +304,7 @@ export class Card extends React.Component<CardProps> {
const highlight = !!evalExpression(highlightTpl, data as object); const highlight = !!evalExpression(highlightTpl, data as object);
const avatar = filter(avatarTpl, data); const avatar = filter(avatarTpl, data);
const avatarText = filter(avatarTextTpl, data);
const title = filter(titleTpl, data); const title = filter(titleTpl, data);
const subTitle = filter(subTitleTpl, data); const subTitle = filter(subTitleTpl, data);
const desc = filter(descTpl, data); const desc = filter(descTpl, data);
@ -323,6 +326,15 @@ export class Card extends React.Component<CardProps> {
src={avatar} src={avatar}
/> />
</span> </span>
) : avatarText ? (
<span
className={cx(
'Card-avtarText',
header.avatarTextClassName || avatarTextClassName
)}
>
{avatarText}
</span>
) : null} ) : null}
<div className={cx('Card-meta')}> <div className={cx('Card-meta')}>
{highlight ? ( {highlight ? (