Skip to content

Commit 8de01cf

Browse files
committed
cr util & config-provider & affix & alert
1 parent 0eef790 commit 8de01cf

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

components/_util/styleChecker.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function isStyleSupport(styleName) {
2+
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
3+
const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
4+
const { documentElement } = window.document;
5+
6+
return styleNameList.some(name => name in documentElement.style);
7+
}
8+
return false;
9+
}
10+
11+
export const isFlexSupported = isStyleSupport(['flex', 'webkitFlex', 'Flex', 'msFlex']);
12+
13+
export default isStyleSupport;

components/config-provider/index.en-US.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@ This component provides a configuration to all Vue components underneath itself
99
</a-config-provider>
1010
````
1111

12+
### Content Security Policy
13+
14+
Some component use dynamic style to support wave effect. You can config `csp` prop if Content Security Policy (CSP) is enabled:
15+
16+
```html
17+
<a-config-provider :csp="{ nonce: 'YourNonceCode' }">
18+
<a-button>My Button</a-button>
19+
</a-config-provider>
20+
```
21+
1222
## API
1323

1424
| Property | Description | Type | Default |
1525
| -------- | ----------- | ---- | ------- |
26+
| autoInsertSpaceInButton | Set `false` to remove space between 2 chinese characters on Button | boolean | true |
27+
| csp | Set [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) config | { nonce: string } | - |
28+
| renderEmpty | set empty content of components. Ref [Empty](/components/empty/) | slot-scope \| Function(componentName: string): ReactNode | - |
1629
| getPopupContainer | to set the container of the popup element. The default is to create a `div` element in `body`. | Function(triggerNode) | `() => document.body` |
30+
| prefixCls | set prefix class | string | ant |
31+

components/config-provider/index.zh-CN.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,31 @@
22

33
ConfigProvider 使用 Vue 的 [provide / inject](https://vuejs.org/v2/api/#provide-inject) 特性,只需在应用外围包裹一次即可全局生效。
44

5+
6+
7+
58
````html
69
<a-config-provider :getPopupContainer="getPopupContainer">
710
<app />
811
</a-config-provider>
912
````
1013

14+
### Content Security Policy
15+
16+
部分组件为了支持波纹效果,使用了动态样式。如果开启了 Content Security Policy (CSP),你可以通过 `csp` 属性来进行配置:
17+
18+
```html
19+
<a-config-provider :csp="{ nonce: 'YourNonceCode' }">
20+
<a-button>My Button</a-button>
21+
</a-config-provider>
22+
```
23+
1124
## API
1225

1326
| 参数 | 说明 | 类型 | 默认值 |
1427
| --- | --- | --- | --- |
28+
| autoInsertSpaceInButton | 设置为 `false` 时,移除按钮中 2 个汉字之间的空格 | boolean | true |
29+
| csp | 设置 [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) 配置 | { nonce: string } | - |
30+
| renderEmpty | 自定义组件空状态。参考 [空状态](/components/empty/) | slot-scope \| Function(componentName: string): VNode | - |
1531
| getPopupContainer | 弹出框(Select, Tooltip, Menu 等等)渲染父节点,默认渲染到 body 上。 | Function(triggerNode) | () => document.body |
32+
| prefixCls | 设置统一样式前缀 | string | ant |

components/config-provider/renderEmpty.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import PropTypes from '../_util/vue-types';
22
import Empty from '../empty';
33
import emptyImg from './empty.svg';
4-
import { ConfigConsumerProps } from '.';
4+
import { ConfigConsumerProps } from './';
55

66
const RenderEmpty = {
77
functional: true,

0 commit comments

Comments
 (0)