feat: prefixCls

pull/802/head
mingyan.yu 2019-05-25 22:43:44 +08:00
parent 04ac500c2e
commit f4c0384d97
4 changed files with 28 additions and 11 deletions

View File

@ -2,7 +2,6 @@ import * as moment from 'moment';
import interopDefault from '../_util/interopDefault'; import interopDefault from '../_util/interopDefault';
import { cloneElement } from '../_util/vnode'; import { cloneElement } from '../_util/vnode';
import { initDefaultProps } from '../_util/props-util'; import { initDefaultProps } from '../_util/props-util';
import Statistic, { StatisticProps } from './Statistic'; import Statistic, { StatisticProps } from './Statistic';
import { formatCountdown } from './utils'; import { formatCountdown } from './utils';
@ -15,7 +14,6 @@ function getTime(value) {
export default { export default {
name: 'AStatisticCountdown', name: 'AStatisticCountdown',
props: initDefaultProps(StatisticProps, { props: initDefaultProps(StatisticProps, {
prefixCls: 'ant-statistic',
format: 'HH:mm:ss', format: 'HH:mm:ss',
}), }),

View File

@ -1,6 +1,6 @@
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import { getComponentFromProp, initDefaultProps } from '../_util/props-util'; import { getComponentFromProp, initDefaultProps } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import StatisticNumber from './Number'; import StatisticNumber from './Number';
export const StatisticProps = { export const StatisticProps = {
@ -25,9 +25,20 @@ export default {
decimalSeparator: '.', decimalSeparator: '.',
groupSeparator: ',', groupSeparator: ',',
}), }),
inject: {
configProvider: { default: () => ({}) },
},
render() { render() {
const { prefixCls, value = 0, valueStyle, valueRender } = this.$props; const {
prefixCls: customizePrefixCls,
value = 0,
valueStyle,
valueRender,
} = this.$props;
const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls;
const prefixCls = getPrefixCls('statistic', customizePrefixCls);
const title = getComponentFromProp(this, 'title'); const title = getComponentFromProp(this, 'title');
let prefix = getComponentFromProp(this, 'prefix'); let prefix = getComponentFromProp(this, 'prefix');
let suffix = getComponentFromProp(this, 'suffix'); let suffix = getComponentFromProp(this, 'suffix');

View File

@ -1,6 +1,6 @@
## API ## API
#### Statistic ### Statistic
| Property | Description | Type | Default | | Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- |
@ -14,13 +14,17 @@
| value | Display value | string \| number | - | | value | Display value | string \| number | - |
#### Statistic.Countdown ### Statistic.Countdown
| Property | Description | Type | Default | | Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- |
| format | Format as [moment](http://momentjs.com/) | string | 'HH:mm:ss' | | format | Format as [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
| onFinish | Trigger when time's up | () => void | - |
| prefix | prefix node of value | string \| VNode | - | | prefix | prefix node of value | string \| VNode | - |
| suffix | suffix node of value | string \| VNode | - | | suffix | suffix node of value | string \| VNode | - |
| title | Display title | string \| VNode | - | | title | Display title | string \| VNode | - |
| value | Set target countdown time | number \| moment | - | | value | Set target countdown time | number \| moment | - |
#### Statistic.Countdown Events
| Events Name | Description | Arguments |
| --- | --- | --- |
| onFinish | Trigger when time's up | () => void | - |

View File

@ -1,6 +1,6 @@
## API ## API
#### Statistic ### Statistic
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- |
@ -13,13 +13,17 @@
| title | 数值的标题 | string \| VNode | - | | title | 数值的标题 | string \| VNode | - |
| value | 数值内容 | string \| number | - | | value | 数值内容 | string \| number | - |
#### Statistic.Countdown ### Statistic.Countdown
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- |
| format | 格式化倒计时展示,参考 [moment](http://momentjs.com/) | string | 'HH:mm:ss' | | format | 格式化倒计时展示,参考 [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
| onFinish | 倒计时完成时触发 | () => void | - |
| prefix | 设置数值的前缀 | string \| VNode | - | | prefix | 设置数值的前缀 | string \| VNode | - |
| suffix | 设置数值的后缀 | string \| VNode | - | | suffix | 设置数值的后缀 | string \| VNode | - |
| title | 数值的标题 | string \| VNode | - | | title | 数值的标题 | string \| VNode | - |
| value | 数值内容 | number \| moment | - | | value | 数值内容 | number \| moment | - |
#### Statistic.Countdown事件
| 事件名称 | 说明 | 回调参数 |
| --- | --- | --- |
| onFinish | 倒计时完成时触发 | () => void |