refactor: fix using magic numbers

This commit is contained in:
2026-02-05 11:24:20 +05:00
parent f7d2353d8f
commit ca3995881f
2 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import Button from "$components/ui/Button.svelte"; import Button from "$components/ui/Button.svelte";
import { PANEL_SETTINGS } from "$lib/constants";
import type { ImageCropResult } from "$lib/types/panel"; import type { ImageCropResult } from "$lib/types/panel";
import { setLoading } from "$stores/uiStore"; import { setLoading } from "$stores/uiStore";
import CropperJS from "cropperjs"; import CropperJS from "cropperjs";
@@ -52,7 +53,7 @@
} }
const canvas = await cropperCanvasElement.$toCanvas({ const canvas = await cropperCanvasElement.$toCanvas({
width: 320, width: PANEL_SETTINGS.PANEL_WIDTH,
}); });
if (!canvas) { if (!canvas) {
+3 -3
View File
@@ -65,10 +65,10 @@
function getTextPosition(textItem: TextItem) { function getTextPosition(textItem: TextItem) {
const panelWidth = PANEL_SETTINGS.PANEL_WIDTH; const panelWidth = PANEL_SETTINGS.PANEL_WIDTH;
const paddingX = textItem.paddingX ?? 20; const paddingX = textItem.paddingX;
const verticalOffset = textItem.verticalOffset ?? 0; const verticalOffset = textItem.verticalOffset;
const centerY = panel.height / 2 + verticalOffset; const centerY = panel.height / 2 + verticalOffset;
const textWidth = 300; const textWidth = panelWidth - paddingX * 2;
let position; let position;
switch (textItem.textAlign) { switch (textItem.textAlign) {