From 0828ac9822f8b790012848078c14736623ef311e Mon Sep 17 00:00:00 2001 From: zadit <75159257+insvrgent@users.noreply.github.com> Date: Wed, 19 Feb 2025 07:06:13 +0700 Subject: [PATCH] ok --- src/components/TablesPage.js | 69 +++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 13 deletions(-) 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
+-----------------
+-----------------
-