File tree Expand file tree Collapse file tree 4 files changed +27
-15
lines changed
challenge-listing/Tooltips/UserAvatarTooltip Expand file tree Collapse file tree 4 files changed +27
-15
lines changed Original file line number Diff line number Diff line change 2020
2121import PT from 'prop-types' ;
2222import React from 'react' ;
23+ import _ from 'lodash' ;
2324import { themr } from 'react-css-themr' ;
2425import DefaultAvatar from '../../../assets/images/ico-user-default.svg' ;
2526import defaultStyle from './style.scss' ;
2627
27- function Avatar ( { theme, url } ) {
28+ function Avatar ( { theme, url, handleError } ) {
2829 return url
29- ? < img alt = "Avatar" src = { url } className = { theme . avatar } />
30+ ? < img alt = "Avatar" src = { url } className = { theme . avatar } onError = { handleError } />
3031 : < DefaultAvatar className = { theme . avatar } /> ;
3132}
3233
@@ -36,13 +37,15 @@ Avatar.defaultProps = {
3637 avatar : '' ,
3738 } ,
3839 url : null ,
40+ handleError : _ . noop ,
3941} ;
4042
4143Avatar . propTypes = {
4244 theme : PT . shape ( {
4345 avatar : PT . string . isRequired ,
4446 } ) ,
4547 url : PT . string ,
48+ handleError : PT . func ,
4649} ;
4750
4851export default themr ( 'Avatar' , defaultStyle ) ( Avatar ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import React, { Component } from 'react';
44import PT from 'prop-types' ;
55import './style.scss' ;
66
7+ import config from 'utils/config' ;
8+
79// Constants
810const VISIBLE_CHARACTERS = 3 ;
911const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' ;
@@ -27,7 +29,7 @@ class LeaderboardAvatar extends Component {
2729 render ( ) {
2830 const { domain, openNewTab, url } = this . props ;
2931 const { member } = this . state ;
30- const targetURL = url || `// ${ domain } /members/${ member . handle } ` ;
32+ const targetURL = url || `${ domain } /members/${ member . handle } ` ;
3133 return (
3234 < a
3335 href = { targetURL }
@@ -50,7 +52,7 @@ class LeaderboardAvatar extends Component {
5052}
5153
5254LeaderboardAvatar . defaultProps = {
53- domain : process . env . domain ,
55+ domain : config . URL . BASE ,
5456 member : { } ,
5557 openNewTab : false ,
5658 url : '' ,
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ import React, { Component } from 'react';
1111import PT from 'prop-types' ;
1212// import moment from 'moment';
1313import Tooltip from 'components/Tooltip' ;
14- import './style.scss' ;
14+ import Avatar from 'components/Avatar' ;
15+ import styles from './style.scss' ;
1516
16- const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' ;
1717/**
1818 * Renders the tooltip's content.
1919 * It includes: user profile picture, handle, his country and the TC registration
@@ -31,15 +31,19 @@ function Tip(props) {
3131 </span>
3232 )); */
3333 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+ }
3538
3639 return (
3740 < 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 }
4347 />
4448 < div styleName = "handle" > { props . user . handle } </ div >
4549 { /* Below block is commented out as it's not possible to get this information
@@ -86,7 +90,7 @@ class UserAvatarTooltip extends Component {
8690 }
8791 handleError ( ) {
8892 const user = this . state . user ;
89- user . photoLink = MOCK_PHOTO ;
93+ user . photoLink = null ;
9094 this . setState ( { user } ) ;
9195 }
9296
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ $avatar-radius-50: $corner-radius * 25;
88$avatar-radius-4 : $corner-radius * 2 ;
99
1010.user-avatar-tooltip {
11+ display : flex ;
12+ justify-content : space-between ;
13+ align-items : center ;
1114 max-width : 640px ;
1215 font-family : ' Roboto' ;
1316 overflow : auto ;
@@ -43,13 +46,13 @@ $avatar-radius-4: $corner-radius * 2;
4346
4447 .avatar {
4548 border-radius : $avatar-radius-50 ;
46- float : left ;
47- margin-right : $avatar-space-15 ;
4849 width : $base-unit * 10 ;
4950 height : $base-unit * 10 ;
51+ overflow : hidden ;
5052 }
5153
5254 .handle {
55+ margin-left : $avatar-space-15 ;
5356 display : inline-block ;
5457 font-weight : 500 ;
5558 font-size : 20px ;
You can’t perform that action at this time.
0 commit comments