Skip to content

Commit f4c0384

Browse files
author
mingyan.yu
committed
feat: prefixCls
1 parent 04ac500 commit f4c0384

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

components/statistic/Countdown.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as moment from 'moment';
22
import interopDefault from '../_util/interopDefault';
33
import { cloneElement } from '../_util/vnode';
44
import { initDefaultProps } from '../_util/props-util';
5-
65
import Statistic, { StatisticProps } from './Statistic';
76
import { formatCountdown } from './utils';
87

@@ -15,7 +14,6 @@ function getTime(value) {
1514
export default {
1615
name: 'AStatisticCountdown',
1716
props: initDefaultProps(StatisticProps, {
18-
prefixCls: 'ant-statistic',
1917
format: 'HH:mm:ss',
2018
}),
2119

components/statistic/Statistic.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from '../_util/vue-types';
22
import { getComponentFromProp, initDefaultProps } from '../_util/props-util';
3-
3+
import { ConfigConsumerProps } from '../config-provider';
44
import StatisticNumber from './Number';
55

66
export const StatisticProps = {
@@ -25,9 +25,20 @@ export default {
2525
decimalSeparator: '.',
2626
groupSeparator: ',',
2727
}),
28+
inject: {
29+
configProvider: { default: () => ({}) },
30+
},
2831

2932
render() {
30-
const { prefixCls, value = 0, valueStyle, valueRender } = this.$props;
33+
const {
34+
prefixCls: customizePrefixCls,
35+
value = 0,
36+
valueStyle,
37+
valueRender,
38+
} = this.$props;
39+
const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls;
40+
const prefixCls = getPrefixCls('statistic', customizePrefixCls);
41+
3142
const title = getComponentFromProp(this, 'title');
3243
let prefix = getComponentFromProp(this, 'prefix');
3344
let suffix = getComponentFromProp(this, 'suffix');

components/statistic/index.en-US.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## API
22

3-
#### Statistic
3+
### Statistic
44

55
| Property | Description | Type | Default |
66
| -------- | ----------- | ---- | ------- |
@@ -14,13 +14,17 @@
1414
| value | Display value | string \| number | - |
1515

1616

17-
#### Statistic.Countdown
17+
### Statistic.Countdown
1818

1919
| Property | Description | Type | Default |
2020
| -------- | ----------- | ---- | ------- |
2121
| format | Format as [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
22-
| onFinish | Trigger when time's up | () => void | - |
2322
| prefix | prefix node of value | string \| VNode | - |
2423
| suffix | suffix node of value | string \| VNode | - |
2524
| title | Display title | string \| VNode | - |
26-
| value | Set target countdown time | number \| moment | - |
25+
| value | Set target countdown time | number \| moment | - |
26+
27+
#### Statistic.Countdown Events
28+
| Events Name | Description | Arguments |
29+
| --- | --- | --- |
30+
| onFinish | Trigger when time's up | () => void | - |

components/statistic/index.zh-CN.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## API
22

3-
#### Statistic
3+
### Statistic
44

55
| 参数 | 说明 | 类型 | 默认值 |
66
| -------- | ----------- | ---- | ------- |
@@ -13,13 +13,17 @@
1313
| title | 数值的标题 | string \| VNode | - |
1414
| value | 数值内容 | string \| number | - |
1515

16-
#### Statistic.Countdown
16+
### Statistic.Countdown
1717

1818
| 参数 | 说明 | 类型 | 默认值 |
1919
| -------- | ----------- | ---- | ------- |
2020
| format | 格式化倒计时展示,参考 [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
21-
| onFinish | 倒计时完成时触发 | () => void | - |
2221
| prefix | 设置数值的前缀 | string \| VNode | - |
2322
| suffix | 设置数值的后缀 | string \| VNode | - |
2423
| title | 数值的标题 | string \| VNode | - |
2524
| value | 数值内容 | number \| moment | - |
25+
26+
#### Statistic.Countdown事件
27+
| 事件名称 | 说明 | 回调参数 |
28+
| --- | --- | --- |
29+
| onFinish | 倒计时完成时触发 | () => void |

0 commit comments

Comments
 (0)