Skip to content

Commit e9ce4eb

Browse files
committed
refactor: card #6258
1 parent cb08f85 commit e9ce4eb

File tree

5 files changed

+331
-339
lines changed

5 files changed

+331
-339
lines changed

components/card/Card.tsx

+5-30
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { VNodeTypes, PropType, VNode, ExtractPropTypes, CSSProperties } from 'vue';
22
import { isVNode, defineComponent, renderSlot } from 'vue';
33
import Tabs from '../tabs';
4-
import Row from '../row';
5-
import Col from '../col';
64
import PropTypes from '../_util/vue-types';
75
import { flattenChildren, isEmptyElement, filterEmptyWithUndefined } from '../_util/props-util';
86
import type { SizeType } from '../config-provider';
97
import isPlainObject from 'lodash-es/isPlainObject';
108
import useConfigInject from '../config-provider/hooks/useConfigInject';
119
import devWarning from '../vc-util/devWarning';
1210
import useStyle from './style';
11+
import Skeleton from '../skeleton';
1312
export interface CardTabListType {
1413
key: string;
1514
tab: any;
@@ -112,34 +111,10 @@ const Card = defineComponent({
112111
[`${pre}-type-${type}`]: !!type,
113112
[`${pre}-rtl`]: direction.value === 'rtl',
114113
};
115-
116-
const loadingBlockStyle =
117-
bodyStyle.padding === 0 || bodyStyle.padding === '0px' ? { padding: '24px' } : undefined;
118-
119-
const block = <div class={`${pre}-loading-block`} />;
120114
const loadingBlock = (
121-
<div class={`${pre}-loading-content`} style={loadingBlockStyle}>
122-
<Row gutter={8}>
123-
<Col span={22}>{block}</Col>
124-
</Row>
125-
<Row gutter={8}>
126-
<Col span={8}>{block}</Col>
127-
<Col span={15}>{block}</Col>
128-
</Row>
129-
<Row gutter={8}>
130-
<Col span={6}>{block}</Col>
131-
<Col span={18}>{block}</Col>
132-
</Row>
133-
<Row gutter={8}>
134-
<Col span={13}>{block}</Col>
135-
<Col span={9}>{block}</Col>
136-
</Row>
137-
<Row gutter={8}>
138-
<Col span={4}>{block}</Col>
139-
<Col span={3}>{block}</Col>
140-
<Col span={16}>{block}</Col>
141-
</Row>
142-
</div>
115+
<Skeleton loading active paragraph={{ rows: 4 }} title={false}>
116+
{children}
117+
</Skeleton>
143118
);
144119

145120
const hasActiveTabKey = activeTabKey !== undefined;
@@ -195,7 +170,7 @@ const Card = defineComponent({
195170
actions && actions.length ? <ul class={`${pre}-actions`}>{getAction(actions)}</ul> : null;
196171

197172
return wrapSSR(
198-
<div ref="cardContainerRef" {...attrs} class={classString}>
173+
<div ref="cardContainerRef" {...attrs} class={[classString, attrs.class]}>
199174
{head}
200175
{coverDom}
201176
{children && children.length ? body : null}

components/card/Meta.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { ExtractPropTypes } from 'vue';
22
import { defineComponent } from 'vue';
3-
import PropTypes from '../_util/vue-types';
43
import { getPropsSlot } from '../_util/props-util';
54
import useConfigInject from '../config-provider/hooks/useConfigInject';
5+
import { vNodeType } from '../_util/type';
66

77
export const cardMetaProps = () => ({
88
prefixCls: String,
9-
title: PropTypes.any,
10-
description: PropTypes.any,
11-
avatar: PropTypes.any,
9+
title: vNodeType(),
10+
description: vNodeType(),
11+
avatar: vNodeType(),
1212
});
1313
export type CardGridProps = Partial<ExtractPropTypes<ReturnType<typeof cardMetaProps>>>;
1414
export default defineComponent({

components/card/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
category: Components
33
type: Data Display
44
title: Card
5-
cover: https://gw.alipayobjects.com/zos/antfincdn/NqXt8DJhky/Card.svg
5+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*VXtCTp93KPAAAAAAAAAAAAAADrJ8AQ/original
66
---
77

88
Simple rectangular container.

components/card/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
type: 数据展示
44
title: Card
55
subtitle: 卡片
6-
cover: https://gw.alipayobjects.com/zos/antfincdn/NqXt8DJhky/Card.svg
6+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*VXtCTp93KPAAAAAAAAAAAAAADrJ8AQ/original
77
---
88

99
通用卡片容器

0 commit comments

Comments
 (0)