shrub/pkg/interface/chat/tile/tile.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-06-05 01:46:36 +03:00
import React, { Component } from 'react';
import classnames from 'classnames';
import _ from 'lodash';
2019-06-05 01:46:36 +03:00
export default class ChatTile extends Component {
render() {
const { props } = this;
let data = _.get(props.data, 'chat-configs', false);
let inviteNum = 0;
let msgNum = 0;
if (data) {
Object.keys(data).forEach((conf) => {
console.log(conf);
msgNum = msgNum + data[conf].length - data[conf].read;
});
2019-06-22 02:09:04 +03:00
}
let notificationsNum = inviteNum + msgNum;
let numNotificationsElem =
notificationsNum > 0 ? (
<p
2020-02-22 05:57:27 +03:00
className="absolute green2 white-d"
style={{
bottom: 6,
fontWeight: 400,
fontSize: 12,
lineHeight: "20px"
}}>
{notificationsNum > 99 ? "99+" : notificationsNum}
</p>
) : (
<div />
);
2019-06-05 01:46:36 +03:00
return (
2020-02-22 05:57:27 +03:00
<div className={"w-100 h-100 relative bg-white bg-gray0-d ba " +
"b--black b--gray1-d"}>
<a className="w-100 h-100 db pa2 no-underline" href="/~chat">
2020-02-22 05:57:27 +03:00
<p className="black white-d absolute f9" style={{left: 8, top: 8}}>Messaging</p>
<img
2020-02-22 05:57:27 +03:00
className="absolute invert-d"
style={{ left: 39, top: 39 }}
src="/~chat/img/Tile.png"
width={48}
height={48} />
{numNotificationsElem}
</a>
2019-06-05 01:46:36 +03:00
</div>
);
}
}
window['chat-viewTile'] = ChatTile;