2022-12-31 19:18:09 +08:00
|
|
|
import React, { useState } from 'react';
|
2023-07-28 16:17:43 +08:00
|
|
|
import { Avatar, List, Radio, Space } from 'antd';
|
2022-12-31 19:18:09 +08:00
|
|
|
|
|
|
|
type PaginationPosition = 'top' | 'bottom' | 'both';
|
|
|
|
|
|
|
|
type PaginationAlign = 'start' | 'center' | 'end';
|
|
|
|
|
|
|
|
const data = [
|
|
|
|
{
|
|
|
|
title: 'Ant Design Title 1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Ant Design Title 2',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Ant Design Title 3',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Ant Design Title 4',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const positionOptions = ['top', 'bottom', 'both'];
|
|
|
|
|
|
|
|
const alignOptions = ['start', 'center', 'end'];
|
|
|
|
|
|
|
|
const App: React.FC = () => {
|
|
|
|
const [position, setPosition] = useState<PaginationPosition>('bottom');
|
|
|
|
const [align, setAlign] = useState<PaginationAlign>('center');
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-02-20 10:24:40 +08:00
|
|
|
<Space direction="vertical" style={{ marginBottom: '20px' }} size="middle">
|
2022-12-31 19:18:09 +08:00
|
|
|
<Space>
|
|
|
|
<span>Pagination Position:</span>
|
|
|
|
<Radio.Group
|
|
|
|
optionType="button"
|
|
|
|
value={position}
|
|
|
|
onChange={(e) => {
|
|
|
|
setPosition(e.target.value);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{positionOptions.map((item) => (
|
|
|
|
<Radio.Button key={item} value={item}>
|
|
|
|
{item}
|
|
|
|
</Radio.Button>
|
|
|
|
))}
|
|
|
|
</Radio.Group>
|
|
|
|
</Space>
|
|
|
|
<Space>
|
|
|
|
<span>Pagination Align:</span>
|
|
|
|
<Radio.Group
|
|
|
|
optionType="button"
|
|
|
|
value={align}
|
|
|
|
onChange={(e) => {
|
|
|
|
setAlign(e.target.value);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{alignOptions.map((item) => (
|
|
|
|
<Radio.Button key={item} value={item}>
|
|
|
|
{item}
|
|
|
|
</Radio.Button>
|
|
|
|
))}
|
|
|
|
</Radio.Group>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
<List
|
|
|
|
pagination={{ position, align }}
|
|
|
|
dataSource={data}
|
2023-02-20 10:24:40 +08:00
|
|
|
renderItem={(item, index) => (
|
2022-12-31 19:18:09 +08:00
|
|
|
<List.Item>
|
|
|
|
<List.Item.Meta
|
2023-04-08 21:01:51 +08:00
|
|
|
avatar={
|
|
|
|
<Avatar src={`https://xsgames.co/randomusers/avatar.php?g=pixel&key=${index}`} />
|
|
|
|
}
|
2022-12-31 19:18:09 +08:00
|
|
|
title={<a href="https://ant.design">{item.title}</a>}
|
|
|
|
description="Ant Design, a design language for background applications, is refined by Ant UED Team"
|
|
|
|
/>
|
|
|
|
</List.Item>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|