diff --git a/res/css/structures/_LeftPanel.scss b/res/css/structures/_LeftPanel.scss index 9cfe78d546..4bd6b1e816 100644 --- a/res/css/structures/_LeftPanel.scss +++ b/res/css/structures/_LeftPanel.scss @@ -18,7 +18,6 @@ $groupFilterPanelWidth: 56px; // only applies in this file, used for calculation $roomListCollapsedWidth: 68px; .mx_LeftPanel { - background-color: $roomlist-bg-color; // TODO decrease this once Spaces launches as it'll no longer need to include the 56px Community Panel min-width: 206px; max-width: 50%; diff --git a/res/css/structures/_MatrixChat.scss b/res/css/structures/_MatrixChat.scss index ca470e6cb4..77dc5f4454 100644 --- a/res/css/structures/_MatrixChat.scss +++ b/res/css/structures/_MatrixChat.scss @@ -39,10 +39,10 @@ limitations under the License. position: absolute; top: 0; left: 0; - width: 100%; min-height: 100%; z-index: 0; pointer-events: none; + overflow: hidden; } .mx_MatrixToolbar { @@ -76,7 +76,7 @@ limitations under the License. } /* not the left panel, and not the resize handle, so the roomview/groupview/... */ -.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle) { +.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(canvas) { background-color: $primary-bg-color; flex: 1 1 0; diff --git a/res/css/structures/_SpacePanel.scss b/res/css/structures/_SpacePanel.scss index 21c1bed18f..619c127f7b 100644 --- a/res/css/structures/_SpacePanel.scss +++ b/res/css/structures/_SpacePanel.scss @@ -24,7 +24,6 @@ $activeBorderColor: $secondary-fg-color; .mx_SpacePanel { flex: 0 0 auto; - background-color: $groupFilterPanel-bg-color; padding: 0; margin: 0; position: relative; diff --git a/src/components/structures/BackdropPanel.tsx b/src/components/structures/BackdropPanel.tsx index 61c8509adb..5493fff3a6 100644 --- a/src/components/structures/BackdropPanel.tsx +++ b/src/components/structures/BackdropPanel.tsx @@ -17,25 +17,44 @@ limitations under the License. import React, { createRef } from "react"; import "context-filter-polyfill"; +import UIStore from "../../stores/UIStore"; + interface IProps { - width?: number; - height?: number; backgroundImage?: CanvasImageSource; - blur?: string; - opacity?: number; } -export default class BackdropPanel extends React.PureComponent { - private canvasRef = createRef(); - private ctx: CanvasRenderingContext2D; +interface IState { + spacePanelWidth: number; + roomListWidth: number; + viewportHeight: number; +} - static defaultProps = { - blur: "60px", - opacity: .15, - }; +export default class BackdropPanel extends React.PureComponent { + private spacesCanvasRef = createRef(); + private roomListCanvasRef = createRef(); + + private spacesCtx: CanvasRenderingContext2D; + private roomListCtx: CanvasRenderingContext2D; + + constructor(props: IProps) { + super(props); + this.state = { + spacePanelWidth: 0, + roomListWidth: 0, + viewportHeight: UIStore.instance.windowHeight, + }; + } public componentDidMount() { - this.ctx = this.canvasRef.current.getContext("2d"); + this.spacesCtx = this.spacesCanvasRef.current.getContext("2d"); + this.roomListCtx = this.roomListCanvasRef.current.getContext("2d"); + UIStore.instance.on("SpacePanel", this.onResize); + UIStore.instance.on("LeftPanel", this.onResize); + } + + public componentWillUnmount() { + UIStore.instance.off("SpacePanel", this.onResize); + UIStore.instance.off("LeftPanel", this.onResize); } public componentDidUpdate() { @@ -44,15 +63,25 @@ export default class BackdropPanel extends React.PureComponent { } } + private onResize = () => { + const spacePanelDimensions = UIStore.instance.getElementDimensions("SpacePanel"); + const roomListDimensions = UIStore.instance.getElementDimensions("LeftPanel"); + this.setState({ + spacePanelWidth: spacePanelDimensions ? spacePanelDimensions.width : 0, + roomListWidth: roomListDimensions ? roomListDimensions.width : 0, + viewportHeight: UIStore.instance.windowHeight, + }); + }; + private refreshBackdropImage = (): void => { - const { width, height, backgroundImage } = this.props; - this.canvasRef.current.width = width; - this.canvasRef.current.height = height; + const width = this.state.spacePanelWidth + this.state.roomListWidth; + const height = this.state.viewportHeight; + const { backgroundImage } = this.props; const imageWidth = (backgroundImage as ImageBitmap).width - || (backgroundImage as HTMLImageElement).naturalWidth; + || (backgroundImage as HTMLImageElement).naturalWidth; const imageHeight = (backgroundImage as ImageBitmap).height - || (backgroundImage as HTMLImageElement).naturalHeight; + || (backgroundImage as HTMLImageElement).naturalHeight; const contentRatio = imageWidth / imageHeight; const containerRatio = width / height; @@ -69,23 +98,48 @@ export default class BackdropPanel extends React.PureComponent { const x = (width - resultWidth) / 2; const y = (height - resultHeight) / 2; - this.ctx.filter = `blur(${this.props.blur})`; - this.ctx.drawImage( + this.spacesCanvasRef.current.width = this.state.spacePanelWidth; + this.spacesCanvasRef.current.height = this.state.viewportHeight; + this.roomListCanvasRef.current.width = this.state.roomListWidth; + this.roomListCanvasRef.current.height = this.state.viewportHeight; + + this.spacesCtx.filter = `blur(30px)`; + this.roomListCtx.filter = `blur(60px)`; + this.spacesCtx.drawImage( backgroundImage, x, y, resultWidth, resultHeight, ); + this.roomListCtx.drawImage( + backgroundImage, + 0, 0, + imageWidth, imageHeight, + x - this.state.spacePanelWidth, + y, + resultWidth, + resultHeight, + ); }; public render() { - return ; + return <> + + + ; } } diff --git a/src/components/structures/GroupFilterPanel.js b/src/components/structures/GroupFilterPanel.js index 98ce3684c8..348e1fe497 100644 --- a/src/components/structures/GroupFilterPanel.js +++ b/src/components/structures/GroupFilterPanel.js @@ -30,7 +30,6 @@ import AutoHideScrollbar from "./AutoHideScrollbar"; import SettingsStore from "../../settings/SettingsStore"; import UserTagTile from "../views/elements/UserTagTile"; import { replaceableComponent } from "../../utils/replaceableComponent"; -import BackdropPanel from "./BackdropPanel"; import UIStore from "../../stores/UIStore"; @replaceableComponent("structures.GroupFilterPanel") @@ -153,14 +152,7 @@ class GroupFilterPanel extends React.Component { ); } - const panelDimensions = UIStore.instance.getElementDimensions("GroupPanel"); - return
- { if (this.state.showGroupFilterPanel) { leftLeftPanel = (
- + {SettingsStore.getValue("feature_custom_tags") ? : null}
); @@ -453,15 +451,8 @@ export default class LeftPanel extends React.Component { "mx_AutoHideScrollbar", ); - const panelDimensions = UIStore.instance.getElementDimensions("LeftPanel"); - return (
- {leftLeftPanel}