@@ -50,16 +50,16 @@ class Button extends React.Component {
50
50
} ) ;
51
51
}
52
52
53
- renderIcon ( ) {
54
- if ( this . props . iconName ) {
53
+ renderIcon ( name ) {
54
+ if ( this . props . iconName || this . props . notSelectedIcon || this . props . selectedIcon || this . props . selectedFocusIcon ) {
55
55
return (
56
56
< ButtonIcon
57
57
variant = { this . props . variant }
58
58
disabled = { this . props . disabled }
59
59
inverse = { this . props . inverse }
60
60
stateful = { this . props . stateful }
61
61
hint = { this . props . hint }
62
- name = { this . props . iconName }
62
+ name = { name }
63
63
size = { this . props . iconSize }
64
64
position = { this . props . iconPosition }
65
65
/>
@@ -88,15 +88,34 @@ class Button extends React.Component {
88
88
const labelClasses = this . props . variant === 'icon' ? 'slds-assistive-text' : '' ;
89
89
if ( this . props . disabled ) { props [ 'disabled' ] = 'disabled' } ;
90
90
91
- return (
92
- < button tabIndex = { this . props . tabindex } className = { this . getClassName ( ) } { ...props } onClick = { click } >
93
- { this . props . iconPosition === 'right' ? < span className = { labelClasses } > { this . props . label } </ span > : null }
94
- { this . renderIcon ( ) }
95
- { this . renderIconMore ( ) }
96
- { ( this . props . iconPosition === 'left' || ! this . props . iconPosition ) ? < span className = { labelClasses } > { this . props . label } </ span > : null }
97
- { this . props . children }
98
- </ button >
99
- ) ;
91
+ if ( this . props . stateful ) {
92
+ return (
93
+ < button tabIndex = { this . props . tabindex } className = { this . getClassName ( ) } { ...props } onClick = { click } >
94
+ < span className = "slds-text-not-selected" >
95
+ { this . renderIcon ( this . props . notSelectedIcon ) }
96
+ { this . props . notSelectedLabel }
97
+ </ span >
98
+ < span className = "slds-text-selected" >
99
+ { this . renderIcon ( this . props . selectedIcon ) }
100
+ { this . props . selectedLabel }
101
+ </ span >
102
+ < span className = "slds-text-selected-focus" >
103
+ { this . renderIcon ( this . props . selectedFocusIcon ) }
104
+ { this . props . selectedFocusLabel }
105
+ </ span >
106
+ </ button >
107
+ )
108
+ } else {
109
+ return (
110
+ < button tabIndex = { this . props . tabindex } className = { this . getClassName ( ) } { ...props } onClick = { click } >
111
+ { this . props . iconPosition === 'right' ? < span className = { labelClasses } > { this . props . label } </ span > : null }
112
+ { this . renderIcon ( this . props . iconName ) }
113
+ { this . renderIconMore ( ) }
114
+ { ( this . props . iconPosition === 'left' || ! this . props . iconPosition ) ? < span className = { labelClasses } > { this . props . label } </ span > : null }
115
+ { this . props . children }
116
+ </ button >
117
+ ) ;
118
+ }
100
119
}
101
120
}
102
121
@@ -113,6 +132,7 @@ Button.propTypes = {
113
132
iconVariant : React . PropTypes . oneOf ( [ 'bare' , 'container' , 'border' , 'border-filled' , 'small' , 'more' ] ) ,
114
133
iconSize : React . PropTypes . oneOf ( [ 'x-small' , 'small' , 'medium' , 'large' ] ) ,
115
134
iconPosition : React . PropTypes . oneOf ( [ 'left' , 'right' ] ) ,
135
+ onClick : React . PropTypes . func ,
116
136
}
117
137
118
138
module . exports = Button ;
0 commit comments