mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
30f7dcc107
* docs: update demo use Space * update snap
40 lines
888 B
TypeScript
40 lines
888 B
TypeScript
import React, { useState } from 'react';
|
|
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
|
import { Button, Progress } 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 (
|
|
<>
|
|
<Progress percent={percent} />
|
|
<Button.Group>
|
|
<Button onClick={decline} icon={<MinusOutlined />} />
|
|
<Button onClick={increase} icon={<PlusOutlined />} />
|
|
</Button.Group>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|