Skip to content

Commit

Permalink
Merge pull request #726 from thundersdata-frontend/feat/lego
Browse files Browse the repository at this point in the history
fix: 修改table的lineHeight报错以及更新modal的写法
  • Loading branch information
chj-damon authored Sep 15, 2023
2 parents ed657fd + 7e04b36 commit 355a88b
Show file tree
Hide file tree
Showing 27 changed files with 38 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-shrimps-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/lego': patch
---

修改table的lineHeight报错以及更新modal的写法
2 changes: 1 addition & 1 deletion packages/lego/example/BarLineDemo/demo8.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/CircularSolidPieDemo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/CuboidBarDemo/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/CylinderBarDemo/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/CylinderShadowBarDemo/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/HorizontalBarDemo/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/ImgLineDemo/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/ModalDemo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default () => {
return (
<>
<Button onClick={() => setVisible(true)}>显示弹窗</Button>
<Modal visible={visible} onClose={() => setVisible(false)} >
<Modal open={visible} onClose={() => setVisible(false)} >
</Modal>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/MultiHorizontalBarDemo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/MultiLineDemo/demo8.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/PictorialBarDemo/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/ProgressDemo/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/RadarDemo/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/ScatterDemo/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/SliceBarDemo/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/StackBarDemo/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/TableDemo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default () => {
data={data}
columns={columns}
height={200}
countPerview={6}
countPreview={6}
autoplay={true}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/lego/example/TableDemo/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand All @@ -74,7 +74,7 @@ export default () => {
data={data}
columns={columns}
height={200}
countPerview={4}
countPreview={4}
/>
</Modal>
</>
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/TableDemo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default () => {
columns={columns}
colors={['red', 'blue', 'green']}
height={200}
countPerview={4}
countPreview={4}
/>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/TableDemo/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ const columns = [
];

export default () => {
return <Table data={data} columns={columns} height={210} countPerview={7} />;
return <Table data={data} columns={columns} height={210} countPreview={7} />;
};
2 changes: 1 addition & 1 deletion packages/lego/example/TableDemo/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default () => {
columns={columns}
autoplay={false}
height={200}
countPerview={4}
countPreview={4}
/>
);
};
2 changes: 1 addition & 1 deletion packages/lego/example/TableDemo/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default () => {
data={data}
columns={columns}
height={200}
countPerview={4}
countPreview={4}
autoplay={false}
headerClass="header"
contentClass="content"
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/TextScrollDemo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={650}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/example/ThreeDimensionalPieDemo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default () => {
<>
<Button onClick={() => setVisible(true)}>弹窗</Button>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
footer={null}
width={750}
Expand Down
2 changes: 1 addition & 1 deletion packages/lego/src/table/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group:
title: 其他
---

# 轮播图
# 表格

## API

Expand Down
14 changes: 7 additions & 7 deletions packages/lego/src/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type CustomTableProps<T> = {
/** 容器高度 */
height: number;
/** 每屏显示几条数据 */
countPerview: number;
countPreview: number;
/** 速度(ms) */
speed?: number;
/** 自动轮播 */
Expand All @@ -49,7 +49,7 @@ function Table<T extends Record<string, any>>({
columns = [],
data = [],
height,
countPerview,
countPreview = 1,
speed = 1000,
autoplay = true,
inModal = false,
Expand All @@ -67,7 +67,7 @@ function Table<T extends Record<string, any>>({
return { width };
};

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

return (
Expand Down Expand Up @@ -116,7 +116,7 @@ function Table<T extends Record<string, any>>({
<Container
{...{
height,
countPerview: slidesPerViewParams,
countPreview: slidesPerViewParams,
speed,
autoplay,
}}
Expand Down Expand Up @@ -165,21 +165,21 @@ function Table<T extends Record<string, any>>({
const Container = memo(
({
height,
countPerview,
countPreview,
autoplay,
speed,
children,
}: PropsWithChildren<{
height: number;
countPerview: number;
countPreview: number;
autoplay: boolean;
speed: number;
}>) => {
return (
<Swiper
direction={'vertical'}
modules={[Autoplay]}
slidesPerView={countPerview}
slidesPerView={countPreview}
spaceBetween={0}
loop
autoplay={
Expand Down

0 comments on commit 355a88b

Please sign in to comment.