Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: New Component Qr-Code #38891

Merged
merged 15 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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');
});