mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-19 20:08:43 +08:00
01d1b3d492
* demo: rewrite render function with React.FC * demo: rewrite render function with React.FC * fix: fix snap * Update components/splitter/Splitter.tsx Co-authored-by: afc163 <afc163@gmail.com> Signed-off-by: lijianan <574980606@qq.com> * fix: clear --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: afc163 <afc163@gmail.com>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { Button, Flex, Splitter, Switch, Typography } from 'antd';
|
|
|
|
const Desc: React.FC<Readonly<{ text?: string | number }>> = (props) => (
|
|
<Flex justify="center" align="center" style={{ height: '100%' }}>
|
|
<Typography.Title type="secondary" level={5} style={{ whiteSpace: 'nowrap' }}>
|
|
{props.text}
|
|
</Typography.Title>
|
|
</Flex>
|
|
);
|
|
|
|
const App: React.FC = () => {
|
|
const [sizes, setSizes] = React.useState<(number | string)[]>(['50%', '50%']);
|
|
const [enabled, setEnabled] = React.useState(true);
|
|
return (
|
|
<Flex vertical gap="middle">
|
|
<Splitter
|
|
onResize={setSizes}
|
|
style={{ height: 200, boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)' }}
|
|
>
|
|
<Splitter.Panel size={sizes[0]} resizable={enabled}>
|
|
<Desc text="First" />
|
|
</Splitter.Panel>
|
|
<Splitter.Panel size={sizes[1]}>
|
|
<Desc text="Second" />
|
|
</Splitter.Panel>
|
|
</Splitter>
|
|
<Flex gap="middle" justify="space-between">
|
|
<Switch
|
|
value={enabled}
|
|
onChange={() => setEnabled(!enabled)}
|
|
checkedChildren="Enabled"
|
|
unCheckedChildren="Disabled"
|
|
/>
|
|
<Button onClick={() => setSizes(['50%', '50%'])}>Reset</Button>
|
|
</Flex>
|
|
</Flex>
|
|
);
|
|
};
|
|
|
|
export default App;
|