|
| 1 | +/* |
| 2 | + * |
| 3 | + * GithubUserCard |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +importReactfrom'react' |
| 8 | +importPropTypesfrom'prop-types' |
| 9 | + |
| 10 | +import{ICON_CMD}from'../../config' |
| 11 | + |
| 12 | +import{ |
| 13 | +Wrapper, |
| 14 | +PopAvatarWrapper, |
| 15 | +UserPopInfo, |
| 16 | +PopAvatar, |
| 17 | +Username, |
| 18 | +UserBio, |
| 19 | +UserLocation, |
| 20 | +UserCompany, |
| 21 | +LabelIcon, |
| 22 | +LabelText, |
| 23 | +}from'./styles' |
| 24 | + |
| 25 | +import{makeDebugger,nilOrEmpty}from'../../utils' |
| 26 | +/* eslint-disable no-unused-vars */ |
| 27 | +constdebug=makeDebugger('c:GithubUserCard:index') |
| 28 | +/* eslint-enable no-unused-vars */ |
| 29 | + |
| 30 | +constGithubUserCard=({ user})=>( |
| 31 | +<Wrapper> |
| 32 | +<PopAvatarWrapper> |
| 33 | +<PopAvatarsrc={user.avatar}/> |
| 34 | +</PopAvatarWrapper> |
| 35 | +<UserPopInfo> |
| 36 | +<Username>{user.nickname}</Username> |
| 37 | +{!nilOrEmpty(user.bio) ?<UserBio>{user.bio}</UserBio> :null} |
| 38 | +{!nilOrEmpty(user.location) ?( |
| 39 | +<UserLocation> |
| 40 | +<LabelIconsrc={`${ICON_CMD}/city_map.svg`}/> |
| 41 | +<LabelText>{user.location}</LabelText> |
| 42 | +</UserLocation> |
| 43 | +) :null} |
| 44 | +{!nilOrEmpty(user.company) ?( |
| 45 | +<UserCompany> |
| 46 | +<LabelIconsrc={`${ICON_CMD}/profile_company.svg`}/> |
| 47 | +<LabelText>{user.company}</LabelText> |
| 48 | +</UserCompany> |
| 49 | +) :null} |
| 50 | +</UserPopInfo> |
| 51 | +</Wrapper> |
| 52 | +) |
| 53 | + |
| 54 | +GithubUserCard.propTypes={ |
| 55 | +// https://www.npmjs.com/package/prop-types |
| 56 | +user:PropTypes.shape({ |
| 57 | +nickname:PropTypes.string.isRequired, |
| 58 | +avatar:PropTypes.string.isRequired, |
| 59 | +bio:PropTypes.string, |
| 60 | +location:PropTypes.string, |
| 61 | +company:PropTypes.string, |
| 62 | +}), |
| 63 | +} |
| 64 | + |
| 65 | +GithubUserCard.defaultProps={ |
| 66 | +user:{ |
| 67 | +location:'', |
| 68 | +company:'', |
| 69 | +bio:'', |
| 70 | +}, |
| 71 | +} |
| 72 | + |
| 73 | +exportdefaultGithubUserCard |