From 6a962d08a2dade752260feb50af946d98948e93a Mon Sep 17 00:00:00 2001 From: nicholaschen09 Date: Sun, 18 May 2025 07:22:22 -0400 Subject: [PATCH 01/12] added preview title and scrolling for both input and preview boxes --- src/app.css | 33 ++++++++------------------------- src/routes/+page.svelte | 2 +- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/app.css b/src/app.css index 9186464..f94a3b0 100644 --- a/src/app.css +++ b/src/app.css @@ -73,10 +73,10 @@ h1 { background: #f7f7f7; color: #067800; transition: border 0.2s; - height: 160px; min-height: 160px; - max-height: 160px; - resize: none; + max-height: 350px; + resize: vertical; + overflow-y: auto; } .query-section textarea:focus { @@ -292,9 +292,11 @@ tr:nth-child(even) td { padding: 1rem; border-radius: 6px; overflow-x: auto; + overflow-y: auto; font-family: "Fira Mono", monospace; font-size: 0.9rem; margin: 1rem 0; + max-height: 350px; } .preview-note { @@ -383,28 +385,9 @@ p { outline: none; } -.preview-section { - margin-top: 1.5rem; - background: var(--card-bg); - border-radius: 8px; - padding: 1.5rem; - color: #222; -} - -.json-preview { - background: #f5f5f5; - padding: 1rem; - border-radius: 6px; - overflow-x: auto; - font-family: "Fira Mono", monospace; - font-size: 0.9rem; - margin: 1rem 0; -} - -.preview-note { - color: #666; - font-size: 0.9rem; - margin: 0; +.preview-section h3 { + color: #067800; + margin-bottom: 1rem; } .table-container { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index fbe9e2c..d50125a 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -198,7 +198,7 @@ {#if previewData}
-

Data Preview

+

Preview

{previewData}

Showing first 3 records of {data.length} total records From 13ebf899d66cd45243247abf4e1d369dee20b74f Mon Sep 17 00:00:00 2001 From: nicholaschen09 Date: Sun, 18 May 2025 07:27:05 -0400 Subject: [PATCH 02/12] fixed the preview box to show all records in JSON input --- src/routes/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d50125a..d843162 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -34,7 +34,7 @@ try { data = JSON.parse(input); jsonError = null; - previewData = JSON.stringify(data.slice(0, 3), null, 2); + previewData = JSON.stringify(data, null, 2); } catch (err) { jsonError = "Invalid JSON input."; data = []; @@ -201,7 +201,7 @@

Preview

{previewData}

- Showing first 3 records of {data.length} total records + Showing {data.length} total record{data.length === 1 ? '' : 's'}

{/if} From 8995b299ecf389db90552d1a33b51ad1678739b6 Mon Sep 17 00:00:00 2001 From: nicholaschen09 Date: Sun, 18 May 2025 07:36:22 -0400 Subject: [PATCH 03/12] fix spacing and added sample sql and json inputs --- src/app.css | 76 +++++++++++++++++++++++++++++++++++++++++ src/routes/+page.svelte | 48 ++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/src/app.css b/src/app.css index f94a3b0..6fb6ad3 100644 --- a/src/app.css +++ b/src/app.css @@ -77,6 +77,26 @@ h1 { max-height: 350px; resize: vertical; overflow-y: auto; + scrollbar-width: thin; + /* For Firefox */ + scrollbar-color: #009624 #e0e0e0; + /* For Firefox */ + border: 1.5px solid #bdbdbd; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); +} + +/* Webkit scrollbar styles */ +.query-section textarea::-webkit-scrollbar, +.json-preview::-webkit-scrollbar { + width: 10px; + background: #e0e0e0; + border-radius: 6px; +} + +.query-section textarea::-webkit-scrollbar-thumb, +.json-preview::-webkit-scrollbar-thumb { + background: #009624; + border-radius: 6px; } .query-section textarea:focus { @@ -297,6 +317,29 @@ tr:nth-child(even) td { font-size: 0.9rem; margin: 1rem 0; max-height: 350px; + scrollbar-width: thin; + /* For Firefox */ + scrollbar-color: #009624 #e0e0e0; + /* For Firefox */ + border: 1.5px solid #bdbdbd; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); +} + +/* Webkit scrollbar styles */ +.json-preview::-webkit-scrollbar { + width: 10px; + background: #e0e0e0; + border-radius: 6px; +} + +.json-preview::-webkit-scrollbar-thumb { + background: #009624; + border-radius: 6px; +} + +.json-preview:focus { + border-color: #009624; + outline: none; } .preview-note { @@ -410,4 +453,37 @@ h3 { p { margin: 0.5rem 0; color: var(--text-light); +} + +.sample-suggestions { + margin: 1.2rem 0 1rem 0; + display: flex; + align-items: center; + gap: 0.7rem; + flex-wrap: wrap; + padding-left: 0.5rem; +} + +.sample-suggestions span { + font-weight: 500; + color: #222; + font-size: 1.08rem; +} + +.sample-suggestions button { + background: #e0e0e0; + color: #067800; + border: 1.5px solid #009624; + border-radius: 6px; + padding: 0.45rem 1.2rem; + font-size: 1.05rem; + font-weight: 600; + cursor: pointer; + transition: background 0.2s, box-shadow 0.2s; + box-shadow: 0 1px 4px rgba(0, 200, 83, 0.07); +} + +.sample-suggestions button:hover { + background: #b9f6ca; + box-shadow: 0 2px 8px rgba(0, 200, 83, 0.13); } \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d843162..f0d8e29 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -17,6 +17,35 @@ let previewData: string = ""; let inputMode: "file" | "raw" = "file"; + // Sample data for suggestions + const sampleJsons = [ + { + label: "US States Population", + value: `[ + { "state": "California", "region": "West", "pop": 39538223, "pop_male": 19453769, "pop_female": 20084454 }, + { "state": "Texas", "region": "South", "pop": 29145505, "pop_male": 14358470, "pop_female": 14787035 }, + { "state": "Florida", "region": "South", "pop": 21538187, "pop_male": 10470577, "pop_female": 11067610 } +]` + } + // Add more samples if you want + ]; + + const sampleSqls = [ + { + label: "All States", + value: "SELECT * FROM table;" + }, + { + label: "States with pop > 20M", + value: "SELECT state, pop FROM table WHERE pop > 20000000;" + }, + { + label: "States in the South", + value: "SELECT state FROM table WHERE region = 'South';" + } + // Add more samples if you want + ]; + function saveHistory() { sessionStorage.setItem("queryHistory", JSON.stringify(history)); sessionStorage.setItem("queryHistoryNextId", String(nextId)); @@ -148,6 +177,16 @@ + +
+ Try sample JSON: + {#each sampleJsons as sample} + + {/each} +
+ {#if inputMode === "file"}
+ +
+ Try sample SQL: + {#each sampleSqls as sample} + + {/each} +

SQL Query