This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
scoresaber-reloadedv3/src/components/background-image.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-09-08 22:35:32 +01:00
"use client";
import { useLiveQuery } from "dexie-react-hooks";
2024-09-11 23:10:16 +01:00
import { config } from "../../config";
2024-09-08 22:35:32 +01:00
import { getImageUrl } from "../common/image-utils";
import useDatabase from "../hooks/use-database";
export default function BackgroundImage() {
const database = useDatabase();
const settings = useLiveQuery(() => database.getSettings());
if (settings?.backgroundImage == undefined || settings?.backgroundImage == "") {
return null; // Don't render anything if the background image is not set
}
let backgroundImage = settings.backgroundImage;
let prependWebsiteUrl = false;
// Remove the prepending slash
if (backgroundImage.startsWith("/")) {
prependWebsiteUrl = true;
backgroundImage = backgroundImage.substring(1);
}
if (prependWebsiteUrl) {
backgroundImage = config.siteUrl + "/" + backgroundImage;
}
2024-09-08 22:35:32 +01:00
return (
// eslint-disable-next-line @next/next/no-img-element
<img
src={getImageUrl(backgroundImage)}
2024-09-08 22:35:32 +01:00
alt="Background image"
2024-09-11 18:39:46 +01:00
fetchPriority="high"
2024-09-11 20:10:27 +01:00
className={`fixed -z-50 object-cover w-screen h-screen blur-sm brightness-[33%] pointer-events-none select-none`}
2024-09-08 22:35:32 +01:00
/>
);
}