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/App.js | 60 ---------------------------- vnext/src/api/index.js | 2 +- 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 ++++++++++++++++++++++++++++++++++++++++ vnext/src/index.js | 4 +- vnext/src/style/main.css | 80 +++---------------------------------- vnext/src/views/index.html | 12 +++--- 10 files changed, 154 insertions(+), 194 deletions(-) create mode 100644 vnext/src/components/UserInfo.js (limited to 'vnext') diff --git a/vnext/src/App.js b/vnext/src/App.js index 955c1200..71dc3926 100644 --- a/vnext/src/App.js +++ b/vnext/src/App.js @@ -166,66 +166,6 @@ export default class App extends React.Component { } /> - diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index 90c8b15e..ab26a359 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -32,7 +32,7 @@ export function me(username = '', password = '') { } export function info(username) { - return client.get(`/info/${username}`); + return client.get(`/users?uname=${username}`); } export function getChats() { 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 diff --git a/vnext/src/index.js b/vnext/src/index.js index b9fc5f54..24fe9352 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -5,7 +5,7 @@ import App from './App'; let container = document.createElement('div'); ReactDOM.render(, container); -let body = document.getElementById('wrapper').parentNode; +let body = document.getElementById('content').parentNode; body.replaceChild(container.getElementsByTagName('header')[0], body.querySelector('#header')); -body.replaceChild(container.querySelector('#wrapper'), body.querySelector('#wrapper')); +body.replaceChild(container.querySelector('#content'), body.querySelector('#content')); diff --git a/vnext/src/style/main.css b/vnext/src/style/main.css index a5e0326d..913572dc 100644 --- a/vnext/src/style/main.css +++ b/vnext/src/style/main.css @@ -70,27 +70,10 @@ html { background: #f8f8f8; color: #222; } -#wrapper { - margin: 0 auto; - width: 1000px; - margin-top: 52px; -} -#column { - float: left; - margin-left: 10px; - overflow: hidden; - padding-top: 10px; - width: 240px; -} #content { - float: right; - margin: 12px 0 0 0; - width: 728px; -} -#minimal_content { margin: 0 auto; - min-width: 310px; - width: auto; + width: 728px; + margin-top: 62px; } noscript article { background-image: url("matrix.jpg"); @@ -135,7 +118,6 @@ body > header { transform: translateY(-100%); } #footer { - clear: both; color: #999; font-size: 10pt; margin: 40px; @@ -147,7 +129,6 @@ body > header { text-size-adjust: 100%; } body, - #wrapper, #topwrapper, #content, #footer { @@ -156,18 +137,9 @@ body > header { min-width: 310px; width: auto; } - #wrapper { - margin-top: 50px; - } body > header { margin-bottom: 15px; } - #column { - float: none; - margin: 0 10px; - padding-top: 0; - width: auto; - } } /* #endregion */ @@ -229,46 +201,6 @@ body > header { border-top: 1px solid #CCC; } -#column ul, -#column p, -#column hr { - margin: 10px 0; -} -#column li > a { - display: block; - height: 100%; - padding: 6px; -} -#column li > a:hover { - background-color: #fff; - box-shadow: 0 0 3px rgba(0, 0, 0, 0.16); - transition: background-color 0.2s ease-in; -} -#column .margtop { - margin-top: 15px; -} - -#column .tags { - background: #fff; - box-shadow: 0 0 3px rgba(0, 0, 0, 0.16); - line-height: 140%; - padding: 6px; - text-align: justify; -} -#column .inp { - background: #fff; - border: 1px solid #ddddd5; - outline: none !important; - padding: 4px; - width: 222px; -} -#column .tags h4 { - background: #eee; - border: 1px solid #eee; - color: #888; - display: block; - text-align: center; -} #ctitle { font-size: 14pt; } @@ -403,10 +335,9 @@ article .tags > a, margin-bottom: 0; } .msg-avatar { - float: left; - height: 48px; + min-height: 48px; margin-right: 10px; - width: 48px; + min-width: 48px; } .msg-avatar img { height: 48px; @@ -419,7 +350,6 @@ article .tags > a, line-height: 140%; margin-bottom: 12px; padding: 20px; - width: 640px; } .reply-new .msg-cont { border-right: 5px solid #0C0; @@ -542,7 +472,7 @@ article .tags > a, } @media screen and (max-width: 480px) { - #wrapper { + #content { margin-top: 104px; } #search { diff --git a/vnext/src/views/index.html b/vnext/src/views/index.html index 35a876ea..e5862bc1 100644 --- a/vnext/src/views/index.html +++ b/vnext/src/views/index.html @@ -44,15 +44,15 @@ -
    +
    -- cgit v1.2.3