Skip to content

Commit

Permalink
feat: New Component Qr-Code (#38891)
Browse files Browse the repository at this point in the history
* feat: QrCode

* fix

* fix

* fix: fix bug

* fix: fix bug

* fix

* fix

* fix

* delete

* delete

* test case

* fix lint

* bundlesize

* demo

* fix: fix test
  • Loading branch information
li-jia-nan committed Nov 25, 2022
1 parent c3b8b44 commit a974d94
Show file tree
Hide file tree
Showing 34 changed files with 595 additions and 514 deletions.
1 change: 1 addition & 0 deletions components/__tests__/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exports[`antd exports modules correctly 1`] = `
"Popconfirm",
"Popover",
"Progress",
"QrCode",
"Radio",
"Rate",
"Result",
Expand Down
2 changes: 2 additions & 0 deletions components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,6 @@ export { default as Typography } from './typography';
export type { TypographyProps } from './typography';
export { default as Upload } from './upload';
export type { UploadFile, UploadProps } from './upload';
export { default as QrCode } from './qr-code';
export type { QrCodeProps, QRPropsCanvas } from './qr-code/interface';
export { default as version } from './version';
153 changes: 153 additions & 0 deletions components/qr-code/__test__/__snapshots__/demo-extend.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders ./components/qr-code/demo/base.tsx extend context correctly 1`] = `
<div
class="ant-qrcode"
style="width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
</div>
`;

exports[`renders ./components/qr-code/demo/download.tsx extend context correctly 1`] = `
<div
id="myqrcode"
>
<div
class="ant-qrcode"
style="width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
</div>
<button
class="ant-btn ant-btn-default"
style="margin-block-start:16px"
type="button"
>
<span>
下载二维码
</span>
</button>
</div>
`;

exports[`renders ./components/qr-code/demo/errorlevel.tsx extend context correctly 1`] = `
Array [
<div
class="ant-radio-group ant-radio-group-outline"
>
<label
class="ant-radio-button-wrapper ant-radio-button-wrapper-checked"
>
<span
class="ant-radio-button ant-radio-button-checked"
>
<input
checked=""
class="ant-radio-button-input"
type="radio"
value="L"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
L
</span>
</label>
<label
class="ant-radio-button-wrapper"
>
<span
class="ant-radio-button"
>
<input
class="ant-radio-button-input"
type="radio"
value="M"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
M
</span>
</label>
<label
class="ant-radio-button-wrapper"
>
<span
class="ant-radio-button"
>
<input
class="ant-radio-button-input"
type="radio"
value="Q"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
Q
</span>
</label>
<label
class="ant-radio-button-wrapper"
>
<span
class="ant-radio-button"
>
<input
class="ant-radio-button-input"
type="radio"
value="H"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
H
</span>
</label>
</div>,
<div
class="ant-qrcode"
style="margin-top:16px;width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
</div>,
]
`;

exports[`renders ./components/qr-code/demo/logo.tsx extend context correctly 1`] = `
<div
class="ant-qrcode"
style="width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
<img
src="https://gw.alipayobjects.com/zos/antfincdn/%24C9tmj978R/Carousel.svg"
style="display:none"
/>
</div>
`;
177 changes: 143 additions & 34 deletions components/qr-code/__test__/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,44 +1,153 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<QrCode /> renders download.tsx correctly 1`] = `
<DocumentFragment>
exports[`renders ./components/qr-code/demo/base.tsx correctly 1`] = `
<div
class="ant-qrcode"
style="width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
</div>
`;

exports[`renders ./components/qr-code/demo/download.tsx correctly 1`] = `
<div
id="myqrcode"
>
<div
class="ant-qrcode"
style="width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
</div>
<button
class="ant-btn ant-btn-default"
style="margin-block-start:16px"
type="button"
>
<span>
下载二维码
</span>
</button>
</div>
`;

exports[`renders ./components/qr-code/demo/errorlevel.tsx correctly 1`] = `
Array [
<div
id="myqrcode"
class="ant-radio-group ant-radio-group-outline"
>
<div
class="tech-qrcode"
style="width: 128px; height: 128px;"
<label
class="ant-radio-button-wrapper ant-radio-button-wrapper-checked"
>
<canvas
height="128"
ke="http://www.baidu.com"
style="height: 128px; width: 128px;"
width="128"
/>
</div>
<button
class="ant-btn ant-btn-default"
style="margin-block-start: 16px;"
type="button"
<span
class="ant-radio-button ant-radio-button-checked"
>
<input
checked=""
class="ant-radio-button-input"
type="radio"
value="L"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
L
</span>
</label>
<label
class="ant-radio-button-wrapper"
>
<span
class="ant-radio-button"
>
<input
class="ant-radio-button-input"
type="radio"
value="M"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
下载二维码
M
</span>
</button>
</div>
</DocumentFragment>
</label>
<label
class="ant-radio-button-wrapper"
>
<span
class="ant-radio-button"
>
<input
class="ant-radio-button-input"
type="radio"
value="Q"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
Q
</span>
</label>
<label
class="ant-radio-button-wrapper"
>
<span
class="ant-radio-button"
>
<input
class="ant-radio-button-input"
type="radio"
value="H"
/>
<span
class="ant-radio-button-inner"
/>
</span>
<span>
H
</span>
</label>
</div>,
<div
class="ant-qrcode"
style="margin-top:16px;width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
</div>,
]
`;

exports[`<QrCode /> renders errorlevel.tsx correctly 1`] = `<DocumentFragment />`;

exports[`<QrCode /> renders logo.tsx correctly 1`] = `<DocumentFragment />`;

exports[`<QrCode /> renders outdated.tsx correctly 1`] = `<DocumentFragment />`;

exports[`<QrCode /> renders popover.tsx correctly 1`] = `<DocumentFragment />`;

exports[`<QrCode /> renders refresh.tsx correctly 1`] = `<DocumentFragment />`;

exports[`<QrCode /> renders rendermode.tsx correctly 1`] = `<DocumentFragment />`;

exports[`<QrCode /> renders withoutlogo.tsx correctly 1`] = `<DocumentFragment />`;
exports[`renders ./components/qr-code/demo/logo.tsx correctly 1`] = `
<div
class="ant-qrcode"
style="width:128px;height:128px"
>
<canvas
height="128"
style="height:128px;width:128px"
width="128"
/>
<img
src="https://gw.alipayobjects.com/zos/antfincdn/%24C9tmj978R/Carousel.svg"
style="display:none"
/>
</div>
`;
16 changes: 16 additions & 0 deletions components/qr-code/__test__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`QrCode test rtl render component should be rendered correctly in RTL direction 1`] = `null`;

exports[`QrCode test should correct render 1`] = `
<div
class="ant-qrcode"
style="width: 128px; height: 128px;"
>
<canvas
height="128"
style="height: 128px; width: 128px;"
width="128"
/>
</div>
`;
3 changes: 3 additions & 0 deletions components/qr-code/__test__/demo-extend.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { extendTest } from '../../../tests/shared/demoTest';

extendTest('qr-code');
4 changes: 2 additions & 2 deletions components/qr-code/__test__/demo.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import demoTest from '../../../tests/demo';
import demoTest from '../../../tests/shared/demoTest';

demoTest('QrCode');
demoTest('qr-code');
5 changes: 5 additions & 0 deletions components/qr-code/__test__/image.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { imageDemoTest } from '../../../tests/shared/imageTest';

describe('QrCode image', () => {
imageDemoTest('qr-code');
});

0 comments on commit a974d94

Please sign in to comment.