diff --git a/src/components/ActiveChart/index.js b/src/components/ActiveChart/index.js index 916a322d70b3fae170720dd31f86eca0c27be906..42e1694dff7b00918588bb35b7e8ee918563d58f 100644 --- a/src/components/ActiveChart/index.js +++ b/src/components/ActiveChart/index.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; -import { NumberInfo, MiniArea } from '../Charts'; +import { MiniArea } from '../Charts'; +import NumberInfo from '../NumberInfo'; import { fixedZero } from '../../utils/utils'; import styles from './index.less'; @@ -46,9 +47,7 @@ export default class ActiveChart extends PureComponent { + 本周访问} + total={numeral(12321).format('0,0')} + status="up" + subTotal={17.1} + /> + 本周访问} + total={numeral(12321).format('0,0')} + status="up" + subTotal={17.1} + style={{ marginTop: 16 }} + /> + +, mountNode); +```` diff --git a/src/components/Charts/NumberInfo/index.js b/src/components/NumberInfo/index.js similarity index 64% rename from src/components/Charts/NumberInfo/index.js rename to src/components/NumberInfo/index.js index bdcba7f5954f16f13623e07b503a2cc7f598f97f..0b90cbd969e65f66e180c9bbe070416a8e5d7f7c 100644 --- a/src/components/Charts/NumberInfo/index.js +++ b/src/components/NumberInfo/index.js @@ -1,10 +1,11 @@ import React from 'react'; import { Icon } from 'antd'; import classNames from 'classnames'; - import styles from './index.less'; -export default ({ theme, title, subTitle, total, subTotal, status, suffix, ...rest }) => ( +export default ({ + theme, title, subTitle, total, subTotal, status, suffix, gap, ...rest +}) => (
- {title &&

{title}

} - {subTitle &&
{subTitle}
} -
+ {title &&
{title}
} + {subTitle &&
{subTitle}
} +
{total} {suffix && {suffix}} diff --git a/src/components/Charts/NumberInfo/index.less b/src/components/NumberInfo/index.less similarity index 86% rename from src/components/Charts/NumberInfo/index.less rename to src/components/NumberInfo/index.less index 8f221d9c93cb425169de29143e31c4b044e070f6..2545624d3c6d851061119fd6314d8cf90636a7e5 100644 --- a/src/components/Charts/NumberInfo/index.less +++ b/src/components/NumberInfo/index.less @@ -1,5 +1,5 @@ @import "~antd/lib/style/themes/default.less"; -@import "../../../utils/utils.less"; +@import "../../utils/utils.less"; .numberInfo { .suffix { @@ -8,22 +8,21 @@ font-style: normal; margin-left: 4px; } - h4 { + .numberInfoTitle { color: @text-color; font-size: @font-size-lg; margin-bottom: 16px; transition: all .3s; } - h6 { + .numberInfoSubTitle { color: @text-color-secondary; font-size: @font-size-base; - font-weight: normal; height: 22px; line-height: 22px; .textOverflow(); } - & > div { - margin-top: 8px; + .numberInfoValue { + margin-top: 4px; font-size: 0; .textOverflow(); & > span { @@ -48,7 +47,7 @@ } } .numberInfolight { - & > div { + .numberInfoValue { & > span { color: @text-color; } diff --git a/src/components/NumberInfo/index.md b/src/components/NumberInfo/index.md new file mode 100644 index 0000000000000000000000000000000000000000..05a9552d43f965879b13746c3c56f669815ce33f --- /dev/null +++ b/src/components/NumberInfo/index.md @@ -0,0 +1,19 @@ +--- +type: General +title: NumberInfo +subtitle: 数据文本 +cols: 1 +--- + +常用在数据卡片中,用于突出展示某个业务数据。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +title | 标题 | ReactNode\|string | - +subTitle | 子标题 | ReactNode\|string | - +total | 总量 | ReactNode\|string | - +status | 增加状态 | 'up'\/'down' | - +theme | 状态样式 | string | 'light' +gap | 设置数字和描述直接的间距(像素) | number | 8 diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 8640e23247ff3e135b21b62725de1cee7b316b61..3f69f798e1d5c9643a8d79674079694ef4f085bf 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -3,9 +3,10 @@ import { connect } from 'dva'; import { Row, Col, Icon, Card, Tabs, Table, Radio, DatePicker, Tooltip } from 'antd'; import numeral from 'numeral'; import { - ChartCard, yuan, MiniArea, MiniBar, MiniProgress, Field, Bar, Pie, NumberInfo, TimelineChart, + ChartCard, yuan, MiniArea, MiniBar, MiniProgress, Field, Bar, Pie, TimelineChart, } from '../../components/Charts'; import Trend from '../../components/Trend'; +import NumberInfo from '../../components/NumberInfo'; import { getTimeDistance } from '../../utils/utils'; import styles from './Analysis.less'; @@ -178,7 +179,8 @@ export default class Analysis extends Component { {data.cvr * 100}%} + gap={2} + total={`${data.cvr * 100}%`} theme={(currentKey !== data.name) && 'light'} /> @@ -370,6 +372,7 @@ export default class Analysis extends Component { } + gap={8} total={numeral(12321).format('0,0')} status="up" subTotal={17.1} @@ -386,6 +389,7 @@ export default class Analysis extends Component { total={2.7} status="down" subTotal={26.2} + gap={8} />