Add channel topic to ChatTitle, improve TabList layout

This commit is contained in:
Ken-Håvard Lieng 2015-05-23 04:38:43 +02:00
parent 9b9bef3695
commit b8a8ba2e08
4 changed files with 84 additions and 37 deletions

View File

@ -36,17 +36,28 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
top: 0; top: 0;
bottom: 0; bottom: 0;
width: 200px; width: 200px;
overflow: auto;
background: #222; background: #222;
color: #FFF; color: #FFF;
font-family: Montserrat, sans-serif; font-family: Montserrat, sans-serif;
} }
.tab-container {
position: absolute;
top: 50px;
bottom: 50px;
width: 100%;
overflow: auto;
}
.tablist p { .tablist p {
padding: 3px 15px; padding: 3px 15px;
cursor: pointer; cursor: pointer;
} }
.tablist p:last-child {
margin-bottom: 10px;
}
.tablist p:hover { .tablist p:hover {
background: #111; background: #111;
} }
@ -57,8 +68,8 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.tab-server { .tab-server {
color: #AAA; color: #999;
margin-top: 15px !important; margin-top: 10px !important;
} }
.button-connect { .button-connect {
@ -85,15 +96,22 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.side-buttons i { .side-buttons i {
display: inline-block;
color: #999; color: #999;
margin: 25px; width: 50%;
line-height: 40px; line-height: 50px;
cursor: pointer; cursor: pointer;
font-size: 20px; font-size: 20px;
border-top: 1px solid #1D1D1D;
}
.side-buttons i:not(:first-child) {
border-left: 1px solid #1D1D1D;
} }
.side-buttons i:hover { .side-buttons i:hover {
color: #FFF; color: #CCC;
background: #1D1D1D;
} }
.connect { .connect {
@ -205,8 +223,34 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.chat-title { .chat-title {
font-size: 28px; font-size: 24px;
white-space: nowrap;
}
.chat-topic-wrap {
flex: 1; flex: 1;
position: relative;
margin: 0 15px;
}
.chat-topic {
position: absolute;
width: 100%;
bottom: -4px;
font-size: 16px;
color: #999;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.chat-topic a {
color: #999;
text-decoration: none;
}
.chat-topic a:hover {
text-decoration: underline;
} }
.userlist-bar { .userlist-bar {

View File

@ -1,5 +1,6 @@
var React = require('react'); var React = require('react');
var Reflux = require('reflux'); var Reflux = require('reflux');
var Autolinker = require('autolinker');
var channelStore = require('../stores/channel'); var channelStore = require('../stores/channel');
var selectedTabStore = require('../stores/selectedTab'); var selectedTabStore = require('../stores/selectedTab');
@ -9,6 +10,14 @@ var searchActions = require('../actions/search');
var privateChatActions = require('../actions/privateChat'); var privateChatActions = require('../actions/privateChat');
var PureMixin = require('../mixins/pure'); var PureMixin = require('../mixins/pure');
function buildState(tab) {
return {
selectedTab: tab,
usercount: channelStore.getUsers(tab.server, tab.channel).size,
topic: channelStore.getTopic(tab.server, tab.channel)
};
}
var ChatTitle = React.createClass({ var ChatTitle = React.createClass({
mixins: [ mixins: [
PureMixin, PureMixin,
@ -17,25 +26,15 @@ var ChatTitle = React.createClass({
], ],
getInitialState() { getInitialState() {
var tab = selectedTabStore.getState(); return buildState(selectedTabStore.getState());
return {
usercount: channelStore.getUsers(tab.server, tab.channel).size,
selectedTab: tab
};
}, },
channelsChanged() { channelsChanged() {
var tab = this.state.selectedTab; this.setState(buildState(this.state.selectedTab));
this.setState({ usercount: channelStore.getUsers(tab.server, tab.channel).size });
}, },
selectedTabChanged(tab) { selectedTabChanged(tab) {
this.setState({ this.setState(buildState(tab));
selectedTab: tab,
usercount: channelStore.getUsers(tab.server, tab.channel).size
});
}, },
handleLeaveClick() { handleLeaveClick() {
@ -52,6 +51,7 @@ var ChatTitle = React.createClass({
render() { render() {
var tab = this.state.selectedTab; var tab = this.state.selectedTab;
var topic = Autolinker.link(this.state.topic || '', { keepOriginalText: true });
var leaveTitle; var leaveTitle;
if (!tab.channel) { if (!tab.channel) {
@ -66,6 +66,9 @@ var ChatTitle = React.createClass({
<div> <div>
<div className="chat-title-bar"> <div className="chat-title-bar">
<span className="chat-title">{tab.name}</span> <span className="chat-title">{tab.name}</span>
<div className="chat-topic-wrap">
<span className="chat-topic" dangerouslySetInnerHTML={{ __html: topic }}></span>
</div>
<i className="icon-search" title="Search" onClick={searchActions.toggle}></i> <i className="icon-search" title="Search" onClick={searchActions.toggle}></i>
<i <i
className="icon-logout button-leave" className="icon-logout button-leave"

View File

@ -66,7 +66,7 @@ var TabList = React.createClass({
return ( return (
<div className="tablist"> <div className="tablist">
<button className="button-connect" onClick={this.handleConnectClick}>Connect</button> <button className="button-connect" onClick={this.handleConnectClick}>Connect</button>
{tabs} <div className="tab-container">{tabs}</div>
<div className="side-buttons"> <div className="side-buttons">
<i className="icon-user"></i> <i className="icon-user"></i>
<i className="icon-cog" onClick={this.handleSettingsClick}></i> <i className="icon-cog" onClick={this.handleSettingsClick}></i>

File diff suppressed because one or more lines are too long