From bcebef7e5631e98e6ad7df5b2f1e5c082dbd3bbb Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 16 Jun 2020 12:13:12 -0600 Subject: [PATCH] Add a globe icon to public rooms For https://github.com/vector-im/riot-web/issues/14039 --- res/css/views/rooms/_RoomTile2.scss | 25 +++++++++++++++++++++ res/img/globe.svg | 6 +++++ src/components/views/rooms/RoomSublist2.tsx | 1 + src/components/views/rooms/RoomTile2.tsx | 13 +++++++++++ 4 files changed, 45 insertions(+) create mode 100644 res/img/globe.svg diff --git a/res/css/views/rooms/_RoomTile2.scss b/res/css/views/rooms/_RoomTile2.scss index f74d0ff5a4..2e9fe4a31e 100644 --- a/res/css/views/rooms/_RoomTile2.scss +++ b/res/css/views/rooms/_RoomTile2.scss @@ -32,6 +32,31 @@ limitations under the License. .mx_RoomTile2_avatarContainer { margin-right: 8px; + position: relative; + + .mx_RoomTile2_publicRoom { + width: 12px; + height: 12px; + border-radius: 12px; + background-color: $roomlist2-bg-color; // to match the room list itself + position: absolute; + bottom: 0; + right: 0; + + &::before { + content: ''; + width: 8px; + height: 8px; + top: 2px; + left: 2px; + position: absolute; + mask-position: center; + mask-size: contain; + mask-repeat: no-repeat; + background: $primary-fg-color; + mask-image: url('$(res)/img/globe.svg'); + } + } } .mx_RoomTile2_nameContainer { diff --git a/res/img/globe.svg b/res/img/globe.svg new file mode 100644 index 0000000000..cc22bc6e66 --- /dev/null +++ b/res/img/globe.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/components/views/rooms/RoomSublist2.tsx b/src/components/views/rooms/RoomSublist2.tsx index 9f8b8579c3..f03cb3ecbd 100644 --- a/src/components/views/rooms/RoomSublist2.tsx +++ b/src/components/views/rooms/RoomSublist2.tsx @@ -145,6 +145,7 @@ export default class RoomSublist2 extends React.Component { key={`room-${room.roomId}`} showMessagePreview={this.props.layout.showPreviews} isMinimized={this.props.isMinimized} + tag={this.props.layout.tagId} /> ); } diff --git a/src/components/views/rooms/RoomTile2.tsx b/src/components/views/rooms/RoomTile2.tsx index 10845d3840..f0d99eed99 100644 --- a/src/components/views/rooms/RoomTile2.tsx +++ b/src/components/views/rooms/RoomTile2.tsx @@ -44,6 +44,7 @@ interface IProps { room: Room; showMessagePreview: boolean; isMinimized: boolean; + tag: TagID; // TODO: Allow falsifying counts (for invites and stuff) // TODO: Transparency? Was this ever used? @@ -85,6 +86,12 @@ export default class RoomTile2 extends React.Component { ActiveRoomObserver.addListener(this.props.room.roomId, this.onActiveRoomUpdate); } + private get isPublicRoom(): boolean { + const joinRules = this.props.room.currentState.getStateEvents("m.room.join_rules", ""); + const joinRule = joinRules && joinRules.getContent().join_rule; + return joinRule === 'public'; + } + public componentWillUnmount() { if (this.props.room) { ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate); @@ -287,6 +294,11 @@ export default class RoomTile2 extends React.Component { ); if (this.props.isMinimized) nameContainer = null; + let globe = null; + if (this.isPublicRoom && this.props.tag !== DefaultTagID.DM) { + globe = ; // sizing and such set by CSS + } + const avatarSize = 32; return ( @@ -304,6 +316,7 @@ export default class RoomTile2 extends React.Component { >
+ {globe}
{nameContainer}