From a1438e6f7f227f7489465070c02abdbb495a9dd1 Mon Sep 17 00:00:00 2001 From: Ku6epXBOCTuK Date: Mon, 7 Sep 2026 10:48:45 +0500 Subject: [PATCH] fix: resolve always text input issue, separate to simple components --- .../lib/components/kit/SchemaActions.svelte | 77 ++++++ .../lib/components/kit/SchemaPreview.svelte | 248 ++++-------------- .../components/kit/SchemaResultTile.svelte | 101 +++++++ .../components/kit/SchemaSourceTile.svelte | 80 ++++++ .../lib/components/kit/SchemaToolView.svelte | 2 +- 5 files changed, 316 insertions(+), 192 deletions(-) create mode 100644 web/src/lib/components/kit/SchemaActions.svelte create mode 100644 web/src/lib/components/kit/SchemaResultTile.svelte create mode 100644 web/src/lib/components/kit/SchemaSourceTile.svelte diff --git a/web/src/lib/components/kit/SchemaActions.svelte b/web/src/lib/components/kit/SchemaActions.svelte new file mode 100644 index 0000000..fb1015d --- /dev/null +++ b/web/src/lib/components/kit/SchemaActions.svelte @@ -0,0 +1,77 @@ + + +
+ {#if inputMode === "none"} + + {:else if inputMode === "file"} + + {/if} + {#if canDownload} + + {/if} +
+ + diff --git a/web/src/lib/components/kit/SchemaPreview.svelte b/web/src/lib/components/kit/SchemaPreview.svelte index fdc4bb0..e188f29 100644 --- a/web/src/lib/components/kit/SchemaPreview.svelte +++ b/web/src/lib/components/kit/SchemaPreview.svelte @@ -1,21 +1,19 @@
{isGenerator ? "GENERATOR / RESULT" : "SOURCE / RESULT"} -
- {#if isGenerator} - - {:else if !isTextInput} - - {/if} - {#if isImageDownload} - - {/if} -
+ {})} + {ondownload} + />
{#if error} @@ -88,85 +81,31 @@
{#if !isGenerator} -
-
SOURCE
-
- {#if isTextInput} -
- {})} - onrender={onrendertext ?? (() => {})} - /> -
- {:else if sourceUrl} - source - {:else} - choose an image - {/if} -
-
+ {/if} -
-
RESULT {running ? "…" : ""}
-
- {#if resultKind === "text" && textResult} -
- {})} - ondownload={ondownloadtxt ?? (() => {})} - /> -
- {:else if resultKind === "verdict" && textResult} -
- {})} - ondownload={ondownloadtxt ?? (() => {})} - /> -
- {:else if resultKind === "image" && resultUrl} - result - {:else if running} - - {:else} - - {isGenerator ? "click Generate" : "no result yet"} - - {/if} -
-
+
@@ -187,35 +126,6 @@ letter-spacing: var(--space-text-l); color: var(--color-main); } - .head-actions { - display: flex; - align-items: center; - gap: var(--space-l); - flex-wrap: wrap; - } - .upload { - display: inline-flex; - align-items: center; - gap: var(--space-m); - padding: var(--space-m) var(--space-l); - border: var(--size-border) solid var(--color-border); - border-radius: var(--radius-m); - font: var(--font-size-s) var(--font-mono); - color: var(--color-text-muted); - cursor: pointer; - } - .generate-btn { - background: var(--color-main); - border-color: var(--color-main); - color: var(--color-background); - } - .generate-btn:disabled { - opacity: 0.6; - cursor: default; - } - .upload input { - display: none; - } .error { margin: 0 0 var(--space-l); color: var(--color-danger); @@ -226,50 +136,6 @@ grid-template-columns: 1fr 1fr; gap: var(--space-l); } - .pair > .full { - grid-column: 1 / -1; - } - .tile figcaption { - display: flex; - align-items: center; - gap: var(--space-m); - margin-bottom: var(--space-m); - font: var(--font-size-s) var(--font-mono); - color: var(--color-text-muted); - } - .canvas { - display: flex; - align-items: center; - justify-content: center; - min-height: clamp(var(--space-brand), 30vh, 60vh); - border: var(--size-border) solid var(--color-border); - border-radius: var(--radius-m); - overflow: hidden; - background: var(--color-background-muted); - color: var(--color-text-muted); - } - .canvas img { - width: 100%; - height: 100%; - object-fit: contain; - display: block; - } - .canvas.checker { - background: repeating-conic-gradient( - var(--color-checker-main) 0 25%, - var(--color-checker-alt) 0 50% - ) - 50% / 28px 28px; - } - .empty { - font: var(--font-size-s) var(--font-mono); - } - .text-source-wrap, - .text-result-wrap { - width: 100%; - padding: var(--space-l); - box-sizing: border-box; - } .meta { margin-top: var(--space-l); } diff --git a/web/src/lib/components/kit/SchemaResultTile.svelte b/web/src/lib/components/kit/SchemaResultTile.svelte new file mode 100644 index 0000000..d010c2d --- /dev/null +++ b/web/src/lib/components/kit/SchemaResultTile.svelte @@ -0,0 +1,101 @@ + + +
+
RESULT {running ? "…" : ""}
+
+ {#if resultKind === "text" && textResult} +
+ {})} + ondownload={ondownloadtxt ?? (() => {})} + /> +
+ {:else if resultKind === "verdict" && textResult} +
+ {})} + ondownload={ondownloadtxt ?? (() => {})} + /> +
+ {:else if resultKind === "image" && resultUrl} + result + {:else if running} + + {:else} + no result yet + {/if} +
+
+ + diff --git a/web/src/lib/components/kit/SchemaSourceTile.svelte b/web/src/lib/components/kit/SchemaSourceTile.svelte new file mode 100644 index 0000000..bf76982 --- /dev/null +++ b/web/src/lib/components/kit/SchemaSourceTile.svelte @@ -0,0 +1,80 @@ + + +
+
SOURCE
+
+ {#if mode === "text"} +
+ {})} + onrender={onrendertext ?? (() => {})} + /> +
+ {:else if sourceUrl} + source + {:else} + choose an image + {/if} +
+
+ + diff --git a/web/src/lib/components/kit/SchemaToolView.svelte b/web/src/lib/components/kit/SchemaToolView.svelte index 0296fba..7013f2a 100644 --- a/web/src/lib/components/kit/SchemaToolView.svelte +++ b/web/src/lib/components/kit/SchemaToolView.svelte @@ -196,10 +196,10 @@ {result} {textSource} {textResult} + {inputMode} {resultKind} {running} {error} - {isGenerator} onupload={handleFile} ongenerate={runGenerate} ontextsource={(t) => {