added BackgroundDecorator component

This commit is contained in:
SrGooglo 2023-02-24 14:27:17 +00:00
parent f889cd3ed2
commit ccbf0cbf65

View File

@ -0,0 +1,48 @@
import React from "react"
import classnames from "classnames"
export default () => {
const [activeColor, setActiveColor] = React.useState(false)
const hasBackgroundSVG = (value) => {
if (value === "unset" || value === "none" || !value) {
return false
} else {
return true
}
}
const handleStyleUpdate = (update) => {
if (hasBackgroundSVG(update["backgroundSVG"])) {
setActiveColor(true)
} else {
setActiveColor(false)
}
}
React.useEffect(() => {
app.eventBus.on("style.update", handleStyleUpdate)
const activeSVG = app.cores.style.getValue("backgroundSVG")
if (hasBackgroundSVG(activeSVG)) {
setActiveColor(true)
}
return () => {
app.eventBus.off("style.update", handleStyleUpdate)
}
}, [])
return <div
id="root_background"
className={
classnames(
"root_background",
{
["active"]: activeColor
}
)
}
/>
}