Add support for image background in world settings

This commit is contained in:
2026-03-31 20:04:35 +02:00
parent 85644944b7
commit ff34d3942d

View File

@@ -2,7 +2,7 @@ import type { CSSProperties } from "react";
import type { WorldBackgroundSettings } from "../document/world-settings";
export function createWorldBackgroundStyle(background: WorldBackgroundSettings): CSSProperties {
export function createWorldBackgroundStyle(background: WorldBackgroundSettings, imageUrl: string | null = null): CSSProperties {
if (background.mode === "solid") {
return {
backgroundColor: background.colorHex,
@@ -10,6 +10,16 @@ export function createWorldBackgroundStyle(background: WorldBackgroundSettings):
};
}
if (background.mode === "image") {
return {
backgroundColor: "#0d1116",
backgroundImage: imageUrl === null ? "none" : `url("${imageUrl}")`,
backgroundPosition: "center center",
backgroundRepeat: "no-repeat",
backgroundSize: "cover"
};
}
return {
backgroundColor: background.bottomColorHex,
backgroundImage: `linear-gradient(180deg, ${background.topColorHex} 0%, ${background.bottomColorHex} 100%)`