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 { Text, Box } from 'gestalt' interface Options { enabled: boolean stroke: string strokeWidth: number } function Outline() { const editor = useEditor() const activeObject = useActiveObject() const [options, setOptions] = React.useState({ enabled: true, stroke: "#000000", strokeWidth: 1, }) React.useEffect(() => { if (activeObject) { updateOptions(activeObject) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [activeObject]) const updateOptions = (object: any) => { const { stroke, strokeWidth } = object setOptions({ ...options, stroke, strokeWidth, enabled: !!strokeWidth }) } const handleChange = (type: string, value: any) => { setOptions({ ...options, [type]: value }) if (type === "enabled") { if (value) { editor.objects.update(options) } else { editor.objects.update({ strokeWidth: 0 }) } } else { if (editor && options.enabled) { editor.objects.update({ [type]: value }) } } } return (
handleChange("enabled", (e.target as any).checked)} > Outline
handleChange("stroke", color)} /> handleChange("color", (e.target as any).value)} placeholder="#000000" clearOnEscape />
} accessibilityType={"tooltip"} >
Size null, ThumbValue: () => null, TickBar: () => null, Thumb: { style: { height: "12px", width: "12px", paddingLeft: 0, }, }, Track: { style: { paddingLeft: 0, paddingRight: 0, }, }, }} value={[options.strokeWidth]} onChange={({ value }) => handleChange("strokeWidth", value[0])} />
) } export default Outline