cr util & config-provider & affix & alert

pull/1162/head
tangjinzhou 2019-09-05 22:18:27 +08:00
parent 0eef790e6b
commit 8de01cf07e
4 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,13 @@
function isStyleSupport(styleName) {
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
const { documentElement } = window.document;
return styleNameList.some(name => name in documentElement.style);
}
return false;
}
export const isFlexSupported = isStyleSupport(['flex', 'webkitFlex', 'Flex', 'msFlex']);
export default isStyleSupport;

View File

@ -9,8 +9,23 @@ This component provides a configuration to all Vue components underneath itself
</a-config-provider>
````
### Content Security Policy
Some component use dynamic style to support wave effect. You can config `csp` prop if Content Security Policy (CSP) is enabled:
```html
<a-config-provider :csp="{ nonce: 'YourNonceCode' }">
<a-button>My Button</a-button>
</a-config-provider>
```
## API
| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| autoInsertSpaceInButton | Set `false` to remove space between 2 chinese characters on Button | boolean | true |
| csp | Set [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) config | { nonce: string } | - |
| renderEmpty | set empty content of components. Ref [Empty](/components/empty/) | slot-scope \| Function(componentName: string): ReactNode | - |
| getPopupContainer | to set the container of the popup element. The default is to create a `div` element in `body`. | Function(triggerNode) | `() => document.body` |
| prefixCls | set prefix class | string | ant |

View File

@ -2,14 +2,31 @@
ConfigProvider 使用 Vue 的 [provide / inject](https://vuejs.org/v2/api/#provide-inject) 特性,只需在应用外围包裹一次即可全局生效。
````html
<a-config-provider :getPopupContainer="getPopupContainer">
<app />
</a-config-provider>
````
### Content Security Policy
部分组件为了支持波纹效果,使用了动态样式。如果开启了 Content Security Policy (CSP),你可以通过 `csp` 属性来进行配置:
```html
<a-config-provider :csp="{ nonce: 'YourNonceCode' }">
<a-button>My Button</a-button>
</a-config-provider>
```
## API
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| autoInsertSpaceInButton | 设置为 `false` 时,移除按钮中 2 个汉字之间的空格 | boolean | true |
| csp | 设置 [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) 配置 | { nonce: string } | - |
| renderEmpty | 自定义组件空状态。参考 [空状态](/components/empty/) | slot-scope \| Function(componentName: string): VNode | - |
| getPopupContainer | 弹出框Select, Tooltip, Menu 等等)渲染父节点,默认渲染到 body 上。 | Function(triggerNode) | () => document.body |
| prefixCls | 设置统一样式前缀 | string | ant |

View File

@ -1,7 +1,7 @@
import PropTypes from '../_util/vue-types';
import Empty from '../empty';
import emptyImg from './empty.svg';
import { ConfigConsumerProps } from '.';
import { ConfigConsumerProps } from './';
const RenderEmpty = {
functional: true,