ant-design/components/config-provider/demo/holderRender.tsx
叶枫 8950642664
feat: config support holderRender (#46596)
* feat: config support container

* feat: add test

* feat: reset demo

* feat: test

* feat: test

* feat: test

* feat: test

* feat: md

* feat: limit

* fix: prefix

* feat: limit

* feat: message support app config

* feat: notification support app config

* feat: add maxCount test

* feat: icons

* feat: 增加 2 个 todo

* feat: holderRender

* feat: md

* feat: message 兼容旧逻辑

* feat: notification 兼容完成

* feat: modal 兼容完成

* feat: 优化 modal

* feat: 优化代码

* feat: 优化代码

* feat: 给 CP 添加 demo

* feat: 优先级完成/demo迁移完成

* feat: review

* feat: review

* feat: 优化 modal 代码

* feat: 支持 rtl

* feat: 修改注释

* feat: 优化单测

* feat: 优先级注释

* feat: remove getPrefixCls

* feat: demo

* feat: demo

* feat: demo

---------

Co-authored-by: MadCcc <madccc@foxmail.com>
2024-01-02 17:43:27 +08:00

63 lines
1.8 KiB
TypeScript

import React, { useContext, useLayoutEffect } from 'react';
import { StyleProvider } from '@ant-design/cssinjs';
import { ExclamationCircleFilled } from '@ant-design/icons';
import { App, Button, ConfigProvider, message, Modal, notification, Space } from 'antd';
const Demo: React.FC = () => {
const { locale, theme } = useContext(ConfigProvider.ConfigContext);
useLayoutEffect(() => {
ConfigProvider.config({
holderRender: (children) => (
<StyleProvider hashPriority="high">
<ConfigProvider prefixCls="static" iconPrefixCls="icon" locale={locale} theme={theme}>
<App message={{ maxCount: 1 }} notification={{ maxCount: 1 }}>
{children}
</App>
</ConfigProvider>
</StyleProvider>
),
});
}, [locale, theme]);
return (
<div>
<Space>
<Button
type="primary"
onClick={() => {
message.info('This is a normal message');
}}
>
message
</Button>
<Button
type="primary"
onClick={() => {
notification.open({
message: 'Notification Title',
description:
'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
});
}}
>
notification
</Button>
<Button
type="primary"
onClick={() => {
Modal.confirm({
title: 'Do you Want to delete these items?',
icon: <ExclamationCircleFilled />,
content: 'Some descriptions',
});
}}
>
Modal
</Button>
</Space>
</div>
);
};
export default Demo;