File tree 4 files changed +27
-15
lines changed
challenge-listing/Tooltips/UserAvatarTooltip
4 files changed +27
-15
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import PT from 'prop-types' ;
22
22
import React from 'react' ;
23
+ import _ from 'lodash' ;
23
24
import { themr } from 'react-css-themr' ;
24
25
import DefaultAvatar from '../../../assets/images/ico-user-default.svg' ;
25
26
import defaultStyle from './style.scss' ;
26
27
27
- function Avatar ( { theme, url } ) {
28
+ function Avatar ( { theme, url, handleError } ) {
28
29
return url
29
- ? < img alt = "Avatar" src = { url } className = { theme . avatar } />
30
+ ? < img alt = "Avatar" src = { url } className = { theme . avatar } onError = { handleError } />
30
31
: < DefaultAvatar className = { theme . avatar } /> ;
31
32
}
32
33
@@ -36,13 +37,15 @@ Avatar.defaultProps = {
36
37
avatar : '' ,
37
38
} ,
38
39
url : null ,
40
+ handleError : _ . noop ,
39
41
} ;
40
42
41
43
Avatar . propTypes = {
42
44
theme : PT . shape ( {
43
45
avatar : PT . string . isRequired ,
44
46
} ) ,
45
47
url : PT . string ,
48
+ handleError : PT . func ,
46
49
} ;
47
50
48
51
export default themr ( 'Avatar' , defaultStyle ) ( Avatar ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import React, { Component } from 'react';
4
4
import PT from 'prop-types' ;
5
5
import './style.scss' ;
6
6
7
+ import config from 'utils/config' ;
8
+
7
9
// Constants
8
10
const VISIBLE_CHARACTERS = 3 ;
9
11
const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' ;
@@ -27,7 +29,7 @@ class LeaderboardAvatar extends Component {
27
29
render ( ) {
28
30
const { domain, openNewTab, url } = this . props ;
29
31
const { member } = this . state ;
30
- const targetURL = url || `// ${ domain } /members/${ member . handle } ` ;
32
+ const targetURL = url || `${ domain } /members/${ member . handle } ` ;
31
33
return (
32
34
< a
33
35
href = { targetURL }
@@ -50,7 +52,7 @@ class LeaderboardAvatar extends Component {
50
52
}
51
53
52
54
LeaderboardAvatar . defaultProps = {
53
- domain : process . env . domain ,
55
+ domain : config . URL . BASE ,
54
56
member : { } ,
55
57
openNewTab : false ,
56
58
url : '' ,
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ import React, { Component } from 'react';
11
11
import PT from 'prop-types' ;
12
12
// import moment from 'moment';
13
13
import Tooltip from 'components/Tooltip' ;
14
- import './style.scss' ;
14
+ import Avatar from 'components/Avatar' ;
15
+ import styles from './style.scss' ;
15
16
16
- const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' ;
17
17
/**
18
18
* Renders the tooltip's content.
19
19
* It includes: user profile picture, handle, his country and the TC registration
@@ -31,15 +31,19 @@ function Tip(props) {
31
31
</span>
32
32
)); */
33
33
const { photoLink } = props . user ;
34
- const src = photoLink . startsWith ( 'https' ) ? photoLink : `${ props . MAIN_URL } /${ photoLink } ` ;
34
+ let src = null ;
35
+ if ( photoLink ) {
36
+ src = photoLink . startsWith ( 'https' ) ? photoLink : `${ props . MAIN_URL } /${ photoLink } ` ;
37
+ }
35
38
36
39
return (
37
40
< div styleName = "user-avatar-tooltip" >
38
- < img
39
- alt = "User avatar"
40
- styleName = "avatar"
41
- src = { src }
42
- onError = { props . handleError }
41
+ < Avatar
42
+ theme = { {
43
+ avatar : styles . avatar ,
44
+ } }
45
+ url = { src }
46
+ handleError = { props . handleError }
43
47
/>
44
48
< div styleName = "handle" > { props . user . handle } </ div >
45
49
{ /* Below block is commented out as it's not possible to get this information
@@ -86,7 +90,7 @@ class UserAvatarTooltip extends Component {
86
90
}
87
91
handleError ( ) {
88
92
const user = this . state . user ;
89
- user . photoLink = MOCK_PHOTO ;
93
+ user . photoLink = null ;
90
94
this . setState ( { user } ) ;
91
95
}
92
96
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ $avatar-radius-50: $corner-radius * 25;
8
8
$avatar-radius-4 : $corner-radius * 2 ;
9
9
10
10
.user-avatar-tooltip {
11
+ display : flex ;
12
+ justify-content : space-between ;
13
+ align-items : center ;
11
14
max-width : 640px ;
12
15
font-family : ' Roboto' ;
13
16
overflow : auto ;
@@ -43,13 +46,13 @@ $avatar-radius-4: $corner-radius * 2;
43
46
44
47
.avatar {
45
48
border-radius : $avatar-radius-50 ;
46
- float : left ;
47
- margin-right : $avatar-space-15 ;
48
49
width : $base-unit * 10 ;
49
50
height : $base-unit * 10 ;
51
+ overflow : hidden ;
50
52
}
51
53
52
54
.handle {
55
+ margin-left : $avatar-space-15 ;
53
56
display : inline-block ;
54
57
font-weight : 500 ;
55
58
font-size : 20px ;
You can’t perform that action at this time.
0 commit comments