temp
This commit is contained in:
parent
7f58a21aac
commit
94a5013beb
3 changed files with 43 additions and 41 deletions
|
@ -239,8 +239,10 @@ $voice-playback-button-fg-color: $message-body-panel-icon-fg-color;
|
||||||
$appearance-tab-border-color: $room-highlight-color;
|
$appearance-tab-border-color: $room-highlight-color;
|
||||||
|
|
||||||
// blur amounts for left left panel (only for element theme, used in _mods.scss)
|
// blur amounts for left left panel (only for element theme, used in _mods.scss)
|
||||||
$roomlist-background-blur-amount: 60px;
|
:root {
|
||||||
$groupFilterPanel-background-blur-amount: 30px;
|
--roomlist-background-blur-amount: 60px;
|
||||||
|
--groupFilterPanel-background-blur-amount: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
$composer-shadow-color: rgba(0, 0, 0, 0.28);
|
$composer-shadow-color: rgba(0, 0, 0, 0.28);
|
||||||
|
|
||||||
|
|
|
@ -362,9 +362,10 @@ $voice-playback-button-fg-color: $message-body-panel-icon-fg-color;
|
||||||
$appearance-tab-border-color: $input-darker-bg-color;
|
$appearance-tab-border-color: $input-darker-bg-color;
|
||||||
|
|
||||||
// blur amounts for left left panel (only for element theme, used in _mods.scss)
|
// blur amounts for left left panel (only for element theme, used in _mods.scss)
|
||||||
$roomlist-background-blur-amount: 40px;
|
:root {
|
||||||
$groupFilterPanel-background-blur-amount: 20px;
|
--roomlist-background-blur-amount: 40px;
|
||||||
|
--groupFilterPanel-background-blur-amount: 20px;
|
||||||
|
}
|
||||||
$composer-shadow-color: rgba(0, 0, 0, 0.04);
|
$composer-shadow-color: rgba(0, 0, 0, 0.04);
|
||||||
|
|
||||||
// Bubble tiles
|
// Bubble tiles
|
||||||
|
|
|
@ -27,31 +27,21 @@ export default class BackdropPanel extends React.PureComponent<IProps> {
|
||||||
private spacesCanvasRef = createRef<HTMLCanvasElement>();
|
private spacesCanvasRef = createRef<HTMLCanvasElement>();
|
||||||
private roomListCanvasRef = createRef<HTMLCanvasElement>();
|
private roomListCanvasRef = createRef<HTMLCanvasElement>();
|
||||||
|
|
||||||
private spacesCtx: CanvasRenderingContext2D;
|
|
||||||
private roomListCtx: CanvasRenderingContext2D;
|
|
||||||
|
|
||||||
private sizes = {
|
private sizes = {
|
||||||
spacePanelWidth: 0,
|
spacePanelWidth: 0,
|
||||||
roomListWidth: 0,
|
roomListWidth: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
};
|
};
|
||||||
private currentFrame?: number;
|
private style = getComputedStyle(document.documentElement);
|
||||||
|
|
||||||
constructor(props: IProps) {
|
constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
this.spacesCtx = this.spacesCanvasRef.current.getContext("2d");
|
|
||||||
this.roomListCtx = this.roomListCanvasRef.current.getContext("2d");
|
|
||||||
UIStore.instance.on("SpacePanel", this.onResize);
|
UIStore.instance.on("SpacePanel", this.onResize);
|
||||||
UIStore.instance.on("LeftPanel", this.onResize);
|
UIStore.instance.on("LeftPanel", this.onResize);
|
||||||
}
|
this.onResize();
|
||||||
|
|
||||||
public componentDidUpdate() {
|
|
||||||
if (this.props.backgroundImage) {
|
|
||||||
this.refreshBackdropImage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
|
@ -59,28 +49,31 @@ export default class BackdropPanel extends React.PureComponent<IProps> {
|
||||||
UIStore.instance.off("LeftPanel", this.onResize);
|
UIStore.instance.off("LeftPanel", this.onResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onResize = () => {
|
public componentDidUpdate(prevProps: IProps) {
|
||||||
const spacePanelDimensions = UIStore.instance.getElementDimensions("SpacePanel");
|
|
||||||
const roomListDimensions = UIStore.instance.getElementDimensions("LeftPanel");
|
|
||||||
this.sizes = {
|
|
||||||
spacePanelWidth: spacePanelDimensions?.width ?? 0,
|
|
||||||
roomListWidth: roomListDimensions?.width ?? 0,
|
|
||||||
height: UIStore.instance.windowHeight,
|
|
||||||
};
|
|
||||||
if (this.props.backgroundImage) {
|
if (this.props.backgroundImage) {
|
||||||
|
this.onResize();
|
||||||
|
}
|
||||||
|
if (prevProps.backgroundImage && !this.props.backgroundImage) {
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onResize = () => {
|
||||||
|
if (this.props.backgroundImage) {
|
||||||
|
const spacePanelDimensions = UIStore.instance.getElementDimensions("SpacePanel");
|
||||||
|
const roomListDimensions = UIStore.instance.getElementDimensions("LeftPanel");
|
||||||
|
this.sizes = {
|
||||||
|
spacePanelWidth: spacePanelDimensions?.width ?? 0,
|
||||||
|
roomListWidth: roomListDimensions?.width ?? 0,
|
||||||
|
height: UIStore.instance.windowHeight,
|
||||||
|
};
|
||||||
this.refreshBackdropImage();
|
this.refreshBackdropImage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private animate = () => {
|
|
||||||
if (this.currentFrame !== undefined) {
|
|
||||||
cancelAnimationFrame(this.currentFrame);
|
|
||||||
this.currentFrame = undefined;
|
|
||||||
}
|
|
||||||
this.currentFrame = requestAnimationFrame(this.refreshBackdropImage);
|
|
||||||
};
|
|
||||||
|
|
||||||
private refreshBackdropImage = (): void => {
|
private refreshBackdropImage = (): void => {
|
||||||
|
const spacesCtx = this.spacesCanvasRef.current.getContext("2d");
|
||||||
|
const roomListCtx = this.roomListCanvasRef.current.getContext("2d");
|
||||||
const { spacePanelWidth, roomListWidth, height } = this.sizes;
|
const { spacePanelWidth, roomListWidth, height } = this.sizes;
|
||||||
const width = spacePanelWidth + roomListWidth;
|
const width = spacePanelWidth + roomListWidth;
|
||||||
const { backgroundImage } = this.props;
|
const { backgroundImage } = this.props;
|
||||||
|
@ -111,16 +104,21 @@ export default class BackdropPanel extends React.PureComponent<IProps> {
|
||||||
this.roomListCanvasRef.current.height = height;
|
this.roomListCanvasRef.current.height = height;
|
||||||
this.roomListCanvasRef.current.style.transform = `translateX(${spacePanelWidth}px)`;
|
this.roomListCanvasRef.current.style.transform = `translateX(${spacePanelWidth}px)`;
|
||||||
|
|
||||||
this.spacesCtx.filter = `blur(30px)`;
|
const spacesBlur = this.style.getPropertyValue('--roomlist-background-blur-amount');
|
||||||
this.roomListCtx.filter = `blur(60px)`;
|
const roomListBlur = this.style.getPropertyValue('--groupFilterPanel-background-blur-amount');
|
||||||
this.spacesCtx.drawImage(
|
|
||||||
|
spacesCtx.filter = `blur(${spacesBlur})`;
|
||||||
|
roomListCtx.filter = `blur(${roomListBlur})`;
|
||||||
|
spacesCtx.drawImage(
|
||||||
backgroundImage,
|
backgroundImage,
|
||||||
|
0, 0,
|
||||||
|
imageWidth, imageHeight,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
resultWidth,
|
resultWidth,
|
||||||
resultHeight,
|
resultHeight,
|
||||||
);
|
);
|
||||||
this.roomListCtx.drawImage(
|
roomListCtx.drawImage(
|
||||||
backgroundImage,
|
backgroundImage,
|
||||||
0, 0,
|
0, 0,
|
||||||
imageWidth, imageHeight,
|
imageWidth, imageHeight,
|
||||||
|
@ -132,22 +130,23 @@ export default class BackdropPanel extends React.PureComponent<IProps> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return <>
|
if (!this.props.backgroundImage) return null;
|
||||||
|
return <div>
|
||||||
<canvas
|
<canvas
|
||||||
ref={this.spacesCanvasRef}
|
ref={this.spacesCanvasRef}
|
||||||
className="mx_BackdropPanel"
|
className="mx_BackdropPanel"
|
||||||
style={{
|
style={{
|
||||||
opacity: .15,
|
opacity: .19,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<canvas
|
<canvas
|
||||||
style={{
|
style={{
|
||||||
transform: `translateX(0)`,
|
transform: `translateX(0)`,
|
||||||
opacity: .1,
|
opacity: .12,
|
||||||
}}
|
}}
|
||||||
ref={this.roomListCanvasRef}
|
ref={this.roomListCanvasRef}
|
||||||
className="mx_BackdropPanel"
|
className="mx_BackdropPanel"
|
||||||
/>
|
/>
|
||||||
</>;
|
</div>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue