File tree 3 files changed +22
-11
lines changed
3 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import IconSettings from '../../icon-settings';
4
4
5
5
import logo from '../__examples__/logo.svg' ;
6
6
7
+ import Avatar from '../../avatar' ;
7
8
import GlobalHeader from '../../global-header' ;
8
9
import GlobalHeaderButton from '../../global-header/button' ;
9
10
import GlobalHeaderDropdown from '../../global-header/dropdown' ;
@@ -104,6 +105,7 @@ const GlobalHeaderDemo = (props) => (
104
105
openOn = { props . openOn }
105
106
onClick = { action ( 'Profile Clicked' ) }
106
107
onSelect = { action ( 'Profile Selected' ) }
108
+ avatar = { props . avatar }
107
109
>
108
110
< HeaderProfileCustomContent />
109
111
</ GlobalHeaderProfile >
@@ -132,4 +134,7 @@ storiesOf(GLOBAL_HEADER, module)
132
134
options = { [ { label : 'Profile Menu' } ] }
133
135
/>
134
136
</ GlobalHeader >
137
+ ) )
138
+ . add ( 'With custom <Avatar/>' , ( ) => (
139
+ < GlobalHeaderDemo avatar = { < Avatar variant = "user" label = "Art Vandelay" /> } />
135
140
) ) ;
Original file line number Diff line number Diff line change @@ -38,9 +38,9 @@ const GlobalHeaderDropdownTrigger = createReactClass({
38
38
// ### Prop Types
39
39
propTypes : {
40
40
/**
41
- * An image URL to display for the user profile.
41
+ * An image URL or avatar node to display for the user profile.
42
42
*/
43
- avatar : PropTypes . string ,
43
+ avatar : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) ,
44
44
/**
45
45
* CSS classes to be added to `li` element.
46
46
*/
@@ -107,11 +107,22 @@ const GlobalHeaderDropdownTrigger = createReactClass({
107
107
triggerRef : PropTypes . func ,
108
108
} ,
109
109
110
+ renderAvatar ( ) {
111
+ const { avatar } = this . props ;
112
+ if ( typeof avatar === 'string' ) {
113
+ return (
114
+ < span className = "slds-avatar slds-avatar--circle slds-avatar--medium" >
115
+ < img src = { avatar } alt = "" />
116
+ </ span >
117
+ ) ;
118
+ }
119
+ return avatar || null ;
120
+ } ,
121
+
110
122
// ### Render
111
123
render ( ) {
112
124
// The following props are provided to the `li`, all others are passed into the `Button`
113
125
const {
114
- avatar,
115
126
className,
116
127
id,
117
128
isOpen,
@@ -128,7 +139,6 @@ const GlobalHeaderDropdownTrigger = createReactClass({
128
139
...rest
129
140
} = this . props ;
130
141
131
- // TODO: Add avatar component for use across multiple components
132
142
return (
133
143
/* eslint-disable jsx-a11y/no-static-element-interactions */
134
144
< li
@@ -162,11 +172,7 @@ const GlobalHeaderDropdownTrigger = createReactClass({
162
172
aria-haspopup = "true"
163
173
{ ...rest }
164
174
>
165
- { avatar ? (
166
- < span className = "slds-avatar slds-avatar--circle slds-avatar--medium" >
167
- < img src = { avatar } alt = "" />
168
- </ span >
169
- ) : null }
175
+ { this . renderAvatar ( ) }
170
176
</ Button >
171
177
{ menu }
172
178
</ li >
Original file line number Diff line number Diff line change @@ -70,9 +70,9 @@ GlobalHeaderProfile.propTypes = {
70
70
*/
71
71
className : PropTypes . string ,
72
72
/**
73
- * An image URL to display for the user profile.
73
+ * An image URL or avatar node to display for the user profile.
74
74
*/
75
- avatar : PropTypes . string ,
75
+ avatar : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) ,
76
76
/**
77
77
* CSS classes to be added to `li` element.
78
78
*/
You can’t perform that action at this time.
0 commit comments