import ActiveObjectContext from "@/components/Context/activeObject/ObjectContext"; import CanvasContext from "@/components/Context/canvasContext/CanvasContext"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Slider } from "@/components/ui/slider"; import { useContext, useEffect, useState } from "react"; import CollapsibleComponent from "./CollapsibleComponent"; const ShadowCustomization = () => { // get values from context const { activeObject } = useContext(ActiveObjectContext); const { canvas } = useContext(CanvasContext); // state to handle shadow inputs const [shadowColor, setShadowColor] = useState(""); const [offsetX, setOffsetX] = useState(5); const [offsetY, setOffsetY] = useState(5); const [blur, setBlur] = useState(0.5); const [opacity, setOpacity] = useState(0.5); useEffect(() => { if (activeObject) { setShadowColor(activeObject?.shadow?.color || "#db1d62"); setOffsetX(activeObject?.shadow?.offsetX || 5); setOffsetY(activeObject?.shadow?.offsetY || 5); setBlur(activeObject?.shadow?.blur || 0.5); setOpacity(activeObject?.shadow?.opacity || 0.5); } }, [activeObject]); const handleApplyShadow = () => { if (activeObject && canvas) { const shadow = { color: shadowColor, blur: blur, offsetX: offsetX, offsetY: offsetY, opacity: opacity, }; activeObject.set("shadow", shadow); // Ensure object updates and renders activeObject.dirty = true; // Mark the object as dirty for re-render canvas.renderAll(); // Trigger canvas re-render } }; const handleDisableShadow = () => { if (activeObject && canvas) { activeObject.set("shadow", null); canvas.renderAll(); } }; const content = () => { return (