2023-05-25 10:19:56 +08:00
|
|
|
import type { CSSProperties } from 'react';
|
|
|
|
import React from 'react';
|
2024-04-08 14:04:08 +08:00
|
|
|
import { CaretRightOutlined } from '@ant-design/icons';
|
2023-07-28 16:17:43 +08:00
|
|
|
import type { CollapseProps } from 'antd';
|
|
|
|
import { Collapse, theme } from 'antd';
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
const text = `
|
|
|
|
A dog is a type of domesticated animal.
|
|
|
|
Known for its loyalty and faithfulness,
|
|
|
|
it can be found as a welcome guest in many households across the world.
|
|
|
|
`;
|
|
|
|
|
2023-05-25 10:19:56 +08:00
|
|
|
const getItems: (panelStyle: CSSProperties) => CollapseProps['items'] = (panelStyle) => [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
label: 'This is panel header 1',
|
|
|
|
children: <p>{text}</p>,
|
|
|
|
style: panelStyle,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
label: 'This is panel header 2',
|
|
|
|
children: <p>{text}</p>,
|
|
|
|
style: panelStyle,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
label: 'This is panel header 3',
|
|
|
|
children: <p>{text}</p>,
|
|
|
|
style: panelStyle,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-01-11 12:10:20 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const { token } = theme.useToken();
|
|
|
|
|
2023-08-01 01:26:41 +08:00
|
|
|
const panelStyle: React.CSSProperties = {
|
2023-01-11 12:10:20 +08:00
|
|
|
marginBottom: 24,
|
|
|
|
background: token.colorFillAlter,
|
|
|
|
borderRadius: token.borderRadiusLG,
|
|
|
|
border: 'none',
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Collapse
|
|
|
|
bordered={false}
|
|
|
|
defaultActiveKey={['1']}
|
|
|
|
expandIcon={({ isActive }) => <CaretRightOutlined rotate={isActive ? 90 : 0} />}
|
|
|
|
style={{ background: token.colorBgContainer }}
|
2023-05-25 10:19:56 +08:00
|
|
|
items={getItems(panelStyle)}
|
|
|
|
/>
|
2023-01-11 12:10:20 +08:00
|
|
|
);
|
|
|
|
};
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
export default App;
|