From 452e6e74cb86a33e3b3b3339a06d67b467c3f970 Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Sat, 31 Jan 2026 09:10:55 +0100 Subject: [PATCH] update: moved input control buttons JSON Data area. --- src/components/MainPage.js | 131 ++++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 45 deletions(-) diff --git a/src/components/MainPage.js b/src/components/MainPage.js index e1220f7..801c650 100644 --- a/src/components/MainPage.js +++ b/src/components/MainPage.js @@ -12,6 +12,7 @@ function MainPage({ const [result, setResult] = useState(""); const [error, setError] = useState(""); const [jsonError, setJsonError] = useState(""); + const [copySuccess, setCopySuccess] = useState(false); const evaluateExpression = () => { try { @@ -77,6 +78,26 @@ function MainPage({ setJsonError(""); }; + const copyToClipboard = async () => { + try { + await navigator.clipboard.writeText(result); + setCopySuccess(true); + setTimeout(() => setCopySuccess(false), 2000); + } catch (err) { + console.error("Failed to copy!", err); + } + }; + + const downloadResult = () => { + const blob = new Blob([result], { type: "application/json" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = "result.json"; + a.click(); + URL.revokeObjectURL(url); + }; + const loadSample = () => { const sampleData = { users: [ @@ -155,11 +176,54 @@ function MainPage({
-
+
JMESPath Expression
+
+
+ +
+ + {error || "Expression is correct"} + + {showReloadButton && ( + + )} +
+
+
+
+
+ + {/* Lower Middle Section: Input and Output Areas */} +
+ {/* Left Panel: JSON Data Input */} +
+
+
+
+ + JSON Data +
-
- -
- - {error || "Expression is correct"} - - {showReloadButton && ( - - )} -
-
-
-
-
- - {/* Lower Middle Section: Input and Output Areas */} -
- {/* Left Panel: JSON Data Input */} -
-
-
-
- - JSON Data -
-
-
+
Results
+
+ + +