Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d76c4f1

Browse files
author
Kerry Archibald
committed
add simple live share warning
Signed-off-by: Kerry Archibald <[email protected]>
1 parent 6ee54b6 commit d76c4f1

File tree

6 files changed

+150
-21
lines changed

6 files changed

+150
-21
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
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_LeftPanelLiveShareWarning {
18+
width: 100%;
19+
box-sizing: border-box;
20+
21+
padding: $spacing-4;
22+
text-align: center;
23+
24+
background-color: $accent;
25+
color: #fff;
26+
font-size: $font-10px;
27+
28+
// panel backdrops overlay the whole sidepanel
29+
// go above to get hover for title
30+
z-index: 1;
31+
}

res/css/structures/_LeftPanel.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ $roomListCollapsedWidth: 68px;
2323
}
2424
}
2525

26-
.mx_LeftPanel_wrapper {
26+
.mx_LeftPanel_outerWrapper {
2727
display: flex;
28+
flex-direction: column;
2829
max-width: 50%;
2930
position: relative;
3031

3132
// Contain the amount of layers rendered by constraining what actually needs re-layering via css
3233
contain: layout paint;
34+
}
35+
36+
.mx_LeftPanel_wrapper {
37+
display: flex;
38+
flex-direction: row;
39+
flex: 1;
3340

3441
.mx_LeftPanel_wrapper--user {
3542
background-color: $roomlist-bg-color;

res/css/structures/_MatrixChat.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ limitations under the License.
6363
}
6464

6565
/* not the left panel, and not the resize handle, so the roomview/groupview/... */
66-
.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(.mx_LeftPanel_wrapper) {
66+
.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(.mx_LeftPanel_outerWrapper) {
6767
background-color: $background;
6868

6969
flex: 1 1 0;

src/components/structures/LoggedInView.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import RightPanelStore from '../../stores/right-panel/RightPanelStore';
7575
import { TimelineRenderingType } from "../../contexts/RoomContext";
7676
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
7777
import { SwitchSpacePayload } from "../../dispatcher/payloads/SwitchSpacePayload";
78+
import LeftPanelLiveShareWarning from '../views/beacon/LeftPanelLiveShareWarning';
7879

7980
// We need to fetch each pinned message individually (if we don't already have it)
8081
// so each pinned message may trigger a request. Limit the number per room for sanity.
@@ -694,8 +695,10 @@ class LoggedInView extends React.Component<IProps, IState> {
694695
>
695696
<ToastContainer />
696697
<div className={bodyClasses}>
697-
<div className='mx_LeftPanel_wrapper'>
698-
{ SettingsStore.getValue('TagPanel.enableTagPanel') &&
698+
<div className='mx_LeftPanel_outerWrapper'>
699+
<LeftPanelLiveShareWarning isMinimized={this.props.collapseLhs || false} />
700+
<div className='mx_LeftPanel_wrapper'>
701+
{ SettingsStore.getValue('TagPanel.enableTagPanel') &&
699702
(<div className="mx_GroupFilterPanelContainer">
700703
<BackdropPanel
701704
blurMultiplier={0.5}
@@ -704,26 +707,27 @@ class LoggedInView extends React.Component<IProps, IState> {
704707
<GroupFilterPanel />
705708
{ SettingsStore.getValue("feature_custom_tags") ? <CustomRoomTagPanel /> : null }
706709
</div>)
707-
}
708-
{ SpaceStore.spacesEnabled ? <>
710+
}
711+
{ SpaceStore.spacesEnabled ? <>
712+
<BackdropPanel
713+
blurMultiplier={0.5}
714+
backgroundImage={this.state.backgroundImage}
715+
/>
716+
<SpacePanel />
717+
</> : null }
709718
<BackdropPanel
710-
blurMultiplier={0.5}
711719
backgroundImage={this.state.backgroundImage}
712720
/>
713-
<SpacePanel />
714-
</> : null }
715-
<BackdropPanel
716-
backgroundImage={this.state.backgroundImage}
717-
/>
718-
<div
719-
className="mx_LeftPanel_wrapper--user"
720-
ref={this._resizeContainer}
721-
data-collapsed={this.props.collapseLhs ? true : undefined}
722-
>
723-
<LeftPanel
724-
isMinimized={this.props.collapseLhs || false}
725-
resizeNotifier={this.props.resizeNotifier}
726-
/>
721+
<div
722+
className="mx_LeftPanel_wrapper--user"
723+
ref={this._resizeContainer}
724+
data-collapsed={this.props.collapseLhs ? true : undefined}
725+
>
726+
<LeftPanel
727+
isMinimized={this.props.collapseLhs || false}
728+
resizeNotifier={this.props.resizeNotifier}
729+
/>
730+
</div>
727731
</div>
728732
</div>
729733
<ResizeHandle passRef={this.resizeHandler} id="lp-resizer" />
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
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+
import classNames from 'classnames';
18+
import React from 'react';
19+
20+
import { useEventEmitterState } from '../../../hooks/useEventEmitter';
21+
import { _t } from '../../../languageHandler';
22+
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../stores/OwnBeaconStore';
23+
import { Icon as LiveLocationIcon } from '../../../../res/img/location/live-location.svg';
24+
25+
interface Props {
26+
isMinimized?: boolean;
27+
}
28+
29+
const LeftPanelLiveShareWarning: React.FC<Props> = ({ isMinimized }) => {
30+
const hasLiveBeacons = useEventEmitterState(
31+
OwnBeaconStore.instance,
32+
OwnBeaconStoreEvent.LivenessChange,
33+
() => OwnBeaconStore.instance.hasLiveBeacons(),
34+
);
35+
36+
if (!hasLiveBeacons) {
37+
return null;
38+
}
39+
40+
return <div
41+
className={classNames('mx_LeftPanelLiveShareWarning', {
42+
'mx_LeftPanelLiveShareWarning__minimized': isMinimized,
43+
})}
44+
title={isMinimized ? _t('You are sharing your live location') : undefined}
45+
>
46+
{ isMinimized ? <LiveLocationIcon height={10} /> : _t('You are sharing your live location') }
47+
</div>;
48+
};
49+
50+
export default LeftPanelLiveShareWarning;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
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+
import React from 'react';
18+
import { mount } from 'enzyme';
19+
20+
import '../../../skinned-sdk';
21+
import LeftPanelLiveShareWarning from '../../../../src/components/views/beacon/LeftPanelLiveShareWarning';
22+
23+
describe('<LeftPanelLiveShareWarning />', () => {
24+
const defaultProps = {};
25+
const getComponent = (props = {}) =>
26+
mount(<LeftPanelLiveShareWarning {...defaultProps} {...props} />);
27+
28+
it('renders correctly when not minimized', () => {
29+
const component = getComponent();
30+
expect(component).toMatchSnapshot();
31+
});
32+
33+
it('renders correctly when minimized', () => {
34+
const component = getComponent({ isMinimized: true });
35+
expect(component).toMatchSnapshot();
36+
});
37+
});

0 commit comments

Comments
 (0)