mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-21 18:56:03 +08:00

* feat(Button): deprecate Button.Group, prefer Space.Compact * test: update snap --------- Signed-off-by: afc163 <afc163@gmail.com> Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: thinkasany <480968828@qq.com>
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
|
import { Button, Flex, Progress, Space } from 'antd';
|
|
|
|
const App: React.FC = () => {
|
|
const [percent, setPercent] = useState<number>(0);
|
|
|
|
const increase = () => {
|
|
setPercent((prevPercent) => {
|
|
const newPercent = prevPercent + 10;
|
|
if (newPercent > 100) {
|
|
return 100;
|
|
}
|
|
return newPercent;
|
|
});
|
|
};
|
|
|
|
const decline = () => {
|
|
setPercent((prevPercent) => {
|
|
const newPercent = prevPercent - 10;
|
|
if (newPercent < 0) {
|
|
return 0;
|
|
}
|
|
return newPercent;
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Flex vertical gap="small">
|
|
<Flex vertical gap="small">
|
|
<Progress percent={percent} type="line" />
|
|
<Progress percent={percent} type="circle" />
|
|
</Flex>
|
|
<Space.Compact>
|
|
<Button onClick={decline} icon={<MinusOutlined />} />
|
|
<Button onClick={increase} icon={<PlusOutlined />} />
|
|
</Space.Compact>
|
|
</Flex>
|
|
);
|
|
};
|
|
|
|
export default App;
|