Skip to content

Commit 095da68

Browse files
committed
Add buttons to room sub list headers
1 parent 96c867b commit 095da68

5 files changed

Lines changed: 54 additions & 30 deletions

File tree

‎src/components/structures/RoomSubList.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
Copyright 2017 Vector Creations Ltd
23
Copyright 2015, 2016 OpenMarket Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
@@ -83,6 +84,7 @@ var RoomSubList = React.createClass({
8384
onShowMoreRooms: React.PropTypes.func,
8485
searchFilter: React.PropTypes.string,
8586
emptyContent: React.PropTypes.node, // content shown if the list is empty
87+
headerItems: React.PropTypes.node, // content shown in the sublist header
8688
},
8789

8890
getInitialState: function() {
@@ -522,6 +524,7 @@ var RoomSubList = React.createClass({
522524
roomNotificationCount={ this.roomNotificationCount() }
523525
onClick={ this.onClick }
524526
onHeaderClick={ this.props.onHeaderClick }
527+
headerItems={this.props.headerItems}
525528
/>
526529
{ subList }
527530
</div>
@@ -543,6 +546,7 @@ var RoomSubList = React.createClass({
543546
roomNotificationCount={ this.roomNotificationCount() }
544547
onClick={ this.onClick }
545548
onHeaderClick={ this.props.onHeaderClick }
549+
headerItems={this.props.headerItems}
546550
/>
547551
: undefined }
548552
{ (this.props.showSpinner && !this.state.hidden) ? <Loader /> : undefined }

‎src/components/structures/RoomSubListHeader.js‎

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
'use strict';
18-
19-
var React = require('react');
20-
var ReactDOM = require('react-dom');
21-
var classNames = require('classnames');
22-
var sdk = require('matrix-react-sdk')
23-
var FormattingUtils = require('matrix-react-sdk/lib/utils/FormattingUtils');
24-
var RoomNotifs = require('matrix-react-sdk/lib/RoomNotifs');
25-
var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton');
26-
var ConstantTimeDispatcher = require('matrix-react-sdk/lib/ConstantTimeDispatcher');
17+
import React from 'react';
18+
import classNames from 'classnames';
19+
import sdk from 'matrix-react-sdk';
20+
import FormattingUtils from 'matrix-react-sdk/lib/utils/FormattingUtils';
21+
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
2722

2823
module.exports = React.createClass({
2924
displayName: 'RoomSubListHeader',
@@ -42,6 +37,7 @@ module.exports = React.createClass({
4237
hidden: React.PropTypes.bool,
4338
onClick: React.PropTypes.func,
4439
onHeaderClick: React.PropTypes.func,
40+
headerItems: React.PropTypes.node, // content shown in the sublist header
4541
},
4642

4743
getDefaultProps: function() {
@@ -63,52 +59,52 @@ module.exports = React.createClass({
6359
// },
6460

6561
render: function() {
66-
var TintableSvg = sdk.getComponent("elements.TintableSvg");
62+
const TintableSvg = sdk.getComponent("elements.TintableSvg");
6763

68-
var subListNotifications = this.props.roomNotificationCount;
69-
var subListNotifCount = subListNotifications[0];
70-
var subListNotifHighlight = subListNotifications[1];
64+
const subListNotifications = this.props.roomNotificationCount;
65+
const subListNotifCount = subListNotifications[0];
66+
const subListNotifHighlight = subListNotifications[1];
7167

72-
var chevronClasses = classNames({
68+
const chevronClasses = classNames({
7369
'mx_RoomSubList_chevron': true,
7470
'mx_RoomSubList_chevronRight': this.props.hidden,
7571
'mx_RoomSubList_chevronDown': !this.props.hidden,
7672
});
7773

78-
var badgeClasses = classNames({
74+
const badgeClasses = classNames({
7975
'mx_RoomSubList_badge': true,
8076
'mx_RoomSubList_badgeHighlight': subListNotifHighlight,
8177
});
8278

83-
var badge;
79+
let badge;
8480
if (subListNotifCount > 0) {
8581
badge = <div className={badgeClasses}>{ FormattingUtils.formatCount(subListNotifCount) }</div>;
86-
}
87-
else if (subListNotifHighlight) {
82+
} else if (subListNotifHighlight) {
8883
badge = <div className={badgeClasses}>!</div>;
8984
}
9085

9186
// When collapsed, allow a long hover on the header to show user
9287
// the full tag name and room count
93-
var title;
94-
var roomCount = this.props.roomCount;
88+
let title;
89+
const roomCount = this.props.roomCount;
9590
if (this.props.collapsed) {
9691
title = this.props.label;
9792
if (roomCount !== '') {
9893
title += " [" + roomCount + "]";
9994
}
10095
}
10196

102-
var incomingCall;
97+
let incomingCall;
10398
if (this.props.isIncomingCallRoom) {
104-
var IncomingCallBox = sdk.getComponent("voip.IncomingCallBox");
99+
const IncomingCallBox = sdk.getComponent("voip.IncomingCallBox");
105100
incomingCall = <IncomingCallBox className="mx_RoomSubList_incomingCall" incomingCall={ this.props.incomingCall }/>;
106101
}
107102

108103
return (
109104
<div className="mx_RoomSubList_labelContainer" title={ title } ref="header">
110105
<AccessibleButton onClick={ this.props.onClick } className="mx_RoomSubList_label" tabIndex="0">
111106
{ this.props.collapsed ? '' : this.props.label }
107+
{this.props.headerItems}
112108
<div className="mx_RoomSubList_roomCount">{ roomCount }</div>
113109
<div className={chevronClasses}></div>
114110
{ badge }

‎src/skins/vector/css/_components.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@import "./matrix-react-sdk/views/elements/_MemberEventListSummary.scss";
2828
@import "./matrix-react-sdk/views/elements/_ProgressBar.scss";
2929
@import "./matrix-react-sdk/views/elements/_RichText.scss";
30+
@import "./matrix-react-sdk/views/elements/_RoleButton.scss";
3031
@import "./matrix-react-sdk/views/login/_InteractiveAuthEntryComponents.scss";
3132
@import "./matrix-react-sdk/views/login/_ServerConfig.scss";
3233
@import "./matrix-react-sdk/views/messages/_MEmoteBody.scss";
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2107 Vector Creations Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_RoleButton {
18+
margin-left: 4px;
19+
margin-right: 4px;
20+
cursor: pointer;
21+
display: inline-block;
22+
}
23+
24+
.mx_RoleButton object {
25+
pointer-events: none;
26+
}

‎src/skins/vector/css/matrix-react-sdk/views/rooms/_RoomList.scss‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,20 @@ limitations under the License.
3939
z-index: 6;
4040
}
4141

42-
.mx_RoomList_greyedSubListLabel {
43-
color: #a2a2a2;
44-
}
45-
4642
.mx_RoomList_emptySubListTip {
4743
font-size: 13px;
4844
margin-left: 18px;
4945
margin-right: 18px;
5046
margin-top: 8px;
5147
margin-bottom: 7px;
5248
padding: 5px;
53-
border: 1px solid $accent-color;
49+
border: 1px dashed $accent-color;
5450
color: $primary-fg-color;
5551
background-color: $droptarget-bg-color;
5652
border-radius: 4px;
5753
}
5854

59-
.mx_RoomList_butonPreview {
60-
float: right;
55+
.mx_RoomList_headerButtons {
56+
position: absolute;
57+
right: 60px;
6158
}

0 commit comments

Comments
 (0)