You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
888 B
39 lines
888 B
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;
|
|
|