From c8b149d88760dc9369c51038c7efbb335ac7f795 Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Sun, 14 Dec 2025 18:24:47 +0100 Subject: [PATCH] using pressables to change numerical values --- .../js/admin/mobile/QrLayoutCustomizePage.tsx | 221 ++++++++++++------ 1 file changed, 147 insertions(+), 74 deletions(-) diff --git a/resources/js/admin/mobile/QrLayoutCustomizePage.tsx b/resources/js/admin/mobile/QrLayoutCustomizePage.tsx index bef238d..d68f9cf 100644 --- a/resources/js/admin/mobile/QrLayoutCustomizePage.tsx +++ b/resources/js/admin/mobile/QrLayoutCustomizePage.tsx @@ -306,6 +306,7 @@ type SlotDefinition = { fontFamily?: string; lineHeight?: number; align?: 'left' | 'center' | 'right'; + color?: string; }; type SlotOverrides = Record>; @@ -345,6 +346,7 @@ function normalizeSlotOverrides(raw: unknown): SlotOverrides { fontSize: toNumber(slot.fontSize), lineHeight: toNumber(slot.lineHeight), fontFamily: typeof slot.fontFamily === 'string' ? slot.fontFamily : undefined, + color: typeof slot.color === 'string' ? slot.color : undefined, align, }; return acc; @@ -392,11 +394,11 @@ function renderEventName(name: TenantEvent['name'] | null | undefined): string | function getDefaultSlots(): Record { return { - headline: { x: 0.08, y: 0.08, w: 0.84, fontSize: 30, fontWeight: 800, fontFamily: 'Playfair Display', align: 'center' }, - subtitle: { x: 0.1, y: 0.16, w: 0.8, fontSize: 18, fontWeight: 600, fontFamily: 'Montserrat', align: 'center' }, - description: { x: 0.1, y: 0.22, w: 0.8, fontSize: 16, fontFamily: 'Lora', lineHeight: 1.4, align: 'center' }, + headline: { x: 0.08, y: 0.15, w: 0.84, fontSize: 50, fontWeight: 800, fontFamily: 'Playfair Display', align: 'center' }, + subtitle: { x: 0.1, y: 0.21, w: 0.8, fontSize: 37, fontWeight: 600, fontFamily: 'Montserrat', align: 'center' }, + description: { x: 0.1, y: 0.66, w: 0.8, fontSize: 13, fontFamily: 'Lora', lineHeight: 1.4, align: 'center' }, instructions: { x: 0.1, y: 0.34, w: 0.8, fontSize: 14, fontFamily: 'Lora', lineHeight: 1.35 }, - qr: { x: 0.35, y: 0.55, w: 0.3 }, + qr: { x: 0.3, y: 0.3, w: 0.28 }, }; } @@ -425,11 +427,11 @@ function resolveSlots(layout: EventQrInviteLayout | null, isFoldable: boolean, o const baseSlots = isFoldable ? { - headline: { x: 0.1, y: 0.1, w: 0.8, fontSize: 28, fontWeight: 800, fontFamily: 'Playfair Display', align: 'center' }, - subtitle: { x: 0.12, y: 0.18, w: 0.76, fontSize: 18, fontWeight: 600, fontFamily: 'Montserrat', align: 'center' }, - description: { x: 0.12, y: 0.24, w: 0.76, fontSize: 15, fontFamily: 'Lora', lineHeight: 1.4, align: 'center' }, + headline: { x: 0.08, y: 0.15, w: 0.84, fontSize: 50, fontWeight: 800, fontFamily: 'Playfair Display', align: 'center' }, + subtitle: { x: 0.1, y: 0.21, w: 0.8, fontSize: 37, fontWeight: 600, fontFamily: 'Montserrat', align: 'center' }, + description: { x: 0.1, y: 0.66, w: 0.8, fontSize: 13, fontFamily: 'Lora', lineHeight: 1.4, align: 'center' }, instructions: { x: 0.12, y: 0.36, w: 0.76, fontSize: 13, fontFamily: 'Lora', lineHeight: 1.3 }, - qr: { x: 0.36, y: 0.56, w: 0.28 }, + qr: { x: 0.3, y: 0.3, w: 0.28 }, } : getDefaultSlots(); @@ -452,6 +454,7 @@ function applySlotOverrides(baseSlots: Record, overrides fontFamily: override.fontFamily ?? base.fontFamily, lineHeight: override.lineHeight ?? base.lineHeight, align: override.align ?? base.align, + color: override.color ?? base.color, }; return acc; }, {}); @@ -544,7 +547,7 @@ function buildFabricOptions({ align: slot.align ?? 'center', lineHeight: slot.lineHeight ?? 1.35, content, - fill: textColor, + fill: slot.color ?? textColor, fontFamily: slot.fontFamily, rotation, }); @@ -652,7 +655,11 @@ function BackgroundStep({ null; const isFoldable = (resolvedLayout?.panel_mode ?? '').toLowerCase() === 'double-mirror'; - const formatLabel = isFoldable ? 'A4 Landscape (Double/Mirror)' : 'A4 Portrait'; + const formatPaper = resolvePaper(resolvedLayout).toUpperCase(); + const orientation = ((resolvedLayout?.orientation ?? (isFoldable ? 'landscape' : 'portrait')) || '').toLowerCase() === 'landscape' ? 'Landscape' : 'Portrait'; + const formatLabel = isFoldable + ? `${formatPaper} Landscape (double A5/mirrored)` + : `${formatPaper} ${orientation}`; const disablePresets = isFoldable; const gradientPresets = [ { angle: 180, stops: ['#F8FAFC', '#EEF2FF', '#F8FAFC'], label: 'Soft Lilac' }, @@ -1129,12 +1136,13 @@ function LayoutControls({ }, [tenantFonts]); const numberInputStyle: React.CSSProperties = { - width: '100%', + width: 90, padding: '10px 12px', border: '1px solid #e5e7eb', borderRadius: 10, fontSize: 14, background: '#fff', + appearance: 'textfield', }; const selectStyle: React.CSSProperties = { @@ -1146,6 +1154,50 @@ function LayoutControls({ background: '#fff', }; + const StepperInput = ({ + value, + min, + max, + step, + onChange, + }: { + value: number; + min: number; + max: number; + step: number; + onChange: (value: number) => void; + }) => { + const dec = () => onChange(clampValue(value - step, min, max)); + const inc = () => onChange(clampValue(value + step, min, max)); + return ( + + + + + – + + + + onChange(Number(event.target.value))} + style={numberInputStyle} + /> + + + + + + + + + + ); + }; + const renderTextSlot = (slotKey: string, label: string) => { const slot = slots[slotKey]; if (!slot) return null; @@ -1175,80 +1227,116 @@ function LayoutControls({ {label} - + X (%) - onPercentChange('x')(Number(event.target.value))} - style={numberInputStyle} - /> + + onPercentChange('x')(((override.x ?? slot.x) * 100) - 0.5)}> + + + – + + + + onPercentChange('x')(Number(event.target.value))} + style={numberInputStyle} + /> + onPercentChange('x')(((override.x ?? slot.x) * 100) + 0.5)}> + + + + + + + + Y (%) - onPercentChange('y')(Number(event.target.value))} - style={numberInputStyle} + onPercentChange('y')(val)} /> Breite (%) - onPercentChange('w')(Number(event.target.value))} - style={numberInputStyle} + onPercentChange('w')(val)} /> - + Font Size (px) - onFontSizeChange(Number(event.target.value))} - style={numberInputStyle} - /> + onFontSizeChange(val)} /> + + + + Font Family + + + + + + {t('events.qr.fontColor', 'Schriftfarbe')} + + + onUpdateSlot(slotKey, { color: event.target.value })} + style={{ width: 48, height: 36, border: '1px solid #e5e7eb', borderRadius: 8, padding: 0, background: '#fff' }} + /> + onUpdateSlot(slotKey, { color: event.target.value })} + style={numberInputStyle} + /> + Line Height - onLineHeightChange(Number(event.target.value))} - style={numberInputStyle} - /> + onLineHeightChange(val)} /> + + Align @@ -1263,25 +1351,10 @@ function LayoutControls({ + + + - - - - Font Family - - - ); };