Files
ThreadNet-Web/src/components/structures/BackdropPanel.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-06-25 11:46:38 +01:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2021-2024 New Vector Ltd.
2021-06-25 11:46:38 +01:00
2024-09-09 14:57:16 +01:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
2021-06-25 11:46:38 +01:00
*/
2021-08-23 19:26:57 +02:00
import React, { CSSProperties } from "react";
interface IProps {
2021-08-23 19:26:57 +02:00
backgroundImage?: string;
blurMultiplier?: number;
}
2021-08-23 19:26:57 +02:00
export const BackdropPanel: React.FC<IProps> = ({ backgroundImage, blurMultiplier }) => {
if (!backgroundImage) return null;
2021-08-17 16:07:17 +02:00
2021-08-23 19:26:57 +02:00
const styles: CSSProperties = {};
if (blurMultiplier) {
const rootStyle = getComputedStyle(document.documentElement);
const blurValue = rootStyle.getPropertyValue("--lp-background-blur");
const pixelsValue = blurValue.replace("px", "");
const parsed = parseInt(pixelsValue, 10);
if (!isNaN(parsed)) {
styles.filter = `blur(${parsed * blurMultiplier}px)`;
2021-08-13 19:03:20 +02:00
}
}
2021-08-23 19:26:57 +02:00
return (
<div className="mx_BackdropPanel">
<img role="presentation" alt="" style={styles} className="mx_BackdropPanel--image" src={backgroundImage} />
</div>
);
};
export default BackdropPanel;