diff --git a/src/components/TablesPage.js b/src/components/TablesPage.js index fae3cc7..8d173a9 100644 --- a/src/components/TablesPage.js +++ b/src/components/TablesPage.js @@ -225,6 +225,34 @@ const SetPaymentQr = ({ shop }) => { } }; + const [inputValue, setInputValue] = useState(shop.name); + const inputRef = useRef(null); + + // Monospace font for accurate character width calculation + const monospaceFont = 'monospace'; + + // Minimum width for the input field + const minWidth = 100; // Minimum width in pixels (adjust as necessary) + + // Function to handle input change and adjust the width + const handleInputNameChange = (e) => { + setInputValue(e.target.value); + }; + + // Resize the input width based on the number of characters typed + useEffect(() => { + if (inputRef.current) { + // Get the width of a single character + const characterWidth = 10; // You can adjust this value based on the actual font size + + // Calculate the required width based on the number of characters + const newWidth = characterWidth * inputValue?.length + 30; + + // Set the input width, ensuring it doesn't go below the minimum width + inputRef.current.style.width = `${Math.max(newWidth, minWidth)}px`; + } + }, [inputValue]); // Trigger effect when the input value changes + return (
Klik untuk ganti nama
+Klik untuk ganti nama
+-----------------
+-----------------
-