fix: resolve typescript types errors

This commit is contained in:
2026-02-04 13:43:10 +05:00
parent dfa6c40743
commit 3a99a3d22a
9 changed files with 36 additions and 33 deletions
+9 -10
View File
@@ -25,7 +25,7 @@
let uploadedImage = $state<string | undefined>(undefined);
let errorMessage = $state<string | undefined>(undefined);
const uiError = $derived($uiStore.error?.error);
const uiError = $derived($uiStore.error);
onMount(() => {
setupPasteHandler();
@@ -40,14 +40,14 @@
function setupDragAndDrop() {
if (!dropZone) return;
dropZone.addEventListener("dragover", handleDragOver);
dropZone.addEventListener("dragleave", handleDragLeave);
dropZone.addEventListener("drop", handleDrop);
dropZone!.addEventListener("dragover", handleDragOver);
dropZone!.addEventListener("dragleave", handleDragLeave);
dropZone!.addEventListener("drop", handleDrop);
return () => {
dropZone.removeEventListener("dragover", handleDragOver);
dropZone.removeEventListener("dragleave", handleDragLeave);
dropZone.removeEventListener("drop", handleDrop);
dropZone!.removeEventListener("dragover", handleDragOver);
dropZone!.removeEventListener("dragleave", handleDragLeave);
dropZone!.removeEventListener("drop", handleDrop);
};
}
@@ -119,7 +119,7 @@
async function handleUrlSubmit(e: Event) {
e.preventDefault();
if (!urlInput.value.trim()) return;
if (!urlInput?.value.trim()) return;
try {
setLoading(true);
@@ -230,12 +230,11 @@
accept="image/jpeg,image/jpg,image/png,image/webp,image/gif"
style="display: none;"
onchange={(e) => {
const file = e.target.files?.[0];
const file = (e.target as HTMLInputElement).files?.[0];
if (file) handleFileUpload(file);
}}
/>
{/if}
{#if errorMessage}
<div class="error-message">
<strong>Ошибка:</strong>
+2 -3
View File
@@ -92,10 +92,9 @@
{:else}
<div class="panels-grid">
{#each panels as panel (panel.id)}
<div
<button
class="panel-card {selectedPanelId === panel.id ? 'selected' : ''}"
onclick={() => handlePanelSelect(panel)}
role="button"
tabindex="0"
>
<div class="panel-preview">
@@ -125,7 +124,7 @@
</IconButton>
</div>
</div>
</div>
</button>
{/each}
</div>
{/if}
+1 -1
View File
@@ -60,7 +60,7 @@
<div class="panel-preview">
<div class="preview-header">
<div class="panel-title">{panel.texts[0]?.text || "Без названия"}</div>
<Button variant="primary" size="sm" onclick={onDownload}>Скачать</Button>
<Button variant="primary" size="sm" onclick={handleDownload}>Скачать</Button>
</div>
<div class="preview-sections">
<!-- Превью с текстом -->
+8 -8
View File
@@ -18,7 +18,7 @@
fontSize: 18,
fontFamily: "Arial",
color: "#ffffff",
textAlign: "left" | "center" | "right",
textAlign: "left",
paddingX: 10,
verticalOffset: 0,
});
@@ -104,7 +104,7 @@
<input
type="text"
value={textItem.text}
oninput={(e) => handleUpdateText(textItem.id, e.target.value)}
oninput={(e) => handleUpdateText(textItem.id, e.currentTarget.value)}
class="text-edit-input"
maxlength="100"
/>
@@ -132,8 +132,8 @@
max="72"
step="1"
value={commonTextSettings.fontSize}
oninput={(e) => {
commonTextSettings.fontSize = parseInt(e.target.value);
oninput={(e: Event) => {
commonTextSettings.fontSize = parseInt((e.target as HTMLInputElement).value);
}}
/>
<span class="value-display">{commonTextSettings.fontSize}px</span>
@@ -146,7 +146,7 @@
<select
value={commonTextSettings.fontFamily}
onchange={(e) => {
commonTextSettings.fontFamily = e.target.value;
commonTextSettings.fontFamily = (e.target as HTMLSelectElement).value;
}}
>
{#each availableFonts as font}
@@ -163,7 +163,7 @@
type="color"
value={commonTextSettings.color}
oninput={(e) => {
commonTextSettings.color = e.target.value;
commonTextSettings.color = (e.target as HTMLInputElement).value;
}}
/>
</label>
@@ -214,7 +214,7 @@
step="1"
value={commonTextSettings.paddingX}
oninput={(e) => {
commonTextSettings.paddingX = parseInt(e.target.value);
commonTextSettings.paddingX = parseInt((e.target as HTMLInputElement).value);
}}
/>
<span class="value-display">{commonTextSettings.paddingX}px</span>
@@ -231,7 +231,7 @@
step="1"
value={commonTextSettings.verticalOffset}
oninput={(e) => {
commonTextSettings.verticalOffset = parseInt(e.target.value);
commonTextSettings.verticalOffset = parseInt((e.target as HTMLInputElement).value);
}}
/>
<span class="value-display"
+1
View File
@@ -12,6 +12,7 @@
loading?: boolean;
class?: string;
children?: any;
onclick?: (event: MouseEvent) => void;
[key: string]: any;
}
+1
View File
@@ -9,6 +9,7 @@
ariaLabel?: string;
class?: string;
children?: any;
onclick?: (event: MouseEvent) => void;
[key: string]: any;
}
+3 -4
View File
@@ -1,14 +1,13 @@
export type TextAlign = "left" | "center" | "right";
export interface TextItem {
id: string;
text: string;
fontSize: number;
fontFamily: string;
color: string;
// Выравнивание текста: left, center, right
textAlign: "left" | "center" | "right";
// Боковые отступы (лево/право)
textAlign: TextAlign;
paddingX: number;
// Смещение от центра по вертикали (для компенсации визуального центра разных шрифтов)
verticalOffset: number;
}
+8 -4
View File
@@ -3,10 +3,14 @@ import { ImageError } from "../types/errors";
export const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
export const SUPPORTED_FORMATS = ["image/jpeg", "image/jpg", "image/png", "image/webp", "image/gif"];
export interface ValidationResult {
isValid: boolean;
error?: string;
}
export type ValidationResult =
| {
isValid: true;
}
| {
isValid: false;
error: string;
};
export function validateFileSize(file: File): ValidationResult {
if (file.size > MAX_FILE_SIZE) {
+3 -3
View File
@@ -1,5 +1,5 @@
import { writable, type Writable } from "svelte/store";
import { type Panel } from "../lib/types/panel";
import { type Panel, type TextAlign, type TextItem } from "../lib/types/panel";
import { v4 as uuidv4 } from "uuid";
export const panelStore: Writable<Panel | undefined> = writable(undefined);
@@ -24,7 +24,7 @@ export const updatePanel = (panel: Panel, updates: Partial<Panel>): Panel => {
};
export const addTextToPanel = (panel: Panel, text: string): Panel => {
const newText = {
const newText: TextItem = {
id: uuidv4(),
text,
fontSize: 18,
@@ -52,7 +52,7 @@ export const removeTextFromPanel = (panel: Panel, textId: string): Panel => {
};
export const createPanelFromText = (backgroundImage: string, text: string, height: number = 100): Panel => {
const newText = {
const newText: TextItem = {
id: uuidv4(),
text,
fontSize: 18,