From 5560435b55cb232b978f4c20a813f3d964e66b79 Mon Sep 17 00:00:00 2001 From: Ku6epXBOCTuK Date: Sat, 22 Aug 2026 20:52:03 +0500 Subject: [PATCH] refactor: separate tool page --- web/src/lib/components/ToolPage.svelte | 128 ++++-------------- web/src/lib/components/tool/ParamsCard.svelte | 41 ++++++ web/src/lib/components/tool/ResultCard.svelte | 92 +++++++++++++ web/src/lib/components/tool/SourceCard.svelte | 53 ++++++++ 4 files changed, 213 insertions(+), 101 deletions(-) create mode 100644 web/src/lib/components/tool/ParamsCard.svelte create mode 100644 web/src/lib/components/tool/ResultCard.svelte create mode 100644 web/src/lib/components/tool/SourceCard.svelte diff --git a/web/src/lib/components/ToolPage.svelte b/web/src/lib/components/ToolPage.svelte index 63757d3..3b9daaf 100644 --- a/web/src/lib/components/ToolPage.svelte +++ b/web/src/lib/components/ToolPage.svelte @@ -2,15 +2,10 @@ import { imageInfo, type ImageInfo } from '$lib/core/analyze'; import { decodeFile, isSupportedImage, unsupportedImageMessage } from '$lib/core/io'; import type { PixelImage } from '$lib/core/types'; - import { defaultParams, outputOf, sanitizeParams, type ToolEntry } from '$lib/registry'; - import Button from './ui/Button.svelte'; - import DownloadButton from './DownloadButton.svelte'; - import DropOverlay from './DropOverlay.svelte'; - import DropZone from './DropZone.svelte'; - import EmptyState from './ui/EmptyState.svelte'; - import InfoPanel from './InfoPanel.svelte'; - import ParamForm from './ParamForm.svelte'; - import Preview from './Preview.svelte'; + import { defaultParams, sanitizeParams, type ToolEntry } from '$lib/registry'; + import ParamsCard from './tool/ParamsCard.svelte'; + import ResultCard from './tool/ResultCard.svelte'; + import SourceCard from './tool/SourceCard.svelte'; let { tool }: { tool: ToolEntry } = $props(); @@ -105,71 +100,30 @@ {/if}
-
-

Исходник

- {#if !source} - (errorText = message)} /> - {:else} - (errorText = message)}> -
- -
- -
- {/if} +
+ (errorText = message)} + onReset={reset} + />
- -
-

{isInfo ? 'Сводка' : 'Результат'}

- {#if !source} -
- -
- {:else if !isInfo && status === 'processing' && !result} -
- -
- {:else if isInfo} -
- {#if info} - - {/if} -
- {:else} -
- -
- - {/if} +
+
{#if source && !isInfo} -
-

Параметры

- {#if tool.params.length > 0} - - - {:else} -

- У этого инструмента нет параметров — результат уже готов. -

- {/if} -
+ {/if} @@ -194,54 +148,26 @@ padding: var(--space-4); } - .side { - display: flex; - flex-direction: column; - gap: var(--space-2); + .cell { min-width: 0; + display: flex; } - .side + .side { + .cell + .cell { border-left: 1px solid var(--border); padding-left: var(--space-4); } - .side h2 { - margin-bottom: var(--space-1); - } - - .media { - flex: 1; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - min-height: 16rem; - } - - .params-card { - margin-top: var(--space-4); - padding: var(--space-4); - } - @media (max-width: 48rem) { .stage { grid-template-columns: 1fr; } - .side + .side { + .cell + .cell { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: var(--space-4); } } - - .hint { - margin-bottom: var(--space-3); - } - - .hint { - margin-bottom: var(--space-3); - } diff --git a/web/src/lib/components/tool/ParamsCard.svelte b/web/src/lib/components/tool/ParamsCard.svelte new file mode 100644 index 0000000..63ef5d3 --- /dev/null +++ b/web/src/lib/components/tool/ParamsCard.svelte @@ -0,0 +1,41 @@ + + +
+

Параметры

+ {#if params.length > 0} + + + {:else} +

+ У этого инструмента нет параметров — результат уже готов. +

+ {/if} +
+ + diff --git a/web/src/lib/components/tool/ResultCard.svelte b/web/src/lib/components/tool/ResultCard.svelte new file mode 100644 index 0000000..613ffb1 --- /dev/null +++ b/web/src/lib/components/tool/ResultCard.svelte @@ -0,0 +1,92 @@ + + +
+

{isInfo ? 'Сводка' : 'Результат'}

+ {#if !sourceLoaded} +
+ +
+ {:else if !isInfo && status === 'processing' && !result} +
+ +
+ {:else if isInfo} +
+ {#if info} + + {/if} +
+ {:else} +
+ +
+ + {/if} +
+ + diff --git a/web/src/lib/components/tool/SourceCard.svelte b/web/src/lib/components/tool/SourceCard.svelte new file mode 100644 index 0000000..6b12a94 --- /dev/null +++ b/web/src/lib/components/tool/SourceCard.svelte @@ -0,0 +1,53 @@ + + +
+

Исходник

+ {#if !source} + + {:else} + +
+ +
+ +
+ {/if} +
+ +