Off-canvas tablist

This commit is contained in:
Ken-Håvard Lieng 2015-06-10 00:24:14 +02:00
parent 27552a2e9c
commit 29c13f4f54
11 changed files with 128 additions and 42 deletions

File diff suppressed because one or more lines are too long

View File

@ -39,6 +39,7 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
background: #222; background: #222;
color: #FFF; color: #FFF;
font-family: Montserrat, sans-serif; font-family: Montserrat, sans-serif;
transition: transform .2s;
} }
.tab-container { .tab-container {
@ -114,17 +115,31 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
background: #1D1D1D; background: #1D1D1D;
} }
.main-container {
position: fixed;
left: 200px;
top: 0;
bottom: 0;
right: 0;
transition: left .2s, transform .2s;
}
.connect { .connect {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
position: fixed; position: absolute;
top: 0; top: 0;
left: 200px; width: 100%;
right: 0;
bottom: 0; bottom: 0;
} }
.connect .navicon {
position: absolute;
top: 0;
left: 0;
}
.connect-form h1 { .connect-form h1 {
font: 32px Montserrat, sans-serif; font: 32px Montserrat, sans-serif;
margin-bottom: 15px; margin-bottom: 15px;
@ -185,12 +200,11 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
.chat-title-bar { .chat-title-bar {
font-family: Montserrat, sans-serif; font-family: Montserrat, sans-serif;
position: fixed; position: absolute;
left: 200px; left: 0;
top: 0; top: 0;
right: 0; right: 0;
height: 50px; height: 50px;
padding-left: 15px;
line-height: 50px; line-height: 50px;
border-bottom: 1px solid #DDD; border-bottom: 1px solid #DDD;
display: flex; display: flex;
@ -201,6 +215,14 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
right: 200px; right: 200px;
} }
.navicon {
display: none;
padding: 0 15px;
line-height: 50px;
font-size: 20px;
cursor: pointer;
}
.chat-title-bar i { .chat-title-bar i {
padding: 0 15px; padding: 0 15px;
cursor: pointer; cursor: pointer;
@ -223,6 +245,7 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.chat-title { .chat-title {
margin-left: 15px;
font-size: 24px; font-size: 24px;
white-space: nowrap; white-space: nowrap;
} }
@ -254,7 +277,7 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.userlist-bar { .userlist-bar {
position: fixed; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
width: 200px; width: 200px;
@ -273,7 +296,7 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
.search { .search {
display: none; display: none;
position: fixed; position: absolute;
left: 200px; left: 200px;
top: 50px; top: 50px;
bottom: 50px; bottom: 50px;
@ -302,8 +325,8 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.messagebox { .messagebox {
position: fixed; position: absolute;
left: 200px; left: 0;
top: 50px; top: 50px;
bottom: 50px; bottom: 50px;
right: 0; right: 0;
@ -341,9 +364,9 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.message-input-wrap { .message-input-wrap {
position: fixed; position: absolute;
left: 200px; left: 0;
bottom: 0px; bottom: 0;
right: 0; right: 0;
height: 50px; height: 50px;
z-index: 1; z-index: 1;
@ -357,7 +380,7 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
} }
.userlist { .userlist {
position: fixed; position: absolute;
top: 50px; top: 50px;
bottom: 50px; bottom: 50px;
right: 0; right: 0;
@ -378,3 +401,31 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
.userlist p:hover { .userlist p:hover {
background: #DDD; background: #DDD;
} }
@media (max-width: 600px) {
.tablist {
width: 200px;
transform: translateX(-200px);
}
.main-container {
transform: translateX(0);
left: 0;
}
.navicon {
display: inline-block;
}
.main-container.off-canvas {
transform: translateX(200px);
}
.tablist.off-canvas {
transform: translateX(0);
}
.chat-title {
margin-left: 0;
}
}

View File

@ -1,7 +1,9 @@
var Reflux = require('reflux'); var Reflux = require('reflux');
var tabActions = Reflux.createActions([ var tabActions = Reflux.createActions([
'select' 'select',
'hideMenu',
'toggleMenu'
]); ]);
module.exports = tabActions; module.exports = tabActions;

View File

@ -6,15 +6,24 @@ var Navigation = Router.Navigation;
var TabList = require('./TabList.jsx'); var TabList = require('./TabList.jsx');
var routeActions = require('../actions/route'); var routeActions = require('../actions/route');
var tabActions = require('../actions/tab');
var PureMixin = require('../mixins/pure'); var PureMixin = require('../mixins/pure');
var App = React.createClass({ var App = React.createClass({
mixins: [ mixins: [
PureMixin, PureMixin,
Navigation, Navigation,
Reflux.listenTo(routeActions.navigate, 'navigate') Reflux.listenTo(routeActions.navigate, 'navigate'),
Reflux.listenTo(tabActions.hideMenu, 'hideMenu'),
Reflux.listenTo(tabActions.toggleMenu, 'toggleMenu')
], ],
getInitialState() {
return {
menuToggled: false
};
},
navigate(path, replace) { navigate(path, replace) {
if (!replace) { if (!replace) {
this.transitionTo(path); this.transitionTo(path);
@ -23,12 +32,24 @@ var App = React.createClass({
} }
}, },
hideMenu() {
this.setState({ menuToggled: false });
},
toggleMenu() {
this.setState({ menuToggled: !this.state.menuToggled });
},
render() { render() {
var mainClass = this.state.menuToggled ? 'main-container off-canvas' : 'main-container';
return ( return (
<div> <div>
<TabList /> <TabList menuToggled={this.state.menuToggled} />
<div className={mainClass}>
<RouteHandler /> <RouteHandler />
</div> </div>
</div>
); );
} }
}); });

View File

@ -2,6 +2,7 @@ var React = require('react');
var Reflux = require('reflux'); var Reflux = require('reflux');
var Autolinker = require('autolinker'); var Autolinker = require('autolinker');
var Navicon = require('./Navicon.jsx');
var channelStore = require('../stores/channel'); var channelStore = require('../stores/channel');
var selectedTabStore = require('../stores/selectedTab'); var selectedTabStore = require('../stores/selectedTab');
var serverActions = require('../actions/server'); var serverActions = require('../actions/server');
@ -65,6 +66,7 @@ var ChatTitle = React.createClass({
return ( return (
<div> <div>
<div className="chat-title-bar"> <div className="chat-title-bar">
<Navicon />
<span className="chat-title">{tab.name}</span> <span className="chat-title">{tab.name}</span>
<div className="chat-topic-wrap"> <div className="chat-topic-wrap">
<span className="chat-topic" dangerouslySetInnerHTML={{ __html: topic }}></span> <span className="chat-topic" dangerouslySetInnerHTML={{ __html: topic }}></span>

View File

@ -1,6 +1,7 @@
var React = require('react'); var React = require('react');
var _ = require('lodash'); var _ = require('lodash');
var Navicon = require('./Navicon.jsx');
var serverActions = require('../actions/server'); var serverActions = require('../actions/server');
var channelActions = require('../actions/channel'); var channelActions = require('../actions/channel');
var PureMixin = require('../mixins/pure'); var PureMixin = require('../mixins/pure');
@ -59,6 +60,7 @@ var Connect = React.createClass({
return ( return (
<div className="connect"> <div className="connect">
<Navicon />
<form ref="form" className="connect-form" onSubmit={this.handleSubmit}> <form ref="form" className="connect-form" onSubmit={this.handleSubmit}>
<h1>Connect</h1> <h1>Connect</h1>
<input name="name" type="text" placeholder="Name" defaultValue="Freenode" /> <input name="name" type="text" placeholder="Name" defaultValue="Freenode" />

View File

@ -5,14 +5,12 @@ var inputHistoryStore = require('../stores/inputHistory');
var selectedTabStore = require('../stores/selectedTab'); var selectedTabStore = require('../stores/selectedTab');
var messageActions = require('../actions/message'); var messageActions = require('../actions/message');
var inputHistoryActions = require('../actions/inputHistory'); var inputHistoryActions = require('../actions/inputHistory');
var tabActions = require('../actions/tab');
var PureMixin = require('../mixins/pure'); var PureMixin = require('../mixins/pure');
var MessageInput = React.createClass({ var MessageInput = React.createClass({
mixins: [ mixins: [
PureMixin, PureMixin,
Reflux.connect(inputHistoryStore, 'history'), Reflux.connect(inputHistoryStore, 'history')
Reflux.listenTo(tabActions.select, 'tabSelected')
], ],
getInitialState() { getInitialState() {
@ -21,14 +19,6 @@ var MessageInput = React.createClass({
}; };
}, },
componentDidMount() {
this.refs.input.getDOMNode().focus();
},
tabSelected() {
this.refs.input.getDOMNode().focus();
},
handleKey(e) { handleKey(e) {
if (e.which === 13 && e.target.value) { if (e.which === 13 && e.target.value) {
var tab = selectedTabStore.getState(); var tab = selectedTabStore.getState();

View File

@ -0,0 +1,13 @@
var React = require('react');
var tabActions = require('../actions/tab');
var Navicon = React.createClass({
render() {
return (
<i className="icon-menu navicon" onClick={tabActions.toggleMenu}></i>
);
}
});
module.exports = Navicon;

View File

@ -1,10 +1,12 @@
var React = require('react'); var React = require('react');
var Navicon = require('./Navicon.jsx');
var Settings = React.createClass({ var Settings = React.createClass({
render() { render() {
return ( return (
<div> <div>
<h1>Settings</h1> <Navicon />
</div> </div>
); );
} }

View File

@ -25,6 +25,7 @@ var TabList = React.createClass({
}, },
render() { render() {
var className = this.props.menuToggled ? 'tablist off-canvas' : 'tablist';
var tabs = []; var tabs = [];
this.state.channels.forEach((server, address) => { this.state.channels.forEach((server, address) => {
@ -63,7 +64,7 @@ var TabList = React.createClass({
}); });
return ( return (
<div className="tablist"> <div className={className}>
<button className="button-connect" onClick={this.handleConnectClick}>Connect</button> <button className="button-connect" onClick={this.handleConnectClick}>Connect</button>
<div className="tab-container">{tabs}</div> <div className="tab-container">{tabs}</div>
<div className="side-buttons"> <div className="side-buttons">

View File

@ -159,6 +159,8 @@ var selectedTabStore = Reflux.createStore({
selectedTabStore.listen(tab => { selectedTabStore.listen(tab => {
var channel = tab.channel; var channel = tab.channel;
actions.hideMenu();
if (tab.server) { if (tab.server) {
if (channel) { if (channel) {
while (channel[0] === '#') { while (channel[0] === '#') {