import React from "react" import { Input } from "baseui/input" import { Block } from "baseui/block" import CloudCheck from "~/components/Icons/CloudCheck" import { StatefulTooltip } from "baseui/tooltip" import useDesignEditorContext from "~/hooks/useDesignEditorContext" interface State { name: string width: number } export default function () { const [state, setState] = React.useState({ name: "My first design.", width: 0 }) const { currentDesign, setCurrentDesign } = useDesignEditorContext() const inputTitleRef = React.useRef(null) const spanRef = React.useRef(null) const handleInputChange = (name: string) => { setState({ ...state, name: name, width: spanRef.current?.clientWidth! }) setCurrentDesign({ ...currentDesign, name }) } React.useEffect(() => { const name = currentDesign.name if (name || name === "") { spanRef.current!.innerHTML = name setState({ ...state, name: name, width: spanRef.current?.clientWidth! + 20 }) } }, [currentDesign.name]) React.useEffect(() => { setState({ ...state, width: spanRef.current?.clientWidth! + 20 }) }, [state.name]) return ( {state.name} handleInputChange(e.target.value)} overrides={{ Root: { style: { backgroundColor: "transparent", borderTopStyle: "none", borderBottomStyle: "none", borderRightStyle: "none", borderLeftStyle: "none", }, }, InputContainer: { style: { backgroundColor: "transparent", paddingRight: 0, }, }, Input: { style: { fontWeight: 500, fontSize: "14px", width: `${state.width}px`, fontFamily: "Uber Move Text", backgroundColor: "transparent", color: "#ffffff", paddingRight: 0, }, }, }} value={state.name} ref={inputTitleRef} /> {"All changes are saved"}} > ) }