mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
0352b2fd2e
* feat: spin support ptg * chore: ptg * chore: update demo * chore: popout component * chore: adjust logic * test: update snapshot * test: update snapshot * docs: update docs * test: update snapshot * test: update snapshot * test: update snapshot * chore: back of snapshot * chore: clean up * test: fix test case * chore: fix types * test: update snapshot * chore: opt * test: update testcase * test: coverage * test: update snapshot
41 lines
939 B
TypeScript
41 lines
939 B
TypeScript
import React from 'react';
|
|
import { Space, Spin, Switch } from 'antd';
|
|
|
|
const App: React.FC = () => {
|
|
const [auto, setAuto] = React.useState(false);
|
|
const [percent, setPercent] = React.useState(-50);
|
|
|
|
React.useEffect(() => {
|
|
const timeout = setTimeout(() => {
|
|
setPercent((v) => {
|
|
const nextPercent = v + 5;
|
|
return nextPercent > 150 ? -50 : nextPercent;
|
|
});
|
|
}, 100);
|
|
return () => {
|
|
clearTimeout(timeout);
|
|
};
|
|
}, [percent]);
|
|
|
|
const mergedPercent = auto ? 'auto' : percent;
|
|
|
|
return (
|
|
<Space>
|
|
<Switch
|
|
checkedChildren="Auto"
|
|
unCheckedChildren="Auto"
|
|
checked={auto}
|
|
onChange={() => {
|
|
setAuto(!auto);
|
|
setPercent(-50);
|
|
}}
|
|
/>
|
|
<Spin percent={mergedPercent} size="small" />
|
|
<Spin percent={mergedPercent} />
|
|
<Spin percent={mergedPercent} size="large" />
|
|
</Space>
|
|
);
|
|
};
|
|
|
|
export default App;
|