Skip to content

Statistic Component #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/statistic/Countdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as moment from 'moment';
import interopDefault from '../_util/interopDefault';
import { cloneElement } from '../_util/vnode';
import { initDefaultProps } from '../_util/props-util';

import Statistic, { StatisticProps } from './Statistic';
import { formatCountdown } from './utils';

Expand All @@ -15,7 +14,6 @@ function getTime(value) {
export default {
name: 'AStatisticCountdown',
props: initDefaultProps(StatisticProps, {
prefixCls: 'ant-statistic',
format: 'HH:mm:ss',
}),

Expand Down
15 changes: 13 additions & 2 deletions components/statistic/Statistic.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from '../_util/vue-types';
import { getComponentFromProp, initDefaultProps } from '../_util/props-util';

import { ConfigConsumerProps } from '../config-provider';
import StatisticNumber from './Number';

export const StatisticProps = {
Expand All @@ -25,9 +25,20 @@ export default {
decimalSeparator: '.',
groupSeparator: ',',
}),
inject: {
configProvider: { default: () => ({}) },
},

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');
let prefix = getComponentFromProp(this, 'prefix');
let suffix = getComponentFromProp(this, 'suffix');
Expand Down
12 changes: 8 additions & 4 deletions components/statistic/index.en-US.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## API

#### Statistic
### Statistic

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
Expand All @@ -14,13 +14,17 @@
| value | Display value | string \| number | - |


#### Statistic.Countdown
### Statistic.Countdown

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| 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 | - |
| suffix | suffix node of value | 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 | - |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是finish

10 changes: 7 additions & 3 deletions components/statistic/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## API

#### Statistic
### Statistic

| 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- |
Expand All @@ -13,13 +13,17 @@
| title | 数值的标题 | string \| VNode | - |
| value | 数值内容 | string \| number | - |

#### Statistic.Countdown
### Statistic.Countdown

| 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- |
| format | 格式化倒计时展示,参考 [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
| onFinish | 倒计时完成时触发 | () => void | - |
| prefix | 设置数值的前缀 | string \| VNode | - |
| suffix | 设置数值的后缀 | string \| VNode | - |
| title | 数值的标题 | string \| VNode | - |
| value | 数值内容 | number \| moment | - |

#### Statistic.Countdown事件
| 事件名称 | 说明 | 回调参数 |
| --- | --- | --- |
| onFinish | 倒计时完成时触发 | () => void |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上