import React from "react" import { Checkbox } from "baseui/checkbox" import { StatefulPopover, PLACEMENT } from "baseui/popover" import { HexColorPicker } from "react-colorful" import { Slider } from "baseui/slider" import { Input } from "baseui/input" import { useActiveObject, useEditor } from "@layerhub-io/react" import { Box, Text } from 'gestalt' interface Options { enabled: boolean offsetX: number offsetY: number blur: number color: string } function Shadow() { const editor = useEditor() const [options, setOptions] = React.useState({ enabled: false, offsetX: 15, offsetY: 15, blur: 25, color: "rgba(0,0,0,0.45)", }) const activeObject = useActiveObject() React.useEffect(() => { if (activeObject) { updateOptions(activeObject) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [activeObject]) const updateOptions = (object: any) => { if (object.shadow) { const { blur, color, enabled, offsetX, offsetY } = object.shadow setOptions({ ...options, blur, color, enabled, offsetX, offsetY }) // if (enabled) { // setOpenItems([0]) // } } } const handleChange = (key: string, value: any) => { setOptions({ ...options, [key]: value }) if (editor) { console.log({ ...options, [key]: value }) editor.objects.setShadow({ ...options, [key]: value }) } } return (
handleChange("enabled", e.target.checked)} > Shadow
handleChange("color", color)} /> handleChange("color", (e.target as any).value)} placeholder="#000000" clearOnEscape />
} accessibilityType={"tooltip"} >
Offset Y null, ThumbValue: () => null, TickBar: () => null, Thumb: { style: { height: "12px", width: "12px", paddingLeft: 0, }, }, Track: { style: { paddingLeft: 0, paddingRight: 0, }, }, }} value={[options.offsetY]} onChange={({ value }) => handleChange("offsetY", value)} />
Offset X null, ThumbValue: () => null, TickBar: () => null, Thumb: { style: { height: "12px", width: "12px", paddingLeft: 0, }, }, Track: { style: { paddingLeft: 0, paddingRight: 0, }, }, }} value={[options.offsetX]} onChange={({ value }) => handleChange("offsetX", value)} />
) } export default Shadow