1
- import _ from 'lodash'
2
1
import cx from 'classnames'
2
+ import _ from 'lodash'
3
3
import React , { PropTypes } from 'react'
4
4
5
5
import {
@@ -16,26 +16,36 @@ import StatisticLabel from './StatisticLabel'
16
16
import StatisticValue from './StatisticValue'
17
17
18
18
/**
19
- * A statistic emphasizes the current value of an attribute
19
+ * A statistic emphasizes the current value of an attribute.
20
20
*/
21
21
function Statistic ( props ) {
22
- const { children, className, color, floated, horizontal, inverted, label, size, text, value } = props
22
+ const {
23
+ children,
24
+ className,
25
+ color,
26
+ floated,
27
+ horizontal,
28
+ inverted,
29
+ label,
30
+ size,
31
+ text,
32
+ value,
33
+ } = props
34
+
23
35
const classes = cx (
24
36
'ui' ,
25
37
color ,
38
+ size ,
26
39
useValueAndKey ( floated , 'floated' ) ,
27
40
useKeyOnly ( horizontal , 'horizontal' ) ,
28
41
useKeyOnly ( inverted , 'inverted' ) ,
29
- size ,
30
- className ,
31
42
'statistic' ,
43
+ className ,
32
44
)
33
45
const rest = getUnhandledProps ( Statistic , props )
34
46
const ElementType = getElementType ( Statistic , props )
35
47
36
- if ( ! _ . isNil ( children ) ) {
37
- return < ElementType { ...rest } className = { classes } > { children } </ ElementType >
38
- }
48
+ if ( ! _ . isNil ( children ) ) return < ElementType { ...rest } className = { classes } > { children } </ ElementType >
39
49
40
50
return (
41
51
< ElementType { ...rest } className = { classes } >
@@ -48,11 +58,6 @@ function Statistic(props) {
48
58
Statistic . _meta = {
49
59
name : 'Statistic' ,
50
60
type : META . TYPES . VIEW ,
51
- props : {
52
- color : SUI . COLORS ,
53
- floated : SUI . FLOATS ,
54
- size : _ . without ( SUI . SIZES , 'big' , 'massive' , 'medium' ) ,
55
- } ,
56
61
}
57
62
58
63
Statistic . propTypes = {
@@ -66,10 +71,10 @@ Statistic.propTypes = {
66
71
className : PropTypes . string ,
67
72
68
73
/** A statistic can be formatted to be different colors. */
69
- color : PropTypes . oneOf ( Statistic . _meta . props . color ) ,
74
+ color : PropTypes . oneOf ( SUI . COLORS ) ,
70
75
71
76
/** A statistic can sit to the left or right of other content. */
72
- floated : PropTypes . oneOf ( Statistic . _meta . props . floated ) ,
77
+ floated : PropTypes . oneOf ( SUI . FLOATS ) ,
73
78
74
79
/** A statistic can present its measurement horizontally. */
75
80
horizontal : PropTypes . bool ,
@@ -81,7 +86,7 @@ Statistic.propTypes = {
81
86
label : customPropTypes . contentShorthand ,
82
87
83
88
/** A statistic can vary in size. */
84
- size : PropTypes . oneOf ( Statistic . _meta . props . size ) ,
89
+ size : PropTypes . oneOf ( _ . without ( SUI . SIZES , 'big' , 'massive' , 'medium' ) ) ,
85
90
86
91
/** Format the StatisticValue with smaller font size to fit nicely beside number values. */
87
92
text : PropTypes . bool ,
0 commit comments