123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import React from 'react';
- import Avatar from 'misago/components/avatar'; // jshint ignore:line
- import Status, { StatusIcon, StatusLabel } from 'misago/components/user-status'; // jshint ignore:line
- export default class extends React.Component {
- getClassName() {
- if (this.props.user.rank.css_class) {
- return 'user-card user-card-' + this.props.user.rank.css_class + ' ui-ready';
- } else {
- return 'user-card ui-ready';
- }
- }
- getUserStatus() {
- if (this.props.showStatus) {
- if (this.props.user.status) {
- /* jshint ignore:start */
- return <Status user={this.props.user} status={this.props.user.status}>
- <StatusIcon user={this.props.user}
- status={this.props.user.status} />
- <StatusLabel user={this.props.user}
- status={this.props.user.status}
- className="status-label" />
- </Status>;
- /* jshint ignore:end */
- } else {
- /* jshint ignore:start */
- return <span className="user-status">
- <span className="status-icon ui-preview">
-
- </span>
- <span className="status-label ui-preview">
-
- </span>
- </span>;
- /* jshint ignore:end */
- }
- } else {
- return null;
- }
- }
- getRankName() {
- if (this.props.showRank) {
- if (this.props.user.rank.is_tab) {
- /* jshint ignore:start */
- return <a href={this.props.user.rank.absolute_url}
- className="item-title rank-name">
- {this.props.user.rank.name}
- </a>;
- /* jshint ignore:end */
- } else {
- /* jshint ignore:start */
- return <span className="item-title rank-name">
- {this.props.user.rank.name}
- </span>;
- /* jshint ignore:end */
- }
- } else {
- return null;
- }
- }
- getUserTitle() {
- if (this.props.user.title) {
- /* jshint ignore:start */
- return <span className="user-title">{this.props.user.title}</span>;
- /* jshint ignore:end */
- } else {
- return null;
- }
- }
- getUserJoinedOn() {
- /* jshint ignore:start */
- let title = interpolate(gettext("Joined on %(joined_on)s"), {
- 'joined_on': this.props.user.joined_on.format('LL, LT')
- }, true);
- let age = interpolate(gettext("Joined %(joined_on)s"), {
- 'joined_on': this.props.user.joined_on.fromNow()
- }, true);
- return <span className="user-joined-on" title={title}>
- {age}
- </span>;
- /* jshint ignore:end */
- }
- getPostsCount() {
- let message = ngettext(
- "%(posts)s post",
- "%(posts)s posts",
- this.props.user.posts);
- return interpolate(message, {
- 'posts': this.props.user.posts
- }, true);
- }
- getThreadsCount() {
- let message = ngettext(
- "%(threads)s thread",
- "%(threads)s threads",
- this.props.user.threads);
- return interpolate(message, {
- 'threads': this.props.user.threads
- }, true);
- }
- getFollowersCount() {
- let message = ngettext(
- "%(followers)s follower",
- "%(followers)s followers",
- this.props.user.followers);
- return interpolate(message, {
- 'followers': this.props.user.followers
- }, true);
- }
- render() {
- /* jshint ignore:start */
- return <div className={this.getClassName()}>
- <div className="user-card-bg-image">
- <Avatar user={this.props.user} size="400" className="bg-image" />
- <div className="user-card-bg">
- <div className="user-details">
- <div className="user-avatar">
- <a href={this.props.user.absolute_url}>
- <Avatar user={this.props.user} size="400" />
- </a>
- </div>
- <h4 className="user-name">
- <a href={this.props.user.absolute_url} className="item-title">
- {this.props.user.username}
- </a>
- </h4>
- <p className="user-subscript">
- {this.getUserStatus()}
- {this.getRankName()}
- {this.getUserTitle()}
- {this.getUserJoinedOn()}
- </p>
- </div>
- <div className="user-card-stats">
- <ul className="list-unstyled">
- <li className="user-posts-count">
- {this.getPostsCount()}
- </li>
- <li className="user-threads-count">
- {this.getThreadsCount()}
- </li>
- <li className="user-followers-count">
- {this.getFollowersCount()}
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>;
- /* jshint ignore:end */
- }
- }
|