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: update app demo #39347

Merged
merged 19 commits into from
Dec 14, 2022
Merged
80 changes: 42 additions & 38 deletions components/app/__tests__/__snapshots__/demo-extend.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders ./components/app/demo/message.tsx extend context correctly 1`] = `
exports[`renders ./components/app/demo/basic.tsx extend context correctly 1`] = `
<div
class="ant-app"
>
<button
class="ant-btn ant-btn-primary"
type="button"
<div
class="ant-space ant-space-horizontal ant-space-align-center"
>
<span>
Open message
</span>
</button>
</div>
`;

exports[`renders ./components/app/demo/modal.tsx extend context correctly 1`] = `
<div
class="ant-app"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open modal
</span>
</button>
</div>
`;

exports[`renders ./components/app/demo/notification.tsx extend context correctly 1`] = `
<div
class="ant-app"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open notification
</span>
</button>
<div
class="ant-space-item"
style="margin-right:8px"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open message
</span>
</button>
</div>
<div
class="ant-space-item"
style="margin-right:8px"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open modal
</span>
</button>
</div>
<div
class="ant-space-item"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open notification
</span>
</button>
</div>
</div>
</div>
`;
80 changes: 42 additions & 38 deletions components/app/__tests__/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders ./components/app/demo/message.tsx correctly 1`] = `
exports[`renders ./components/app/demo/basic.tsx correctly 1`] = `
<div
class="ant-app"
>
<button
class="ant-btn ant-btn-primary"
type="button"
<div
class="ant-space ant-space-horizontal ant-space-align-center"
>
<span>
Open message
</span>
</button>
</div>
`;

exports[`renders ./components/app/demo/modal.tsx correctly 1`] = `
<div
class="ant-app"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open modal
</span>
</button>
</div>
`;

exports[`renders ./components/app/demo/notification.tsx correctly 1`] = `
<div
class="ant-app"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open notification
</span>
</button>
<div
class="ant-space-item"
style="margin-right:8px"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open message
</span>
</button>
</div>
<div
class="ant-space-item"
style="margin-right:8px"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open modal
</span>
</button>
</div>
<div
class="ant-space-item"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open notification
</span>
</button>
</div>
</div>
</div>
`;
7 changes: 7 additions & 0 deletions components/app/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## zh-CN

获取 `message`,`notification`,`modal` 静态方法。

## en-US

Static method for `message`,`notification`,`modal`.
47 changes: 47 additions & 0 deletions components/app/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { App, Button, Space } from 'antd';

// Sub page
const MyPage = () => {
const { message, modal, notification } = App.useApp();

const showMessage = () => {
message.success('Success!');
};

const showModal = () => {
modal.warning({
title: 'This is a warning message',
content: 'some messages...some messages...',
});
};

const showNotification = () => {
notification.info({
message: `Notification topLeft`,
description: 'Hello, Ant Design!!',
placement: 'topLeft',
});
};

return (
<Space>
<Button type="primary" onClick={showMessage}>
Open message
</Button>
<Button type="primary" onClick={showModal}>
Open modal
</Button>
<Button type="primary" onClick={showNotification}>
Open notification
</Button>
</Space>
);
};

// Entry component
export default () => (
<App>
<MyPage />
</App>
);
7 changes: 0 additions & 7 deletions components/app/demo/message.md

This file was deleted.

24 changes: 0 additions & 24 deletions components/app/demo/message.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions components/app/demo/modal.md

This file was deleted.

27 changes: 0 additions & 27 deletions components/app/demo/modal.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions components/app/demo/notification.md

This file was deleted.

28 changes: 0 additions & 28 deletions components/app/demo/notification.tsx

This file was deleted.