diff --git a/src/components/UserCard/UserCard.css b/src/components/UserCard/UserCard.css index 09611193..2af3e62a 100644 --- a/src/components/UserCard/UserCard.css +++ b/src/components/UserCard/UserCard.css @@ -1,11 +1,15 @@ @import '../../marketplace.css'; .root { +} + +.content { display: flex; flex-direction: row; } .avatar { + flex-shrink: 0; margin-right: 36px; } @@ -22,7 +26,12 @@ } } -.bio { +.link { + white-space: nowrap; +} + +.mobileBio, +.desktopBio { /* Preserve newlines, but collapse other whitespace */ white-space: pre-line; @@ -35,6 +44,20 @@ } } +.mobileBio { + @media (--viewportMedium) { + display: none; + } +} + +.desktopBio { + display: none; + + @media (--viewportMedium) { + display: block; + } +} + .showMore { margin-left: 5px; } @@ -51,4 +74,5 @@ .linkSeparator { margin: 0 10px; + color: var(--marketplaceColor); } diff --git a/src/components/UserCard/UserCard.example.js b/src/components/UserCard/UserCard.example.js index 178ad59b..b8533e37 100644 --- a/src/components/UserCard/UserCard.example.js +++ b/src/components/UserCard/UserCard.example.js @@ -5,24 +5,28 @@ import UserCard from './UserCard'; const { UUID } = types; export const EmptyUser = { - component: UserCard, - props: {}, - group: 'users', -}; - -export const WithUser = { component: UserCard, props: { - user: createUser('test-card-user'), + onContactUser: user => console.log('concact user:', user), }, group: 'users', }; -export const WithCurrentUser = { +export const WithoutBio = { + component: UserCard, + props: { + user: createUser('test-card-user'), + onContactUser: user => console.log('concact user:', user), + }, + group: 'users', +}; + +export const WithoutBioCurrentUser = { component: UserCard, props: { user: createUser('test-card-user'), currentUser: createCurrentUser('test-card-user'), + onContactUser: user => console.log('concact user:', user), }, group: 'users', }; @@ -63,7 +67,7 @@ export const WithProfileImageAndBio = { }, }, }, - currentUser: createCurrentUser('full-user'), + onContactUser: user => console.log('concact user:', user), }, group: 'users', }; diff --git a/src/components/UserCard/UserCard.js b/src/components/UserCard/UserCard.js index 84a326b1..4074bb7c 100644 --- a/src/components/UserCard/UserCard.js +++ b/src/components/UserCard/UserCard.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { string } from 'prop-types'; +import { string, func } from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { truncate } from 'lodash'; import classNames from 'classnames'; @@ -35,7 +35,7 @@ class ExpandableBio extends Component { } render() { const { expand } = this.state; - const { bio } = this.props; + const { className, bio } = this.props; const truncatedBio = truncated(bio); const handleShowMoreClick = () => { @@ -47,7 +47,7 @@ class ExpandableBio extends Component { ); return ( -
+
{expand ? bio : truncatedBio} {bio !== truncatedBio && !expand ? showMore : null}
@@ -55,45 +55,60 @@ class ExpandableBio extends Component { } } +ExpandableBio.defaultProps = { className: null }; + ExpandableBio.propTypes = { + className: string, bio: string.isRequired, }; const UserCard = props => { - const { rootClassName, className, user, currentUser } = props; + const { rootClassName, className, user, currentUser, onContactUser } = props; const ensuredUser = ensureUser(user); const ensuredCurrentUser = ensureCurrentUser(currentUser); const isCurrentUser = ensuredUser.id && ensuredCurrentUser.id && ensuredUser.id.uuid === ensuredCurrentUser.id.uuid; const { displayName, bio } = ensuredUser.attributes.profile; + const handleContactUserClick = () => { + onContactUser(user); + }; + const hasBio = !!bio; const classes = classNames(rootClassName || css.root, className); const linkClasses = classNames(css.links, { [css.withBioMissingAbove]: !hasBio, }); + + const separator = isCurrentUser ? null : •; + const contact = isCurrentUser ? null : ( +
+
- {ensuredUser.id ? (
-