You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
908 B

"use client";
import type { CSSProperties } from "react";
import { useEffect } from "react";
type PageBackgroundProps = {
image?: string;
disabled?: boolean;
};
export function PageBackground({
image,
disabled = false,
}: PageBackgroundProps) {
useEffect(() => {
if (!image) return;
document.documentElement.style.setProperty(
"--page-background-image",
`url("${image}")`,
);
return () => {
document.documentElement.style.removeProperty("--page-background-image");
};
}, [image]);
return (
<span
aria-hidden="true"
className={
disabled
? "page-background-none"
: image
? "page-background-custom"
: "page-background-default"
}
style={
image
? ({ "--page-background-image": `url("${image}")` } as CSSProperties)
: undefined
}
/>
);
}