fix: card
parent
60cd5475c1
commit
da207c8d9b
|
@ -69,3 +69,7 @@ v-model -> v-model:checked
|
||||||
v-model -> v-model:activeKey
|
v-model -> v-model:activeKey
|
||||||
|
|
||||||
renderTabBar({props, on, style, class}, DefaultTabBar) -> {DefaultTabBar, ...props} 多参数改成单参数并且扁平化处理
|
renderTabBar({props, on, style, class}, DefaultTabBar) -> {DefaultTabBar, ...props} 多参数改成单参数并且扁平化处理
|
||||||
|
|
||||||
|
## card
|
||||||
|
|
||||||
|
tabList[{scopedSlots}] -> tabList[{slots}]
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { inject } from 'vue';
|
import { inject, isVNode } from 'vue';
|
||||||
import Tabs from '../tabs';
|
import Tabs from '../tabs';
|
||||||
import Row from '../row';
|
import Row from '../row';
|
||||||
import Col from '../col';
|
import Col from '../col';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import { getComponent, filterEmpty, getSlot } from '../_util/props-util';
|
import { getComponent, getSlot, isEmptyElement } from '../_util/props-util';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import isPlainObject from 'lodash/isPlainObject';
|
import isPlainObject from 'lodash/isPlainObject';
|
||||||
|
@ -28,6 +28,7 @@ export default {
|
||||||
tabBarExtraContent: PropTypes.any,
|
tabBarExtraContent: PropTypes.any,
|
||||||
activeTabKey: PropTypes.string,
|
activeTabKey: PropTypes.string,
|
||||||
defaultActiveTabKey: PropTypes.string,
|
defaultActiveTabKey: PropTypes.string,
|
||||||
|
cover: PropTypes.any,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
|
@ -41,11 +42,13 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getAction(actions) {
|
getAction(actions) {
|
||||||
const actionList = actions.map((action, index) => (
|
const actionList = actions.map((action, index) =>
|
||||||
<li style={{ width: `${100 / actions.length}%` }} key={`action-${index}`}>
|
(isVNode(action) && !isEmptyElement(action)) || !isVNode(action) ? (
|
||||||
<span>{action}</span>
|
<li style={{ width: `${100 / actions.length}%` }} key={`action-${index}`}>
|
||||||
</li>
|
<span>{action}</span>
|
||||||
));
|
</li>
|
||||||
|
) : null,
|
||||||
|
);
|
||||||
return actionList;
|
return actionList;
|
||||||
},
|
},
|
||||||
onTabChange(key) {
|
onTabChange(key) {
|
||||||
|
@ -75,6 +78,7 @@ export default {
|
||||||
activeTabKey,
|
activeTabKey,
|
||||||
defaultActiveTabKey,
|
defaultActiveTabKey,
|
||||||
} = this.$props;
|
} = this.$props;
|
||||||
|
const { $slots } = this;
|
||||||
const children = getSlot(this);
|
const children = getSlot(this);
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('card', customizePrefixCls);
|
const prefixCls = getPrefixCls('card', customizePrefixCls);
|
||||||
|
@ -155,9 +159,9 @@ export default {
|
||||||
tabList && tabList.length ? (
|
tabList && tabList.length ? (
|
||||||
<Tabs {...tabsProps}>
|
<Tabs {...tabsProps}>
|
||||||
{tabList.map(item => {
|
{tabList.map(item => {
|
||||||
const { tab: temp, children = {} } = item;
|
const { tab: temp, scopedSlots = {}, slots = {} } = item;
|
||||||
const name = children.tab;
|
const name = slots.tab || scopedSlots.tab;
|
||||||
const tab = temp !== undefined ? temp : children[name] ? children[name](item) : null;
|
const tab = temp !== undefined ? temp : $slots[name] ? $slots[name](item) : null;
|
||||||
return <TabPane tab={tab} key={item.key} disabled={item.disabled} />;
|
return <TabPane tab={tab} key={item.key} disabled={item.disabled} />;
|
||||||
})}
|
})}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
@ -183,7 +187,7 @@ export default {
|
||||||
{loading ? loadingBlock : children}
|
{loading ? loadingBlock : children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
const actions = filterEmpty(getComponent(this, 'action'));
|
const actions = getComponent(this, 'actions');
|
||||||
const actionDom =
|
const actionDom =
|
||||||
actions && actions.length ? (
|
actions && actions.length ? (
|
||||||
<ul class={`${prefixCls}-actions`}>{this.getAction(actions)}</ul>
|
<ul class={`${prefixCls}-actions`}>{this.getAction(actions)}</ul>
|
||||||
|
|
|
@ -9,6 +9,7 @@ export default {
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
title: PropTypes.any,
|
title: PropTypes.any,
|
||||||
description: PropTypes.any,
|
description: PropTypes.any,
|
||||||
|
avatar: PropTypes.any,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
exports[`Card should still have padding when card which set padding to 0 is loading 1`] = `
|
exports[`Card should still have padding when card which set padding to 0 is loading 1`] = `
|
||||||
<div class="ant-card ant-card-loading ant-card-bordered">
|
<div class="ant-card ant-card-loading ant-card-bordered">
|
||||||
|
<!---->
|
||||||
|
<!---->
|
||||||
<div class="ant-card-body" style="padding: 0px;">
|
<div class="ant-card-body" style="padding: 0px;">
|
||||||
<div class="ant-card-loading-content">
|
<div class="ant-card-loading-content">
|
||||||
<div class="ant-row" style="margin-left: -4px; margin-right: -4px;">
|
<div class="ant-row" style="margin-left: -4px; margin-right: -4px;">
|
||||||
|
@ -46,6 +48,7 @@ exports[`Card should still have padding when card which set padding to 0 is load
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!---->
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -54,11 +57,15 @@ exports[`Card title should be vertically aligned 1`] = `
|
||||||
<div class="ant-card-head">
|
<div class="ant-card-head">
|
||||||
<div class="ant-card-head-wrapper">
|
<div class="ant-card-head-wrapper">
|
||||||
<div class="ant-card-head-title">Card title</div>
|
<div class="ant-card-head-title">Card title</div>
|
||||||
<div class="ant-card-extra"><button type="button" class="ant-btn"><span>Button</span></button></div>
|
<div class="ant-card-extra"><button class="ant-btn" type="button">
|
||||||
|
<!----><span>Button</span></button></div>
|
||||||
</div>
|
</div>
|
||||||
|
<!---->
|
||||||
</div>
|
</div>
|
||||||
|
<!---->
|
||||||
<div class="ant-card-body">
|
<div class="ant-card-body">
|
||||||
<p>Card content</p>
|
<p>Card content</p>
|
||||||
</div>
|
</div>
|
||||||
|
<!---->
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -64,10 +64,7 @@ describe('Card', () => {
|
||||||
sync: false,
|
sync: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
wrapper
|
wrapper.findAll('.ant-tabs-tab')[1].trigger('click');
|
||||||
.findAll('.ant-tabs-tab')
|
|
||||||
.at(1)
|
|
||||||
.trigger('click');
|
|
||||||
expect(onTabChange).toHaveBeenCalledWith('tab2');
|
expect(onTabChange).toHaveBeenCalledWith('tab2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import Steps from 'ant-design-vue/steps';
|
||||||
import Switch from 'ant-design-vue/switch';
|
import Switch from 'ant-design-vue/switch';
|
||||||
import Layout from 'ant-design-vue/layout';
|
import Layout from 'ant-design-vue/layout';
|
||||||
import Tabs from 'ant-design-vue/tabs';
|
import Tabs from 'ant-design-vue/tabs';
|
||||||
|
import Card from 'ant-design-vue/card';
|
||||||
import 'ant-design-vue/style.js';
|
import 'ant-design-vue/style.js';
|
||||||
|
|
||||||
const basic = {
|
const basic = {
|
||||||
|
@ -89,4 +90,5 @@ app
|
||||||
.use(Switch)
|
.use(Switch)
|
||||||
.use(Layout)
|
.use(Layout)
|
||||||
.use(Tabs)
|
.use(Tabs)
|
||||||
|
.use(Card)
|
||||||
.mount('#app');
|
.mount('#app');
|
||||||
|
|
Loading…
Reference in New Issue