From 31b9d605cf5adb998809928cdc762ed80697a62f Mon Sep 17 00:00:00 2001 From: Jandl-hostacny Date: Wed, 21 Oct 2026 16:55:06 +0200 Subject: [PATCH] feat: predvolena velkost fotky produktu 95 % Co-Authored-By: Claude Opus 5.5 --- src/components/editor/ProductEditor.tsx | 4 ++-- src/lib/productCard.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/editor/ProductEditor.tsx b/src/components/editor/ProductEditor.tsx index 61b352c..88de2bb 100644 --- a/src/components/editor/ProductEditor.tsx +++ b/src/components/editor/ProductEditor.tsx @@ -7,7 +7,7 @@ import { BADGE_IMPORT_TYPES, BadgeTemplate, CardProduct, ProductLabel, ProductPh import { ChevronDown, ChevronUp, Trash2, Pencil, Globe, Layers } from 'lucide-react'; import { ImageUploadInput } from './ImageUploadInput'; import { pickAlt } from '@/lib/altText'; -import { DEFAULT_STORES_OFFSET_X, DEFAULT_STORES_OFFSET_Y, DEFAULT_STORES_SIZE, MAIN_PHOTO, PRODUCT_BG_PRESETS, badgeWidthFor, photoStack, productCardAlt, usesAppPrice } from '@/lib/productCard'; +import { DEFAULT_IMAGE_SCALE, DEFAULT_STORES_OFFSET_X, DEFAULT_STORES_OFFSET_Y, DEFAULT_STORES_SIZE, MAIN_PHOTO, PRODUCT_BG_PRESETS, badgeWidthFor, photoStack, productCardAlt, usesAppPrice } from '@/lib/productCard'; export { PRODUCT_BG_PRESETS }; @@ -337,7 +337,7 @@ export const ProductEditor: React.FC = ({ const isLoyalty = variant === 'loyalty'; const set = (key: string) => (v: unknown) => onChange({ [key]: v }); - const scale = p.imageScale ?? 1; + const scale = p.imageScale ?? DEFAULT_IMAGE_SCALE; const offsetX = p.imageOffsetX || 0; const offsetY = p.imageOffsetY || 0; const storesX = p.storesOffsetX ?? DEFAULT_STORES_OFFSET_X; diff --git a/src/lib/productCard.ts b/src/lib/productCard.ts index 6bc0db2..5c9ecc4 100644 --- a/src/lib/productCard.ts +++ b/src/lib/productCard.ts @@ -29,6 +29,8 @@ export interface StoresOffset { x?: number; // + doprava, − doľava y?: number; // + vyššie nad cenovku, − nižšie (cez horný okraj cenovky) } +// Predvolená veľkosť fotky produktu (zoom), keď ju produkt nemá nastavenú +export const DEFAULT_IMAGE_SCALE = 0.95; // Predvolená poloha štítkov voči pravému hornému rohu pozadia cenovky export const DEFAULT_STORES_OFFSET_X = -23; // Predvolená výška jedného štítka predajne (px), nezávislá od veľkosti cenovky @@ -214,7 +216,7 @@ export function cardVisualKey(p: CardProduct, ctx: CardContext): string { const t = p.badgeCustomTemplate; const relevant = [ ctx.variant, ctx.cardWidth, p.cardBgColor || ctx.cardBg, ctx.variant === 'standard' ? ctx.defaultBadge : null, - p.imageUrl, p.imageScale ?? 1, p.imageOffsetX || 0, p.imageOffsetY || 0, + p.imageUrl, p.imageScale ?? DEFAULT_IMAGE_SCALE, p.imageOffsetX || 0, p.imageOffsetY || 0, p.customBadgePngUrl, badgeWidthFor(p, ctx.variant), t ? [t.svgRaw, t.layersConfig, t.width] : null, p.priceMain, p.priceSub, p.discountText, p.badgeText, p.unitPrice, @@ -323,7 +325,7 @@ function renderVisualPreview(p: CardProduct, ctx: CardContext, key: string): str const height = cardVisualHeight(ctx.cardWidth); const bg = p.cardBgColor || ctx.cardBg; const bw = badgeWidthFor(p, ctx.variant); - const scale = p.imageScale ?? 1; + const scale = p.imageScale ?? DEFAULT_IMAGE_SCALE; const ox = p.imageOffsetX || 0; const oy = p.imageOffsetY || 0; const sx = Math.round(p.storesOffsetX ?? DEFAULT_STORES_OFFSET_X);