From ad99aee11780aa85461ea89dfb40c75d149d3962 Mon Sep 17 00:00:00 2001 From: Jandl-hostacny Date: Thu, 8 Oct 2026 09:59:10 +0200 Subject: [PATCH] feat: moznost nahrat podklad cenovky aj ako PNG --- src/components/editor/BadgeEditorModal.tsx | 69 ++++++++++++++++------ src/lib/badgeUtils.ts | 2 +- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/components/editor/BadgeEditorModal.tsx b/src/components/editor/BadgeEditorModal.tsx index 675096f..b120adf 100644 --- a/src/components/editor/BadgeEditorModal.tsx +++ b/src/components/editor/BadgeEditorModal.tsx @@ -280,24 +280,52 @@ export const BadgeEditorModal: React.FC = ({ setSelectedLayerId(newBadge.layersConfig[0].id); }; - // Upload vlastného SVG súboru - const handleSvgUpload = (e: React.ChangeEvent) => { + // Upload vlastného SVG alebo PNG súboru ako podkladu + const handleBackgroundUpload = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (!file || !activeBadge) return; - const reader = new FileReader(); - reader.onload = (event) => { - const content = event.target?.result as string; - if (content.includes(' { + const content = event.target?.result as string; + if (content.includes(' { + const dataUrl = event.target?.result as string; + const img = new Image(); + img.onload = () => { + const w = img.naturalWidth || 140; + const h = img.naturalHeight || 95; + const svgContent = ``; + setActiveBadge({ + ...activeBadge, + svgRaw: svgContent + }); + }; + img.src = dataUrl; + }; + reader.readAsDataURL(file); + } else { + alert('Podporované sú len grafické súbory vo formáte SVG alebo PNG.'); + } }; const activeLayer = @@ -834,18 +862,21 @@ export const BadgeEditorModal: React.FC = ({ - {/* Upload vlastného SVG podkladu */} + {/* Upload vlastného SVG alebo PNG podkladu */}
+

+ Podporuje SVG vektorové tvary aj priehľadné PNG obrázky. +

{/* Rýchle pridanie vrstiev */} diff --git a/src/lib/badgeUtils.ts b/src/lib/badgeUtils.ts index 867ea7b..7fca900 100644 --- a/src/lib/badgeUtils.ts +++ b/src/lib/badgeUtils.ts @@ -110,7 +110,7 @@ export function renderCleanBadgeSvg( return `${contentSvg}`; }).join('\n '); - return ` + return ` ${innerBg} ${textLayersSvg} `;