Skip to content

Commit

Permalink
Merge pull request #2110 from vector-im/wmwragg/one-to-one-chat
Browse files Browse the repository at this point in the history
Wmwragg/one to one chat
  • Loading branch information
ara4n authored Sep 9, 2016
2 parents bf02a21 + ac36562 commit 8376f0d
Show file tree
Hide file tree
Showing 14 changed files with 455 additions and 63 deletions.
74 changes: 57 additions & 17 deletions src/components/structures/BottomLeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,88 @@ limitations under the License.
'use strict';

var React = require('react');
var ReactDOM = require('react-dom');
var sdk = require('matrix-react-sdk')
var dis = require('matrix-react-sdk/lib/dispatcher');

module.exports = React.createClass({
displayName: 'BottomLeftMenu',

propTypes: {
collapsed: React.PropTypes.bool.isRequired,
},

getInitialState: function() {
return({
roomsHover : false,
peopleHover : false,
settingsHover : false,
});
},

// Room events
onRoomsClick: function() {
dis.dispatch({action: 'view_create_room'});
},

onRoomsMouseEnter: function() {
this.setState({ roomsHover: true });
},

onRoomsMouseLeave: function() {
this.setState({ roomsHover: false });
},

// People events
onPeopleClick: function() {
dis.dispatch({action: 'view_create_chat'});
},

onPeopleMouseEnter: function() {
this.setState({ peopleHover: true });
},

onPeopleMouseLeave: function() {
this.setState({ peopleHover: false });
},

// Settings events
onSettingsClick: function() {
dis.dispatch({action: 'view_user_settings'});
},

onRoomDirectoryClick: function() {
dis.dispatch({action: 'view_room_directory'});
onSettingsMouseEnter: function() {
this.setState({ settingsHover: true });
},

onCreateRoomClick: function() {
dis.dispatch({action: 'view_create_room'});
onSettingsMouseLeave: function() {
this.setState({ settingsHover: false });
},

getLabel: function(name) {
if (!this.props.collapsed) {
return <div className="mx_RoomTile_name">{name}</div>
}
else if (this.state.hover) {
// Get the label/tooltip to show
getLabel: function(label, show) {
if (show) {
var RoomTooltip = sdk.getComponent("rooms.RoomTooltip");
return <RoomTooltip name={name}/>;
return <RoomTooltip className="mx_BottomLeftMenu_tooltip" label={label} />;
}
},

render: function() {
var BottomLeftMenuTile = sdk.getComponent('rooms.BottomLeftMenuTile');
var TintableSvg = sdk.getComponent('elements.TintableSvg');
return (
<div className="mx_BottomLeftMenu">
<div className="mx_BottomLeftMenu_options">
<div className="mx_BottomLeftMenu_createRoom" title="Start chat" onClick={ this.onCreateRoomClick }>
<TintableSvg src="img/icons-create-room.svg" width="25" height="25"/>
<div className="mx_BottomLeftMenu_createRoom" onClick={ this.onRoomsClick } onMouseEnter={ this.onRoomsMouseEnter } onMouseLeave={ this.onRoomsMouseLeave } >
<TintableSvg src="img/icons-create-room.svg" width="25" height="25" />
{ this.getLabel("Rooms", this.state.roomsHover) }
</div>
<div className="mx_BottomLeftMenu_directory" title="Room directory" onClick={ this.onRoomDirectoryClick }>
<TintableSvg src="img/icons-directory.svg" width="25" height="25"/>
<div className="mx_BottomLeftMenu_people" onClick={ this.onPeopleClick } onMouseEnter={ this.onPeopleMouseEnter } onMouseLeave={ this.onPeopleMouseLeave } >
<TintableSvg src="img/icons-people.svg" width="25" height="25" />
{ this.getLabel("New direct message", this.state.peopleHover) }
</div>
<div className="mx_BottomLeftMenu_settings" title="Settings" onClick={ this.onSettingsClick }>
<TintableSvg src="img/icons-settings.svg" width="25" height="25"/>
<div className="mx_BottomLeftMenu_settings" onClick={ this.onSettingsClick } onMouseEnter={ this.onSettingsMouseEnter } onMouseLeave={ this.onSettingsMouseLeave } >
<TintableSvg src="img/icons-settings.svg" width="25" height="25" />
{ this.getLabel("Settings", this.state.settingsHover) }
</div>
</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/components/structures/RoomSubList.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,18 @@ var RoomSubList = React.createClass({
badge = <div className={badgeClasses}>{subListNotifCount > 99 ? "99+" : subListNotifCount}</div>;
}

// When collapsed, allow a long hover on the header to show user
// the full tag name and room count
var title;
if (this.props.collapsed) {
title = this.props.label;
if (roomCount !== '') {
title += " [" + roomCount + "]";
}
}

return (
<div className="mx_RoomSubList_labelContainer" ref="header">
<div className="mx_RoomSubList_labelContainer" title={ title } ref="header">
<div onClick={ this.onClick } className="mx_RoomSubList_label">
{ this.props.collapsed ? '' : this.props.label }
<div className="mx_RoomSubList_roomCount">{roomCount}</div>
Expand Down
83 changes: 60 additions & 23 deletions src/components/views/rooms/RoomTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,79 @@ limitations under the License.

var React = require('react');
var ReactDOM = require('react-dom');

var dis = require('matrix-react-sdk/lib/dispatcher');

module.exports = React.createClass({
displayName: 'RoomTooltip',

propTypes: {
// Alllow the tooltip to be styled by the parent element
className: React.PropTypes.string.isRequired,
// The tooltip is derived from either the room name or a label
room: React.PropTypes.object,
label: React.PropTypes.string,
},

// Create a wrapper for the tooltip outside the parent and attach it to the body element
componentDidMount: function() {
var tooltip = ReactDOM.findDOMNode(this);
if (!this.props.bottom) {
// tell the roomlist about us so it can position us
dis.dispatch({
action: 'view_tooltip',
tooltip: tooltip,
});
}
else {
tooltip.style.top = (70 + tooltip.parentElement.getBoundingClientRect().top) + "px";
tooltip.style.display = "block";
}
this.tooltipContainer = document.createElement("div");
this.tooltipContainer.className = "mx_RoomTileTooltip_wrapper";
document.body.appendChild(this.tooltipContainer);

this._renderTooltip();
},

componentDidUpdate: function() {
this._renderTooltip();
},

// Remove the wrapper element, as the tooltip has finished using it
componentWillUnmount: function() {
if (!this.props.bottom) {
dis.dispatch({
action: 'view_tooltip',
tooltip: null,
});
}
dis.dispatch({
action: 'view_tooltip',
tooltip: null,
parent: null,
});

ReactDOM.unmountComponentAtNode(this.tooltipContainer);
document.body.removeChild(this.tooltipContainer);
},

render: function() {
_renderTooltip: function() {
var label = this.props.room ? this.props.room.name : this.props.label;

// Add the parent's position to the tooltips, so it's correctly
// positioned, also taking into account any window zoom
// NOTE: The additional 6 pixels for the left position, is to take account of the
// tooltips chevron
var parent = ReactDOM.findDOMNode(this);
var style = {};
style.top = parent.getBoundingClientRect().top + window.pageYOffset;
style.left = 6 + parent.getBoundingClientRect().right + window.pageXOffset;
style.display = "block";

var tooltip = (
<div className="mx_RoomTooltip" style={style} >
<div className="mx_RoomTooltip_chevron"></div>
{ label }
</div>
);

// Render the tooltip manually, as we wish it not to be rendered within the parent
this.tooltip = ReactDOM.render(tooltip, this.tooltipContainer);

// Tell the roomlist about us so it can manipulate us if it wishes
dis.dispatch({
action: 'view_tooltip',
tooltip: this.tooltip,
parent: parent,
});
},

render: function() {
// Render a placeholder
return (
<div className="mx_RoomTooltip">
<img className="mx_RoomTooltip_chevron" src="img/chevron-left.png" width="9" height="16"/>
{ label }
<div className={ this.props.className } >
</div>
);
}
Expand Down
12 changes: 9 additions & 3 deletions src/skins/vector/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ input[type=text]:focus, textarea:focus {
box-shadow: none;
}

/* Required by Firefox */
textarea {
font-family: 'Open Sans', Arial, Helvetica, Sans-Serif;
}

/* Prevent ugly dotted highlight around selected elements in Firefox */
::-moz-focus-inner {
border: 0;
Expand Down Expand Up @@ -198,14 +203,15 @@ input[type=text]:focus, textarea:focus {
height: 36px;
border-radius: 40px;
border: solid 1px #76cfa6;
font-weight: 400;
font-size: 15px;
font-weight: 600;
font-size: 14px;
font-family: 'Open Sans', Arial, Helvetica, Sans-Serif;
margin-left: 0px;
margin-right: 8px;
padding-left: 1.5em;
padding-right: 1.5em;
outline: none;

cursor: pointer;
color: #76cfa6;
background-color: #fff;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
Copyright 2016 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/* Using a textarea for this element, to circumvent autofill */
.mx_ChatInviteDialog_input,
.mx_ChatInviteDialog_input:focus
{
height: 26px;
font-size: 14px;
font-family: 'Open Sans', Arial, Helvetica, Sans-Serif;
padding-left: 12px;
padding-right: 12px;
margin: 0 !important;
border: 0 !important;
outline: 0 !important;
width: 1000%; /* Pretend that this is an "input type=text" */
resize: none;
overflow: hidden;
vertical-align: middle;
box-sizing: border-box;
word-wrap: nowrap;
}

.mx_ChatInviteDialog_inputContainer {
border-radius: 3px;
border: solid 1px #f0f0f0;
line-height: 36px;
padding-left: 4px;
padding-right: 4px;
padding-top: 1px;
padding-bottom: 1px;
overflow: hidden;
}

.mx_ChatInviteDialog_queryList {
position: absolute;
background-color: #fff;
width: 470px;
max-height: 116px;
overflow-y: scroll;
border-radius: 3px;
background-color: #fff;
border: solid 1px #76cfa6;
cursor: pointer;
}

.mx_ChatInviteDialog_queryListElement .mx_AddressTile {
background-color: #fff;
border: solid 1px #fff;
}

.mx_ChatInviteDialog_queryListElement.mx_ChatInviteDialog_selected {
background-color: #eaf5f0; /* selected colour */
}

.mx_ChatInviteDialog_queryListElement.mx_ChatInviteDialog_selected .mx_AddressTile {
background-color: #eaf5f0; /* selected colour */
border: solid 1px #eaf5f0; /* selected colour */
}

.mx_ChatInviteDialog_cancel {
position: absolute;
right: 11px;
top: 13px;
cursor: pointer;
}

.mx_ChatInviteDialog_cancel object {
pointer-events: none;
}
Loading

0 comments on commit 8376f0d

Please sign in to comment.