Skip to content

Commit

Permalink
fix: lego中table组件的优化
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuyan committed Sep 18, 2023
1 parent 7e04b36 commit d6df817
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-dolls-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/lego': patch
---

lego中table组件的优化
32 changes: 30 additions & 2 deletions packages/lego/example/TableDemo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ const data = [
model: '200',
money: '200元',
},
{
id: 5,
brand: '维特根5',
name: '沥青摊铺机',
model: '200',
money: '12988元',
},
{
id: 6,
brand: '徐工6',
name: '履带式挖掘机',
model: 'XE80CA',
money: '862.2元',
},
{
id: 7,
brand: '维特根7',
name: '沥青摊铺机',
model: '200',
money: '200元',
},
{
id: 8,
brand: '维特根8',
name: '沥青摊铺机',
model: '200',
money: '200元',
},
];

const columns = [
Expand Down Expand Up @@ -60,8 +88,8 @@ export default () => {
<Table
data={data}
columns={columns}
height={200}
countPreview={6}
height={120}
countPreview={4}
autoplay={true}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/lego/src/table/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ group:
| ------------ | ------- | ---------------------- | ---------------------------------------------- | ------ |
| columns | `true` | 列数据 | `Column[]` | |
| data | `true` | 数据源 | `T[]` | |
| height | `true` | 除了表头的表格内容高度 | `number` | |
| countPreview | `true` | 每屏显示几条数据 | `number` | |
| speed | `false` | 速度(ms) | `number` | |
| autoplay | `false` | 自动轮播 | `boolean` | |
| inModal | `false` | 是否在弹窗中 | `boolean` | |
| lineHeight | `false` | 自定义行高 | `number` | |
| height | `false` | 除了表头的表格内容高度 | `number` | |
| colors | `false` | 自定义颜色 | `[string, string] \| [string, string, string]` | |
| headerClass | `false` | 表头的类 | `string` | |
| contentClass | `false` | 内容的类 | `string` | |
Expand Down
4 changes: 2 additions & 2 deletions packages/lego/src/table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, PropsWithChildren, ReactElement, ReactNode } from 'react';
import React, { memo, PropsWithChildren, ReactElement } from 'react';

import classnames from 'classnames';
import { isEmpty } from 'lodash-es';
Expand Down Expand Up @@ -67,7 +67,7 @@ function Table<T extends Record<string, any>>({
return { width };
};

const slidesPerViewParams = countPreview > data?.length ?? 0 ? countPreview : data.length;
const slidesPerViewParams = countPreview > data.length ? data.length : countPreview;
const lineHeight = height / slidesPerViewParams;

return (
Expand Down

0 comments on commit d6df817

Please sign in to comment.