Add support for image background in world settings
This commit is contained in:
@@ -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%)`
|
||||
|
||||
Reference in New Issue
Block a user