mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
816cf10524
* fix: update demo * Update components/qrcode/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> * Update index.test.tsx Co-authored-by: MadCcc <1075746765@qq.com>
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
|
import { QRCode, Button } from 'antd';
|
|
|
|
const App: React.FC = () => {
|
|
const [size, setSize] = useState<number>(160);
|
|
|
|
const increase = () => {
|
|
setSize((prevSize) => {
|
|
const newSize = prevSize + 10;
|
|
if (newSize > 300) {
|
|
return 300;
|
|
}
|
|
return newSize;
|
|
});
|
|
};
|
|
|
|
const decline = () => {
|
|
setSize((prevSize) => {
|
|
const newSize = prevSize - 10;
|
|
if (newSize < 48) {
|
|
return 48;
|
|
}
|
|
return newSize;
|
|
});
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Button.Group style={{ marginBottom: 16 }}>
|
|
<Button onClick={decline} disabled={size <= 48} icon={<MinusOutlined />}>
|
|
Smaller
|
|
</Button>
|
|
<Button onClick={increase} disabled={size >= 300} icon={<PlusOutlined />}>
|
|
Larger
|
|
</Button>
|
|
</Button.Group>
|
|
<QRCode
|
|
errorLevel="H"
|
|
size={size}
|
|
iconSize={size / 4}
|
|
value="https://ant.design/"
|
|
icon="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|