Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(card): card组件支持传入loadingProps参数 #2959

Merged
merged 8 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/card/_example/custom-loading-props.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<t-card bordered :title="title" :loading="isLoading" :style="{ width: '400px' }" :loading-props="customProps">
{{ infoMessage }}
</t-card>
</template>

<script>
export default {
data() {
return {
title: '自定义loadingProps Card',
isLoading: true,
customProps: {
text: 'TDesign努力加载中...',
},
infoMessage: '',
};
},
};
</script>
6 changes: 4 additions & 2 deletions src/card/card.en-US.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:: BASE_DOC ::

## API

### Card Props

name | type | default | description | required
Expand All @@ -17,9 +18,10 @@ header | String / Slot / Function | - | Typescript:`string \| TNode`。[see mo
headerBordered | Boolean | false | \- | N
hoverShadow | Boolean | false | \- | N
loading | Boolean / Slot / Function | false | Typescript:`boolean \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
loadingProps | Object | - | Loading Component Props。Typescript:`LoadingProps`,[Loading API Documents](./loading?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/card/type.ts) | N
shadow | Boolean | false | \- | N
size | String | medium | optionsmedium/small | N
size | String | medium | options: medium/small | N
status | String | - | \- | N
subtitle | String / Slot / Function | - | card subtitle。Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
theme | String | normal | optionsnormal/poster1/poster2 | N
theme | String | normal | options: normal/poster1/poster2 | N
title | String / Slot / Function | - | card title。Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
2 changes: 2 additions & 0 deletions src/card/card.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:: BASE_DOC ::

## API

### Card Props

名称 | 类型 | 默认值 | 说明 | 必传
Expand All @@ -17,6 +18,7 @@ header | String / Slot / Function | - | 卡片顶部内容,优先级高于其
headerBordered | Boolean | false | 头部是否带分割线,仅在有header时有效 | N
hoverShadow | Boolean | false | hover时是否有阴影 | N
loading | Boolean / Slot / Function | false | 加载状态,值为 true 会根据不同的布局显示不同的加载状态,值为 false 则表示非加载状态。也可以使用 Sketon 组件完全自定义加载态呈现内容。TS 类型:`boolean \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
loadingProps | Object | - | 透传加载组件(Loading)全部属性。TS 类型:`LoadingProps`,[Loading API Documents](./loading?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/card/type.ts) | N
shadow | Boolean | false | 是否显示卡片阴影,默认不显示 | N
size | String | medium | 尺寸。可选项:medium/small | N
status | String | - | 卡片状态内容,仅在操作区域不在顶部时有效(即 `theme=poster2` ) | N
Expand Down
2 changes: 1 addition & 1 deletion src/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default defineComponent({
if (this.loading) {
return renderTNodeJSX(this, 'loading', {
defaultNode: (
<t-loading>
<t-loading {...{ props: this.loadingProps }}>
iiimix marked this conversation as resolved.
Show resolved Hide resolved
<div class={this.baseCls}></div>
</t-loading>
),
Expand Down
4 changes: 4 additions & 0 deletions src/card/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export default {
type: [Boolean, Function] as PropType<TdCardProps['loading']>,
default: false,
},
/** 透传加载组件(Loading)全部属性 */
loadingProps: {
type: Object as PropType<TdCardProps['loadingProps']>,
},
/** 是否显示卡片阴影,默认不显示 */
shadow: Boolean,
/** 尺寸 */
Expand Down
5 changes: 5 additions & 0 deletions src/card/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { LoadingProps } from '../loading';
import { TNode } from '../common';

export interface TdCardProps {
Expand Down Expand Up @@ -59,6 +60,10 @@ export interface TdCardProps {
* @default false
*/
loading?: boolean | TNode;
/**
* 透传加载组件(Loading)全部属性
*/
loadingProps?: LoadingProps;
/**
* 是否显示卡片阴影,默认不显示
* @default false
Expand Down
Loading