Skip to content

Commit

Permalink
Improvement: user picture indicator.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomeandrey committed May 15, 2019
1 parent bdfbf1c commit 5b3f28a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@ import AppContext from "../../../../../model/services/context/AppContext";
import {UserService} from "../../../../../model/services/core/UserService";

const UserPicture = props => {
const {user, scalable = true} = props, title = user.name, pictureUrl = UserService.composeUserPictureUrl(user);
const {hasIndicator = true} = props;
return (
hasIndicator
? <UserPictureWithIndicator {...props}/>
: <UserPictureWithoutIndicator {...props}/>
);
};

const UserPictureWithIndicator = props => {
return (
<AppContext.Consumer>
{context => (
<Indicator {...context} user={user}>
<div className="slds-avatar slds-avatar_large">
{scalable ? <ScalableImage title={title} src={pictureUrl}/> :
<Image title={title} src={pictureUrl}/>}
</div>
<Indicator {...context} user={props.user}>
<UserPictureWithoutIndicator {...props}/>
</Indicator>
)}
</AppContext.Consumer>
);
};

const UserPictureWithoutIndicator = props => {
const {user, scalable = true} = props, pictureUrl = UserService.composeUserPictureUrl(user), title = user.name;
return (
<div className="slds-avatar slds-avatar_large">
{scalable ? <ScalableImage title={title} src={pictureUrl}/> : <Image title={title} src={pictureUrl}/>}
</div>
);
};

export default UserPicture;
2 changes: 1 addition & 1 deletion src/components/common/model/SessionValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SessionValidator = ({isLoginEntry = false}) => WrappedComponent => {

render() {
const {renderComponent} = this.state;
return renderComponent ? <WrappedComponent {...this.props}/> : <Spinner variant="base" size="small"/>;
return renderComponent ? <WrappedComponent {...this.props}/> : <Spinner variant="brand" size="small"/>;
}
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default props => {
return (
<figure className="slds-image slds-image--card slds-m-top_medium">
<div className="slds-image__crop slds-image__crop--16-by-9 stretch">
<UserPicture user={user}/>
<UserPicture user={user} hasIndicator={false}/>
</div>
<figcaption className="slds-image__title slds-image__title--card">
<div className="slds-clearfix width-stretch">
Expand Down

0 comments on commit 5b3f28a

Please sign in to comment.