From 35c009b9e33a94009e43ee261a14037aec4cac10 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 31 Aug 2018 14:45:14 +0300 Subject: layout refresh --- vnext/src/components/Avatar.js | 21 +++++++--- vnext/src/components/Feeds.js | 11 +++++- vnext/src/components/Message.js | 24 +++++------- vnext/src/components/Thread.js | 49 ++++++++++------------- vnext/src/components/UserInfo.js | 85 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+), 50 deletions(-) create mode 100644 vnext/src/components/UserInfo.js (limited to 'vnext/src/components') diff --git a/vnext/src/components/Avatar.js b/vnext/src/components/Avatar.js index 0df0dbd7..f79d7b09 100644 --- a/vnext/src/components/Avatar.js +++ b/vnext/src/components/Avatar.js @@ -6,15 +6,26 @@ import { UserType } from './Types'; export default function Avatar(props) { return ( -
- - {`${props.user.uname}`} - +
+
+ + {`${props.user.uname}`} + +
+
+ + {props.children} +
); } Avatar.propTypes = { user: UserType, - link: PropTypes.string + link: PropTypes.string, + children: PropTypes.node }; diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js index 194af71c..a7833f67 100644 --- a/vnext/src/components/Feeds.js +++ b/vnext/src/components/Feeds.js @@ -8,6 +8,8 @@ import moment from 'moment'; import Message from './Message'; import Spinner from './Spinner'; +import UserInfo from './UserInfo'; + import { getMessages } from '../api'; import { UserType } from './Types'; @@ -38,7 +40,12 @@ export function Blog(props) { search: search, pageParam: search.search ? 'page' : 'before_mid' }; - return (); + return ( + <> + + + + ); } export function Tag(props) { @@ -75,7 +82,7 @@ class Feed extends React.Component { shouldComponentUpdate(nextProps, nextState) { return this.props.visitor.uid !== nextProps.visitor.uid - || this.state !== nextState || this.props.location !== nextProps.location; + || this.state !== nextState || this.props.location !== nextProps.location; } getSnapshotBeforeUpdate(prevProps) { diff --git a/vnext/src/components/Message.js b/vnext/src/components/Message.js index f091296b..b36936ba 100644 --- a/vnext/src/components/Message.js +++ b/vnext/src/components/Message.js @@ -13,20 +13,16 @@ export default function Message({ data, visitor, children, ...rest }) { return (
- - -
- - - -
+ +
+ + + +
+
diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index b0e73b40..2097a315 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -45,7 +45,7 @@ export default class Thread extends React.Component { .then(response => { let msg = response.data.shift(); this.setState({ - msg: {...msg}, + msg: { ...msg }, replies: response.data, loading: false, active: 0 @@ -100,29 +100,20 @@ export default class Thread extends React.Component {
  • - {!msg.user.banned ? ( - <> - - ) : ( - <> - [удалено]: - - ) - } - + + +

    = 0) }}>

    { @@ -149,10 +140,10 @@ export default class Thread extends React.Component {
  • )) : ( <> - {Array(loaders).fill().map((it, i) => )} - - ) - } + {Array(loaders).fill().map((it, i) => )} + + ) + } ); @@ -170,7 +161,7 @@ Thread.propTypes = { visitor: UserType.isRequired }; -function Recommendations({forMessage, ...rest}) { +function Recommendations({ forMessage, ...rest }) { const { likes, recommendations } = forMessage; return recommendations && recommendations.length > 0 && (
    {'Recommended by '} diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js new file mode 100644 index 00000000..147bb6f8 --- /dev/null +++ b/vnext/src/components/UserInfo.js @@ -0,0 +1,85 @@ +import React from 'react'; + +import { Link } from 'react-router-dom'; + +import { info } from '../api'; + +import Avatar from './Avatar'; +import Icon from './Icon'; +import SearchBox from './SearchBox'; + +export default class UserInfo extends React.Component { + constructor(props) { + super(props); + this.state = { + user: { uname: props.user, uid: 0 } + }; + } + componentDidMount() { + info(this.state.user.uname).then(response => { + this.setState({ + user: response.data[0] + }); + }); + } + render() { + const { user } = this.state; + return ( +
    + +
    Was online recently
    +
    +
    + { + user.uid > 0 && + <> +
      +
    • + + PM + +
    • +
    • + + Recommendations + +
    • +
    • + + Photos + +
    • +
    +
    + +
    +
    +
      + { + user.read && +
    • I read: {user.read.length}
    • + } +
    • My readers: {user.readers ? user.readers.length : 0}
    • + { + user.statsMyBL && +
    • My blacklist: {user.statsMyBL}
    • + } +
    • Messages: {user.statsMessages}
    • +
    • Comments: {user.statsReplies}
    • +
    + { + user.read && +
    + { + user.read.map(u => ) + } +
    + } +
    + + } +
    +
    + ); + } +} \ No newline at end of file -- cgit v1.2.3