Skip to content

Commit 172dc14

Browse files
committed
⚡ feat: update dingding demo & pannel config done
1 parent 9264e18 commit 172dc14

9 files changed

Lines changed: 472 additions & 30 deletions

File tree

src/Layout/components/HeaderAndFooter.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import ActionIcon from '@/ActionIcon';
22
import { MenuUnfoldOutlined } from '@ant-design/icons';
33
import { DropDownProps, Dropdown, Flex, FlexProps } from 'antd';
44
import { ReactNode } from 'react';
5+
import { ThemeLayoutType } from '..';
56
import { getPrefixCls } from '../../theme';
67
import { useStyle } from './../style';
78

@@ -14,6 +15,7 @@ type iconDropdownType = {
1415
icon?: ReactNode;
1516
dropdown?: DropDownProps;
1617
title?: ReactNode;
18+
render?: (props: iconDropdownType, defalutDom?: ReactNode) => JSX.Element;
1719
};
1820

1921
interface HeaderFooterSettings {
@@ -26,12 +28,10 @@ interface HeaderFooterSettings {
2628
className?: string;
2729
children?: ReactNode;
2830
type?: typeEnum | string;
31+
themeType?: ThemeLayoutType;
2932
}
3033

3134
const HeaderAndFooter = (props: HeaderFooterSettings) => {
32-
const prefixCls = getPrefixCls('layout');
33-
34-
const { styles, cx } = useStyle(prefixCls);
3535
const {
3636
children,
3737
render,
@@ -47,10 +47,17 @@ const HeaderAndFooter = (props: HeaderFooterSettings) => {
4747
icon: <MenuUnfoldOutlined />,
4848
dropdown: undefined,
4949
title: '',
50+
render,
5051
},
52+
themeType,
5153
style = {},
5254
className,
5355
} = props || {};
56+
57+
const prefixCls = getPrefixCls('layout');
58+
59+
const { styles, cx } = useStyle({ prefixCls, themeType });
60+
5461
if (hide) {
5562
return null;
5663
}
@@ -60,7 +67,7 @@ const HeaderAndFooter = (props: HeaderFooterSettings) => {
6067

6168
const IconDom = () => {
6269
if (iconConfig === false) return null;
63-
const { icon, dropdown, title } = iconConfig || {};
70+
const { icon, dropdown, title, render } = iconConfig || {};
6471

6572
if (!dropdown)
6673
return (
@@ -70,8 +77,8 @@ const HeaderAndFooter = (props: HeaderFooterSettings) => {
7077
</div>
7178
);
7279

73-
return (
74-
<div className={styles.headerAndFooterIcon}>
80+
const DefalutIconDom = (
81+
<>
7582
<Dropdown
7683
trigger={['click']}
7784
placement={type === typeEnum.header ? 'bottomLeft' : 'topLeft'}
@@ -80,8 +87,14 @@ const HeaderAndFooter = (props: HeaderFooterSettings) => {
8087
<ActionIcon icon={icon} />
8188
</Dropdown>
8289
{title}
83-
</div>
90+
</>
8491
);
92+
93+
if (render) {
94+
return render(iconConfig, DefalutIconDom);
95+
}
96+
97+
return DefalutIconDom;
8598
};
8699

87100
return (
@@ -98,7 +111,9 @@ const HeaderAndFooter = (props: HeaderFooterSettings) => {
98111
>
99112
{/* 虽然是放在 flex 中,但实际上是 absoult 定位到最中间 */}
100113
<div className={styles.headerAndFooterCenterChildren}>{children}</div>
101-
<IconDom />
114+
<div className={styles.headerAndFooterIcon}>
115+
<IconDom />
116+
</div>
102117
{extra && <div className={styles.headerAndFooterExtra}>{extra}</div>}
103118
</Flex>
104119
);

src/Layout/components/LayoutTypeContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { Flex } from 'antd';
22
import { ReactNode } from 'react';
33
import { Flexbox } from 'react-layout-kit';
4-
import { LayoutTypeEnum } from '..';
4+
import { LayoutTypeEnum, ThemeLayoutType } from '..';
55
import { getPrefixCls } from '../../theme';
66
import { useStyle } from './../style';
77

88
type LayoutTypeContainerProps = {
99
pannels: ReactNode[];
1010
headerandfooter: ReactNode[];
1111
type: LayoutTypeEnum;
12+
themeType: ThemeLayoutType;
1213
};
1314

1415
const LayoutTypeContainer = (props: LayoutTypeContainerProps) => {
16+
const { type, pannels, themeType, headerandfooter, ...rest } = props;
1517
const prefixCls = getPrefixCls('layout');
16-
const { styles } = useStyle(prefixCls);
17-
18-
const { type, pannels, headerandfooter, ...rest } = props;
18+
const { styles } = useStyle({ prefixCls, themeType });
1919

2020
const [LeftPannelDom, RightPannelDom, BottomPannelDom, CenterPannelDom] = pannels;
2121
const [HeaderDom, FooterDom] = headerandfooter;

src/Layout/components/PannelDefault.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DraggablePanel, TabsProps } from '@ant-design/pro-editor';
22
import { Size } from 're-resizable';
33
import { ReactNode } from 'react';
4+
import { ThemeLayoutType } from '..';
45
import { getPrefixCls } from '../../theme';
56
import { useStyle } from './../style';
67

@@ -17,11 +18,22 @@ interface PannelSettings {
1718
maxHeight?: number;
1819
style?: React.CSSProperties;
1920
className?: string;
21+
themeType?: ThemeLayoutType;
2022
}
2123

2224
const PannelDefault = (props: PannelSettings & { index: number }) => {
25+
const {
26+
children = '',
27+
className,
28+
style,
29+
minHeight = 100,
30+
minWidth = 100,
31+
index = 0,
32+
themeType,
33+
...rest
34+
} = props || {};
2335
const prefixCls = getPrefixCls('layout');
24-
const { styles, cx } = useStyle(prefixCls);
36+
const { styles, cx } = useStyle({ prefixCls, themeType });
2537

2638
const getPannelProps = (
2739
index: number,
@@ -67,20 +79,10 @@ const PannelDefault = (props: PannelSettings & { index: number }) => {
6779
return false;
6880
}
6981
};
70-
71-
const {
72-
children = '',
73-
className,
74-
style,
75-
minHeight = 100,
76-
minWidth = 100,
77-
index = 0,
78-
...rest
79-
} = props || {};
8082
const pannelProps = getPannelProps(index);
8183
if (!pannelProps) {
8284
return (
83-
<div className={cx(styles.pannel, styles.centerPannel)}>
85+
<div className={cx(styles.pannel, styles.centerPannel)} style={style}>
8486
<div className={cx(className)}>{children}</div>
8587
</div>
8688
);
@@ -89,14 +91,16 @@ const PannelDefault = (props: PannelSettings & { index: number }) => {
8991
return (
9092
<DraggablePanel
9193
expandable={false}
92-
style={{ border: 'none', ...style }}
94+
style={{ border: 'none' }}
9395
placement={placement}
9496
minHeight={minHeight}
9597
minWidth={minWidth}
9698
{...pannelProps}
9799
{...rest}
98100
>
99-
<div className={cx(styles.pannel, pannelClassName, className)}>{children}</div>
101+
<div className={cx(styles.pannel, pannelClassName, className)} style={style}>
102+
{children}
103+
</div>
100104
</DraggablePanel>
101105
);
102106
};
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import { Avatar, Button, List, Skeleton } from 'antd';
2+
import { css, cx } from 'antd-style';
3+
import React, { useEffect, useState } from 'react';
4+
5+
export interface DataType {
6+
gender?: string;
7+
name: {
8+
title?: string;
9+
first?: string;
10+
last?: string;
11+
};
12+
email?: string;
13+
picture: {
14+
large?: string;
15+
medium?: string;
16+
thumbnail?: string;
17+
};
18+
nat?: string;
19+
loading: boolean;
20+
}
21+
22+
const count = 8;
23+
const fakeDataUrl = `https://randomuser.me/api/?results=${count}&inc=name,gender,email,nat,picture&noinfo`;
24+
25+
const ClassNamesGroup = {
26+
ListClassName: cx(css`
27+
overflow: scroll;
28+
`),
29+
ListItemClassName: cx(css`
30+
cursor: pointer;
31+
padding: 0px 10px !important;
32+
margin-top: 4px;
33+
margin-bottom: 4px;
34+
border-radius: 10px;
35+
:hover {
36+
background-color: #e3e3e3;
37+
}
38+
`),
39+
SubTitle: cx(css`
40+
text-wrap: nowrap;
41+
overflow: hidden;
42+
text-overflow: ellipsis;
43+
`),
44+
ItemTitle: cx(css`
45+
text-wrap: nowrap;
46+
overflow: hidden;
47+
text-overflow: ellipsis;
48+
margin: 0 0 -4px 0;
49+
`),
50+
avatar: cx(css`
51+
height: 40px;
52+
width: 40px;
53+
`),
54+
};
55+
56+
const SessonList: React.FC = () => {
57+
const [initLoading, setInitLoading] = useState(true);
58+
const [loading, setLoading] = useState(false);
59+
const [data, setData] = useState<DataType[]>([]);
60+
const [list, setList] = useState<DataType[]>([]);
61+
62+
useEffect(() => {
63+
fetch(fakeDataUrl)
64+
.then((res) => res.json())
65+
.then((res) => {
66+
setInitLoading(false);
67+
setData(res.results);
68+
setList(res.results);
69+
});
70+
}, []);
71+
72+
const onLoadMore = () => {
73+
setLoading(true);
74+
setList(
75+
data.concat([...new Array(count)].map(() => ({ loading: true, name: {}, picture: {} }))),
76+
);
77+
fetch(fakeDataUrl)
78+
.then((res) => res.json())
79+
.then((res) => {
80+
const newData = data.concat(res.results);
81+
setData(newData);
82+
setList(newData);
83+
setLoading(false);
84+
// Resetting window's offsetTop so as to display react-virtualized demo underfloor.
85+
// In real scene, you can using public method of react-virtualized:
86+
// https://stackoverflow.com/questions/46700726/how-to-use-public-method-updateposition-of-react-virtualized
87+
window.dispatchEvent(new Event('resize'));
88+
});
89+
};
90+
91+
const loadMore =
92+
!initLoading && !loading ? (
93+
<div
94+
style={{
95+
textAlign: 'center',
96+
marginTop: 12,
97+
height: 32,
98+
lineHeight: '32px',
99+
}}
100+
>
101+
<Button onClick={onLoadMore}>loading more</Button>
102+
</div>
103+
) : null;
104+
105+
return (
106+
<div
107+
style={{
108+
height: '540px',
109+
overflow: 'scroll',
110+
}}
111+
>
112+
<List
113+
className={ClassNamesGroup.ListClassName}
114+
loading={initLoading}
115+
itemLayout="horizontal"
116+
loadMore={loadMore}
117+
dataSource={list}
118+
renderItem={(item) => (
119+
<List.Item extra={<div>12.31</div>} className={ClassNamesGroup.ListItemClassName}>
120+
<Skeleton avatar title={false} loading={item.loading} active>
121+
<List.Item.Meta
122+
avatar={<Avatar src={item.picture.large} className={ClassNamesGroup.avatar} />}
123+
title={<div className={ClassNamesGroup.ItemTitle}>{item.name?.last}</div>}
124+
description={
125+
<div className={ClassNamesGroup.SubTitle}>Hello! nice to meet to u ~</div>
126+
}
127+
/>
128+
</Skeleton>
129+
</List.Item>
130+
)}
131+
/>
132+
</div>
133+
);
134+
};
135+
136+
export default SessonList;

0 commit comments

Comments
 (0)