fix(Grid): info、dot prop not work when use icon slot (#4902)

This commit is contained in:
neverland
2019-11-02 20:53:22 +08:00
committed by GitHub
parent dcd67a1da9
commit ce30cfa3a9
4 changed files with 60 additions and 12 deletions
+29 -12
View File
@@ -2,6 +2,7 @@ import { createNamespace, addUnit } from '../utils';
import { BORDER } from '../utils/constant';
import { ChildrenMixin } from '../mixins/relation';
import { route, routeProps } from '../utils/router';
import Info from '../info';
import Icon from '../icon';
const [createComponent, bem] = createNamespace('grid-item');
@@ -61,7 +62,32 @@ export default createComponent({
route(this.$router, this);
},
renderContent() {
genIcon() {
const iconSlot = this.slots('icon');
if (iconSlot) {
return (
<div class={bem('icon-wrapper')}>
{iconSlot}
<Info dot={this.dot} info={this.info} />
</div>
);
}
if (this.icon) {
return (
<Icon
name={this.icon}
dot={this.dot}
info={this.info}
size={this.parent.iconSize}
class={bem('icon')}
/>
);
}
},
genContent() {
const slot = this.slots();
if (slot) {
@@ -69,16 +95,7 @@ export default createComponent({
}
return [
this.slots('icon') ||
(this.icon && (
<Icon
name={this.icon}
dot={this.dot}
info={this.info}
size={this.parent.iconSize}
class={bem('icon')}
/>
)),
this.genIcon(),
this.slots('text') || (this.text && <span class={bem('text')}>{this.text}</span>)
];
}
@@ -104,7 +121,7 @@ export default createComponent({
]}
onClick={this.onClick}
>
{this.renderContent()}
{this.genContent()}
</div>
</div>
);
+4
View File
@@ -48,6 +48,10 @@
font-size: @grid-item-icon-size;
}
&__icon-wrapper {
position: relative;
}
&__text {
color: @grid-item-text-color;
font-size: @grid-item-text-font-size;