mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 19:44:15 +00:00
added BackgroundDecorator
component
This commit is contained in:
parent
f889cd3ed2
commit
ccbf0cbf65
48
packages/app/src/components/BackgroundDecorator/index.jsx
Normal file
48
packages/app/src/components/BackgroundDecorator/index.jsx
Normal 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
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user