From c940fc5207a80563a620b37c9aeebce395c659e9 Mon Sep 17 00:00:00 2001 From: whoswhip Date: Mon, 26 Jan 2026 19:41:33 -0500 Subject: [PATCH] feat: enhance CSV rendering with header support and improved styling --- .../src/routes/[id]/+page.svelte | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/SharpbinV3.Client/src/routes/[id]/+page.svelte b/SharpbinV3.Client/src/routes/[id]/+page.svelte index 806d62c..0005f79 100644 --- a/SharpbinV3.Client/src/routes/[id]/+page.svelte +++ b/SharpbinV3.Client/src/routes/[id]/+page.svelte @@ -182,13 +182,25 @@ } const rows = results.data as string[][]; + const [header, ...body] = rows; + + const escape = (v: string) => + v.replace(/&/g, '&').replace(//g, '>'); + const tableHtml = ` - - - ${rows.map((row) => `${row.map((cell) => ``).join('')}`).join('')} - -
${cell ? cell.replace(/&/g, '&').replace(//g, '>') : ''}
- `; + + + + ${header.map((c) => ``).join('')} + + + + ${body + .map((row) => `${row.map((c) => ``).join('')}`) + .join('')} + +
${c ? escape(c) : ''}
${c ? escape(c) : ''}
+ `; pasteContent = tableHtml; contentRendered = true; @@ -959,29 +971,41 @@ } .csv-table { - border-collapse: collapse; + border-collapse: separate; + border-spacing: 0; background-color: var(--color-neutral-800); border-bottom-left-radius: 0.25rem; border-bottom-right-radius: 0.25rem; min-width: 100%; } - .csv-table tr { + .csv-table thead th { + position: sticky; + top: 0; + background-color: var(--color-neutral-800); + border-bottom: 2px solid var(--color-neutral-700); + z-index: 2; + } + + .csv-table tbody tr, + .csv-table thead th { border-bottom: 1px solid var(--color-neutral-700); } - .csv-table tr:hover { + .csv-table tbody tr:hover, + .csv-table thead tr:hover { background-color: rgba(255, 255, 255, 0.05); } - .csv-table td { + .csv-table tbody td, + .csv-table thead th { padding: 0.75rem 1rem; text-align: left; color: var(--color-neutral-300); white-space: nowrap; } - .csv-table tr:last-child { + .csv-table tbody tr:last-child { border-bottom: none; }