Expand branding controls and logo upload
This commit is contained in:
@@ -349,9 +349,14 @@ class EventController extends Controller
|
|||||||
$validated['settings']['watermark_allowed'] = $watermarkAllowed;
|
$validated['settings']['watermark_allowed'] = $watermarkAllowed;
|
||||||
|
|
||||||
$settings = $validated['settings'];
|
$settings = $validated['settings'];
|
||||||
|
$branding = Arr::get($settings, 'branding', []);
|
||||||
$watermark = Arr::get($settings, 'watermark', []);
|
$watermark = Arr::get($settings, 'watermark', []);
|
||||||
$existingWatermark = is_array($watermark) ? $watermark : [];
|
$existingWatermark = is_array($watermark) ? $watermark : [];
|
||||||
|
|
||||||
|
if (is_array($branding)) {
|
||||||
|
$settings['branding'] = $this->normalizeBrandingSettings($branding, $event, $brandingAllowed);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($watermark)) {
|
if (is_array($watermark)) {
|
||||||
$mode = $watermark['mode'] ?? 'base';
|
$mode = $watermark['mode'] ?? 'base';
|
||||||
$policy = $watermarkAllowed ? 'basic' : 'none';
|
$policy = $watermarkAllowed ? 'basic' : 'none';
|
||||||
@@ -442,6 +447,68 @@ class EventController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $branding
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function normalizeBrandingSettings(array $branding, Event $event, bool $brandingAllowed): array
|
||||||
|
{
|
||||||
|
$logoDataUrl = $branding['logo_data_url'] ?? null;
|
||||||
|
|
||||||
|
if (! $brandingAllowed) {
|
||||||
|
unset($branding['logo_data_url']);
|
||||||
|
|
||||||
|
return $branding;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_string($logoDataUrl) || trim($logoDataUrl) === '') {
|
||||||
|
unset($branding['logo_data_url']);
|
||||||
|
|
||||||
|
return $branding;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! preg_match('/^data:image\\/(png|webp|jpe?g);base64,(.+)$/i', $logoDataUrl, $matches)) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'settings.branding.logo_data_url' => __('Ungültiges Branding-Logo.'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$decoded = base64_decode($matches[2], true);
|
||||||
|
|
||||||
|
if ($decoded === false) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'settings.branding.logo_data_url' => __('Branding-Logo konnte nicht gelesen werden.'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($decoded) > 1024 * 1024) { // 1 MB
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'settings.branding.logo_data_url' => __('Branding-Logo ist zu groß (max. 1 MB).'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$extension = str_starts_with(strtolower($matches[1]), 'jp') ? 'jpg' : strtolower($matches[1]);
|
||||||
|
$path = sprintf('branding/logos/event-%s.%s', $event->id, $extension);
|
||||||
|
Storage::disk('public')->put($path, $decoded);
|
||||||
|
|
||||||
|
$branding['logo_url'] = $path;
|
||||||
|
$branding['logo_mode'] = 'upload';
|
||||||
|
$branding['logo_value'] = $path;
|
||||||
|
|
||||||
|
$logo = $branding['logo'] ?? [];
|
||||||
|
if (! is_array($logo)) {
|
||||||
|
$logo = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$logo['mode'] = 'upload';
|
||||||
|
$logo['value'] = $path;
|
||||||
|
$branding['logo'] = $logo;
|
||||||
|
|
||||||
|
unset($branding['logo_data_url']);
|
||||||
|
|
||||||
|
return $branding;
|
||||||
|
}
|
||||||
|
|
||||||
public function destroy(Request $request, Event $event): JsonResponse
|
public function destroy(Request $request, Event $event): JsonResponse
|
||||||
{
|
{
|
||||||
$tenantId = $request->attributes->get('tenant_id');
|
$tenantId = $request->attributes->get('tenant_id');
|
||||||
|
|||||||
@@ -121,6 +121,7 @@
|
|||||||
--guest-radius: 14px;
|
--guest-radius: 14px;
|
||||||
--guest-button-style: filled;
|
--guest-button-style: filled;
|
||||||
--guest-link: #007aff;
|
--guest-link: #007aff;
|
||||||
|
--guest-font-scale: 1;
|
||||||
--guest-font-family: 'Montserrat', 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
--guest-font-family: 'Montserrat', 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
||||||
--guest-body-font: 'Montserrat', 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
--guest-body-font: 'Montserrat', 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
||||||
--guest-heading-font: 'Playfair Display', 'Montserrat', 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
--guest-heading-font: 'Playfair Display', 'Montserrat', 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
||||||
@@ -516,6 +517,7 @@ html.guest-theme {
|
|||||||
--card: var(--guest-surface);
|
--card: var(--guest-surface);
|
||||||
--popover: var(--guest-surface);
|
--popover: var(--guest-surface);
|
||||||
background-color: var(--guest-background);
|
background-color: var(--guest-background);
|
||||||
|
font-size: calc(16px * var(--guest-font-scale, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
html.guest-theme.dark {
|
html.guest-theme.dark {
|
||||||
|
|||||||
@@ -1918,10 +1918,18 @@
|
|||||||
"titleShort": "Branding",
|
"titleShort": "Branding",
|
||||||
"previewTitle": "Guest-App-Vorschau",
|
"previewTitle": "Guest-App-Vorschau",
|
||||||
"previewSubtitle": "Aktuelle Farben & Schriften",
|
"previewSubtitle": "Aktuelle Farben & Schriften",
|
||||||
|
"previewCta": "Fotos hochladen",
|
||||||
"primary": "Primärfarbe",
|
"primary": "Primärfarbe",
|
||||||
"accent": "Akzentfarbe",
|
"accent": "Akzentfarbe",
|
||||||
"background": "Hintergrund",
|
"background": "Hintergrund",
|
||||||
"surface": "Fläche",
|
"surface": "Fläche",
|
||||||
|
"lockedBranding": "Branding ist in diesem Paket gesperrt.",
|
||||||
|
"source": "Branding-Quelle",
|
||||||
|
"sourceHint": "Nutze das Tenant-Branding oder überschreibe es für dieses Event.",
|
||||||
|
"useDefault": "Tenant",
|
||||||
|
"useCustom": "Event",
|
||||||
|
"usingDefault": "Tenant-Branding aktiv",
|
||||||
|
"usingCustom": "Event-Branding aktiv",
|
||||||
"mode": "Theme",
|
"mode": "Theme",
|
||||||
"modeLight": "Hell",
|
"modeLight": "Hell",
|
||||||
"modeAuto": "Auto",
|
"modeAuto": "Auto",
|
||||||
@@ -1936,13 +1944,37 @@
|
|||||||
"headingFontPlaceholder": "SF Pro Display",
|
"headingFontPlaceholder": "SF Pro Display",
|
||||||
"bodyFont": "Fließtext-Schrift",
|
"bodyFont": "Fließtext-Schrift",
|
||||||
"bodyFontPlaceholder": "SF Pro Text",
|
"bodyFontPlaceholder": "SF Pro Text",
|
||||||
|
"fontSize": "Schriftgröße",
|
||||||
|
"fontSizeSmall": "S",
|
||||||
|
"fontSizeMedium": "M",
|
||||||
|
"fontSizeLarge": "L",
|
||||||
"logo": "Logo",
|
"logo": "Logo",
|
||||||
"logoAlt": "Logo",
|
"logoAlt": "Logo",
|
||||||
|
"logoModeUpload": "Upload",
|
||||||
|
"logoModeEmoticon": "Emoticon",
|
||||||
|
"logoValue": "Emoticon",
|
||||||
|
"logoValuePlaceholder": "🎉",
|
||||||
|
"logoPosition": "Position",
|
||||||
|
"positionLeft": "Links",
|
||||||
|
"positionCenter": "Zentriert",
|
||||||
|
"positionRight": "Rechts",
|
||||||
|
"logoSize": "Größe",
|
||||||
|
"logoSizeSmall": "S",
|
||||||
|
"logoSizeMedium": "M",
|
||||||
|
"logoSizeLarge": "L",
|
||||||
"replaceLogo": "Logo ersetzen",
|
"replaceLogo": "Logo ersetzen",
|
||||||
"removeLogo": "Entfernen",
|
"removeLogo": "Entfernen",
|
||||||
"logoHint": "Lade ein Logo hoch, um Einladungen und QR-Poster zu branden.",
|
"logoHint": "Logo hochladen oder Emoji für den Guest-Header nutzen.",
|
||||||
"uploadLogo": "Logo hochladen (max. 1 MB)",
|
"uploadLogo": "Logo hochladen (max. 1 MB)",
|
||||||
"logoTooLarge": "Logo muss unter 1 MB sein.",
|
"logoTooLarge": "Logo muss unter 1 MB sein.",
|
||||||
|
"buttons": "Buttons & Links",
|
||||||
|
"buttonsHint": "Stil, Radius und Link-Farbe für CTAs.",
|
||||||
|
"buttonFilled": "Gefüllt",
|
||||||
|
"buttonOutline": "Outline",
|
||||||
|
"buttonRadius": "Radius",
|
||||||
|
"buttonPrimary": "Button Primär",
|
||||||
|
"buttonSecondary": "Button Sekundär",
|
||||||
|
"linkColor": "Link-Farbe",
|
||||||
"save": "Branding speichern",
|
"save": "Branding speichern",
|
||||||
"saving": "Speichere...",
|
"saving": "Speichere...",
|
||||||
"saveSuccess": "Branding gespeichert.",
|
"saveSuccess": "Branding gespeichert.",
|
||||||
|
|||||||
@@ -1922,10 +1922,18 @@
|
|||||||
"titleShort": "Branding",
|
"titleShort": "Branding",
|
||||||
"previewTitle": "Guest app preview",
|
"previewTitle": "Guest app preview",
|
||||||
"previewSubtitle": "Current colors & fonts",
|
"previewSubtitle": "Current colors & fonts",
|
||||||
|
"previewCta": "Upload photos",
|
||||||
"primary": "Primary",
|
"primary": "Primary",
|
||||||
"accent": "Accent",
|
"accent": "Accent",
|
||||||
"background": "Background",
|
"background": "Background",
|
||||||
"surface": "Surface",
|
"surface": "Surface",
|
||||||
|
"lockedBranding": "Branding is locked for this package.",
|
||||||
|
"source": "Branding source",
|
||||||
|
"sourceHint": "Use tenant branding or override for this event.",
|
||||||
|
"useDefault": "Tenant",
|
||||||
|
"useCustom": "Event",
|
||||||
|
"usingDefault": "Tenant branding active",
|
||||||
|
"usingCustom": "Event branding active",
|
||||||
"mode": "Theme",
|
"mode": "Theme",
|
||||||
"modeLight": "Light",
|
"modeLight": "Light",
|
||||||
"modeAuto": "Auto",
|
"modeAuto": "Auto",
|
||||||
@@ -1940,13 +1948,37 @@
|
|||||||
"headingFontPlaceholder": "SF Pro Display",
|
"headingFontPlaceholder": "SF Pro Display",
|
||||||
"bodyFont": "Body font",
|
"bodyFont": "Body font",
|
||||||
"bodyFontPlaceholder": "SF Pro Text",
|
"bodyFontPlaceholder": "SF Pro Text",
|
||||||
|
"fontSize": "Font size",
|
||||||
|
"fontSizeSmall": "S",
|
||||||
|
"fontSizeMedium": "M",
|
||||||
|
"fontSizeLarge": "L",
|
||||||
"logo": "Logo",
|
"logo": "Logo",
|
||||||
"logoAlt": "Logo",
|
"logoAlt": "Logo",
|
||||||
|
"logoModeUpload": "Upload",
|
||||||
|
"logoModeEmoticon": "Emoticon",
|
||||||
|
"logoValue": "Emoticon",
|
||||||
|
"logoValuePlaceholder": "🎉",
|
||||||
|
"logoPosition": "Position",
|
||||||
|
"positionLeft": "Left",
|
||||||
|
"positionCenter": "Center",
|
||||||
|
"positionRight": "Right",
|
||||||
|
"logoSize": "Size",
|
||||||
|
"logoSizeSmall": "S",
|
||||||
|
"logoSizeMedium": "M",
|
||||||
|
"logoSizeLarge": "L",
|
||||||
"replaceLogo": "Replace logo",
|
"replaceLogo": "Replace logo",
|
||||||
"removeLogo": "Remove",
|
"removeLogo": "Remove",
|
||||||
"logoHint": "Upload a logo to brand guest invites and QR posters.",
|
"logoHint": "Upload a logo or use an emoji for the guest header.",
|
||||||
"uploadLogo": "Upload logo (max. 1 MB)",
|
"uploadLogo": "Upload logo (max. 1 MB)",
|
||||||
"logoTooLarge": "Logo must be under 1 MB.",
|
"logoTooLarge": "Logo must be under 1 MB.",
|
||||||
|
"buttons": "Buttons & links",
|
||||||
|
"buttonsHint": "Style, radius, and link color for CTA buttons.",
|
||||||
|
"buttonFilled": "Filled",
|
||||||
|
"buttonOutline": "Outline",
|
||||||
|
"buttonRadius": "Radius",
|
||||||
|
"buttonPrimary": "Button primary",
|
||||||
|
"buttonSecondary": "Button secondary",
|
||||||
|
"linkColor": "Link color",
|
||||||
"save": "Save branding",
|
"save": "Save branding",
|
||||||
"saving": "Saving...",
|
"saving": "Saving...",
|
||||||
"saveSuccess": "Branding saved.",
|
"saveSuccess": "Branding saved.",
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ const defaults = {
|
|||||||
background: '#ffffff',
|
background: '#ffffff',
|
||||||
surface: '#f0f0f0',
|
surface: '#f0f0f0',
|
||||||
mode: 'auto' as const,
|
mode: 'auto' as const,
|
||||||
|
buttonStyle: 'filled' as const,
|
||||||
|
buttonRadius: 12,
|
||||||
|
buttonPrimary: '#111111',
|
||||||
|
buttonSecondary: '#222222',
|
||||||
|
linkColor: '#222222',
|
||||||
|
fontSize: 'm' as const,
|
||||||
|
logoMode: 'upload' as const,
|
||||||
|
logoPosition: 'left' as const,
|
||||||
|
logoSize: 'm' as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('extractBrandingForm', () => {
|
describe('extractBrandingForm', () => {
|
||||||
@@ -34,6 +43,7 @@ describe('extractBrandingForm', () => {
|
|||||||
expect(result.background).toBe('#000000');
|
expect(result.background).toBe('#000000');
|
||||||
expect(result.surface).toBe('#111111');
|
expect(result.surface).toBe('#111111');
|
||||||
expect(result.mode).toBe('dark');
|
expect(result.mode).toBe('dark');
|
||||||
|
expect(result.fontSize).toBe('m');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to legacy keys and defaults', () => {
|
it('falls back to legacy keys and defaults', () => {
|
||||||
@@ -52,5 +62,62 @@ describe('extractBrandingForm', () => {
|
|||||||
expect(result.background).toBe('#abcdef');
|
expect(result.background).toBe('#abcdef');
|
||||||
expect(result.surface).toBe('#abcdef');
|
expect(result.surface).toBe('#abcdef');
|
||||||
expect(result.mode).toBe('light');
|
expect(result.mode).toBe('light');
|
||||||
|
expect(result.buttonStyle).toBe(defaults.buttonStyle);
|
||||||
|
expect(result.buttonRadius).toBe(defaults.buttonRadius);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('extracts buttons, logo, and typography settings', () => {
|
||||||
|
const settings = {
|
||||||
|
branding: {
|
||||||
|
typography: {
|
||||||
|
heading: 'Display Font',
|
||||||
|
body: 'Body Font',
|
||||||
|
size: 'l',
|
||||||
|
},
|
||||||
|
buttons: {
|
||||||
|
style: 'outline',
|
||||||
|
radius: 24,
|
||||||
|
primary: '#333333',
|
||||||
|
secondary: '#444444',
|
||||||
|
link_color: '#555555',
|
||||||
|
},
|
||||||
|
logo: {
|
||||||
|
mode: 'emoticon',
|
||||||
|
value: '🎉',
|
||||||
|
position: 'center',
|
||||||
|
size: 'l',
|
||||||
|
},
|
||||||
|
use_default_branding: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = extractBrandingForm(settings, defaults);
|
||||||
|
|
||||||
|
expect(result.headingFont).toBe('Display Font');
|
||||||
|
expect(result.bodyFont).toBe('Body Font');
|
||||||
|
expect(result.fontSize).toBe('l');
|
||||||
|
expect(result.buttonStyle).toBe('outline');
|
||||||
|
expect(result.buttonRadius).toBe(24);
|
||||||
|
expect(result.buttonPrimary).toBe('#333333');
|
||||||
|
expect(result.buttonSecondary).toBe('#444444');
|
||||||
|
expect(result.linkColor).toBe('#555555');
|
||||||
|
expect(result.logoMode).toBe('emoticon');
|
||||||
|
expect(result.logoValue).toBe('🎉');
|
||||||
|
expect(result.logoPosition).toBe('center');
|
||||||
|
expect(result.logoSize).toBe('l');
|
||||||
|
expect(result.useDefaultBranding).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('normalizes stored logo paths for previews', () => {
|
||||||
|
const settings = {
|
||||||
|
branding: {
|
||||||
|
logo_url: 'branding/logos/event-123.png',
|
||||||
|
logo_mode: 'upload',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = extractBrandingForm(settings, defaults);
|
||||||
|
|
||||||
|
expect(result.logoDataUrl).toBe('/storage/branding/logos/event-123.png');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,11 +5,38 @@ export type BrandingFormValues = {
|
|||||||
surface: string;
|
surface: string;
|
||||||
headingFont: string;
|
headingFont: string;
|
||||||
bodyFont: string;
|
bodyFont: string;
|
||||||
|
fontSize: 's' | 'm' | 'l';
|
||||||
logoDataUrl: string;
|
logoDataUrl: string;
|
||||||
|
logoValue: string;
|
||||||
|
logoMode: 'upload' | 'emoticon';
|
||||||
|
logoPosition: 'left' | 'center' | 'right';
|
||||||
|
logoSize: 's' | 'm' | 'l';
|
||||||
mode: 'light' | 'dark' | 'auto';
|
mode: 'light' | 'dark' | 'auto';
|
||||||
|
buttonStyle: 'filled' | 'outline';
|
||||||
|
buttonRadius: number;
|
||||||
|
buttonPrimary: string;
|
||||||
|
buttonSecondary: string;
|
||||||
|
linkColor: string;
|
||||||
|
useDefaultBranding: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BrandingFormDefaults = Pick<BrandingFormValues, 'primary' | 'accent' | 'background' | 'surface' | 'mode'>;
|
export type BrandingFormDefaults = Pick<
|
||||||
|
BrandingFormValues,
|
||||||
|
| 'primary'
|
||||||
|
| 'accent'
|
||||||
|
| 'background'
|
||||||
|
| 'surface'
|
||||||
|
| 'mode'
|
||||||
|
| 'buttonStyle'
|
||||||
|
| 'buttonRadius'
|
||||||
|
| 'buttonPrimary'
|
||||||
|
| 'buttonSecondary'
|
||||||
|
| 'linkColor'
|
||||||
|
| 'fontSize'
|
||||||
|
| 'logoMode'
|
||||||
|
| 'logoPosition'
|
||||||
|
| 'logoSize'
|
||||||
|
>;
|
||||||
|
|
||||||
type BrandingRecord = Record<string, unknown>;
|
type BrandingRecord = Record<string, unknown>;
|
||||||
|
|
||||||
@@ -23,11 +50,48 @@ const readHexColor = (value: unknown, fallback: string): string => {
|
|||||||
return fallback;
|
return fallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const readEnum = <T extends string>(value: unknown, allowed: readonly T[], fallback: T): T => (
|
||||||
|
allowed.includes(value as T) ? (value as T) : fallback
|
||||||
|
);
|
||||||
|
|
||||||
|
const readNumber = (value: unknown, fallback: number): number => (
|
||||||
|
typeof value === 'number' && !Number.isNaN(value) ? value : fallback
|
||||||
|
);
|
||||||
|
|
||||||
|
const resolveAssetPreviewUrl = (value: string | null | undefined): string => {
|
||||||
|
if (typeof value !== 'string') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const trimmed = value.trim();
|
||||||
|
if (!trimmed) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trimmed.startsWith('data:') || trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized = trimmed.startsWith('/') ? trimmed.slice(1) : trimmed;
|
||||||
|
|
||||||
|
if (normalized.startsWith('storage/')) {
|
||||||
|
return `/${normalized}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.startsWith('branding/') || normalized.startsWith('tenant-branding/')) {
|
||||||
|
return `/storage/${normalized}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
||||||
|
};
|
||||||
|
|
||||||
export function extractBrandingForm(settings: unknown, defaults: BrandingFormDefaults): BrandingFormValues {
|
export function extractBrandingForm(settings: unknown, defaults: BrandingFormDefaults): BrandingFormValues {
|
||||||
const settingsRecord = isRecord(settings) ? settings : {};
|
const settingsRecord = isRecord(settings) ? settings : {};
|
||||||
const branding = isRecord(settingsRecord.branding) ? (settingsRecord.branding as BrandingRecord) : settingsRecord;
|
const branding = isRecord(settingsRecord.branding) ? (settingsRecord.branding as BrandingRecord) : settingsRecord;
|
||||||
const palette = isRecord(branding.palette) ? (branding.palette as BrandingRecord) : {};
|
const palette = isRecord(branding.palette) ? (branding.palette as BrandingRecord) : {};
|
||||||
const typography = isRecord(branding.typography) ? (branding.typography as BrandingRecord) : {};
|
const typography = isRecord(branding.typography) ? (branding.typography as BrandingRecord) : {};
|
||||||
|
const buttons = isRecord(branding.buttons) ? (branding.buttons as BrandingRecord) : {};
|
||||||
|
const logo = isRecord(branding.logo) ? (branding.logo as BrandingRecord) : {};
|
||||||
|
|
||||||
const primary = readHexColor(palette.primary, readHexColor(branding.primary_color, defaults.primary));
|
const primary = readHexColor(palette.primary, readHexColor(branding.primary_color, defaults.primary));
|
||||||
const accent = readHexColor(
|
const accent = readHexColor(
|
||||||
@@ -39,9 +103,27 @@ export function extractBrandingForm(settings: unknown, defaults: BrandingFormDef
|
|||||||
|
|
||||||
const headingFont = typeof typography.heading === 'string' ? typography.heading : (branding.heading_font as string | undefined);
|
const headingFont = typeof typography.heading === 'string' ? typography.heading : (branding.heading_font as string | undefined);
|
||||||
const bodyFont = typeof typography.body === 'string' ? typography.body : (branding.body_font as string | undefined);
|
const bodyFont = typeof typography.body === 'string' ? typography.body : (branding.body_font as string | undefined);
|
||||||
const mode = branding.mode === 'light' || branding.mode === 'dark' || branding.mode === 'auto'
|
const mode = readEnum(branding.mode, ['light', 'dark', 'auto'], defaults.mode);
|
||||||
? branding.mode
|
const fontSize = readEnum(typography.size ?? branding.font_size, ['s', 'm', 'l'], defaults.fontSize);
|
||||||
: defaults.mode;
|
|
||||||
|
const logoMode = readEnum(logo.mode ?? branding.logo_mode, ['upload', 'emoticon'], defaults.logoMode);
|
||||||
|
const logoValue = logoMode === 'emoticon'
|
||||||
|
? (typeof logo.value === 'string' ? logo.value : (branding.logo_value as string | undefined) ?? '')
|
||||||
|
: '';
|
||||||
|
const logoPosition = readEnum(logo.position ?? branding.logo_position, ['left', 'center', 'right'], defaults.logoPosition);
|
||||||
|
const logoSize = readEnum(logo.size ?? branding.logo_size, ['s', 'm', 'l'], defaults.logoSize);
|
||||||
|
const logoUploadValue =
|
||||||
|
typeof branding.logo_data_url === 'string'
|
||||||
|
? branding.logo_data_url
|
||||||
|
: logoMode === 'upload'
|
||||||
|
? (typeof logo.value === 'string' ? logo.value : (branding.logo_url as string | undefined))
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const buttonStyle = readEnum(buttons.style ?? branding.button_style, ['filled', 'outline'], defaults.buttonStyle);
|
||||||
|
const buttonRadius = readNumber(buttons.radius ?? branding.button_radius, defaults.buttonRadius);
|
||||||
|
const buttonPrimary = readHexColor(buttons.primary, readHexColor(branding.button_primary_color, primary));
|
||||||
|
const buttonSecondary = readHexColor(buttons.secondary, readHexColor(branding.button_secondary_color, accent));
|
||||||
|
const linkColor = readHexColor(buttons.link_color ?? buttons.linkColor, readHexColor(branding.link_color, accent));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
primary,
|
primary,
|
||||||
@@ -50,7 +132,18 @@ export function extractBrandingForm(settings: unknown, defaults: BrandingFormDef
|
|||||||
surface,
|
surface,
|
||||||
headingFont: headingFont ?? '',
|
headingFont: headingFont ?? '',
|
||||||
bodyFont: bodyFont ?? '',
|
bodyFont: bodyFont ?? '',
|
||||||
logoDataUrl: typeof branding.logo_data_url === 'string' ? branding.logo_data_url : '',
|
fontSize,
|
||||||
|
logoDataUrl: resolveAssetPreviewUrl(logoUploadValue),
|
||||||
|
logoValue,
|
||||||
|
logoMode,
|
||||||
|
logoPosition,
|
||||||
|
logoSize,
|
||||||
mode,
|
mode,
|
||||||
|
buttonStyle,
|
||||||
|
buttonRadius,
|
||||||
|
buttonPrimary,
|
||||||
|
buttonSecondary,
|
||||||
|
linkColor,
|
||||||
|
useDefaultBranding: branding.use_default_branding === true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { SizableText as Text } from '@tamagui/text';
|
|||||||
import { Pressable } from '@tamagui/react-native-web-lite';
|
import { Pressable } from '@tamagui/react-native-web-lite';
|
||||||
import { MobileShell, HeaderActionButton } from './components/MobileShell';
|
import { MobileShell, HeaderActionButton } from './components/MobileShell';
|
||||||
import { MobileCard, CTAButton, SkeletonCard } from './components/Primitives';
|
import { MobileCard, CTAButton, SkeletonCard } from './components/Primitives';
|
||||||
import { TenantEvent, getEvent, updateEvent, getTenantFonts, TenantFont, WatermarkSettings, trackOnboarding } from '../api';
|
import { TenantEvent, getEvent, updateEvent, getTenantFonts, getTenantSettings, TenantFont, WatermarkSettings, trackOnboarding } from '../api';
|
||||||
import { isAuthError } from '../auth/tokens';
|
import { isAuthError } from '../auth/tokens';
|
||||||
import { ApiError, getApiErrorMessage } from '../lib/apiError';
|
import { ApiError, getApiErrorMessage } from '../lib/apiError';
|
||||||
import { isBrandingAllowed } from '../lib/events';
|
import { isBrandingAllowed } from '../lib/events';
|
||||||
@@ -25,6 +25,15 @@ const BRANDING_FORM_DEFAULTS = {
|
|||||||
background: '#ffffff',
|
background: '#ffffff',
|
||||||
surface: '#ffffff',
|
surface: '#ffffff',
|
||||||
mode: 'auto' as const,
|
mode: 'auto' as const,
|
||||||
|
buttonStyle: 'filled' as const,
|
||||||
|
buttonRadius: 12,
|
||||||
|
buttonPrimary: ADMIN_COLORS.primary,
|
||||||
|
buttonSecondary: ADMIN_COLORS.accent,
|
||||||
|
linkColor: ADMIN_COLORS.accent,
|
||||||
|
fontSize: 'm' as const,
|
||||||
|
logoMode: 'upload' as const,
|
||||||
|
logoPosition: 'left' as const,
|
||||||
|
logoSize: 'm' as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
const BRANDING_FORM_BASE: BrandingFormValues = {
|
const BRANDING_FORM_BASE: BrandingFormValues = {
|
||||||
@@ -32,6 +41,20 @@ const BRANDING_FORM_BASE: BrandingFormValues = {
|
|||||||
headingFont: '',
|
headingFont: '',
|
||||||
bodyFont: '',
|
bodyFont: '',
|
||||||
logoDataUrl: '',
|
logoDataUrl: '',
|
||||||
|
logoValue: '',
|
||||||
|
useDefaultBranding: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const FONT_SIZE_SCALE: Record<BrandingFormValues['fontSize'], number> = {
|
||||||
|
s: 0.94,
|
||||||
|
m: 1,
|
||||||
|
l: 1.08,
|
||||||
|
};
|
||||||
|
|
||||||
|
const LOGO_SIZE_PREVIEW: Record<BrandingFormValues['logoSize'], number> = {
|
||||||
|
s: 28,
|
||||||
|
m: 36,
|
||||||
|
l: 44,
|
||||||
};
|
};
|
||||||
|
|
||||||
type WatermarkPosition =
|
type WatermarkPosition =
|
||||||
@@ -89,6 +112,8 @@ export default function MobileBrandingPage() {
|
|||||||
const [fonts, setFonts] = React.useState<TenantFont[]>([]);
|
const [fonts, setFonts] = React.useState<TenantFont[]>([]);
|
||||||
const [fontsLoading, setFontsLoading] = React.useState(false);
|
const [fontsLoading, setFontsLoading] = React.useState(false);
|
||||||
const [fontsLoaded, setFontsLoaded] = React.useState(false);
|
const [fontsLoaded, setFontsLoaded] = React.useState(false);
|
||||||
|
const [tenantBranding, setTenantBranding] = React.useState<BrandingFormValues | null>(null);
|
||||||
|
const [tenantBrandingLoaded, setTenantBrandingLoaded] = React.useState(false);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!slug) return;
|
if (!slug) return;
|
||||||
@@ -122,13 +147,42 @@ export default function MobileBrandingPage() {
|
|||||||
});
|
});
|
||||||
}, [showFontsSheet, fontsLoaded]);
|
}, [showFontsSheet, fontsLoaded]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (tenantBrandingLoaded) return;
|
||||||
|
let active = true;
|
||||||
|
getTenantSettings()
|
||||||
|
.then((payload) => {
|
||||||
|
if (!active) return;
|
||||||
|
setTenantBranding(extractBrandingForm(payload.settings ?? {}, BRANDING_FORM_DEFAULTS));
|
||||||
|
})
|
||||||
|
.catch(() => undefined)
|
||||||
|
.finally(() => {
|
||||||
|
if (active) {
|
||||||
|
setTenantBrandingLoaded(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false;
|
||||||
|
};
|
||||||
|
}, [tenantBrandingLoaded]);
|
||||||
|
|
||||||
|
const previewForm = form.useDefaultBranding && tenantBranding ? tenantBranding : form;
|
||||||
const previewTitle = event ? renderName(event.name) : t('events.placeholders.untitled', 'Unbenanntes Event');
|
const previewTitle = event ? renderName(event.name) : t('events.placeholders.untitled', 'Unbenanntes Event');
|
||||||
const previewHeadingFont = form.headingFont || 'Fraunces';
|
const previewHeadingFont = previewForm.headingFont || 'Fraunces';
|
||||||
const previewBodyFont = form.bodyFont || 'Manrope';
|
const previewBodyFont = previewForm.bodyFont || 'Manrope';
|
||||||
const previewSurfaceText = getContrastingTextColor(form.surface, '#ffffff', '#0f172a');
|
const previewSurfaceText = getContrastingTextColor(previewForm.surface, '#ffffff', '#0f172a');
|
||||||
|
const previewScale = FONT_SIZE_SCALE[previewForm.fontSize] ?? 1;
|
||||||
|
const previewButtonColor = previewForm.buttonPrimary || previewForm.primary;
|
||||||
|
const previewButtonText = getContrastingTextColor(previewButtonColor, '#ffffff', '#0f172a');
|
||||||
|
const previewLogoSize = LOGO_SIZE_PREVIEW[previewForm.logoSize] ?? 36;
|
||||||
|
const previewLogoUrl = previewForm.logoMode === 'upload' ? previewForm.logoDataUrl : '';
|
||||||
|
const previewLogoValue = previewForm.logoMode === 'emoticon' ? previewForm.logoValue : '';
|
||||||
|
const previewInitials = getInitials(previewTitle);
|
||||||
const watermarkAllowed = event?.package?.watermark_allowed !== false;
|
const watermarkAllowed = event?.package?.watermark_allowed !== false;
|
||||||
const brandingAllowed = isBrandingAllowed(event ?? null);
|
const brandingAllowed = isBrandingAllowed(event ?? null);
|
||||||
const watermarkLocked = watermarkAllowed && !brandingAllowed;
|
const watermarkLocked = watermarkAllowed && !brandingAllowed;
|
||||||
|
const brandingDisabled = !brandingAllowed || form.useDefaultBranding;
|
||||||
|
|
||||||
async function handleSave() {
|
async function handleSave() {
|
||||||
if (!event?.slug) return;
|
if (!event?.slug) return;
|
||||||
@@ -159,22 +213,38 @@ export default function MobileBrandingPage() {
|
|||||||
is_active: event.is_active ?? undefined,
|
is_active: event.is_active ?? undefined,
|
||||||
};
|
};
|
||||||
const settings = { ...(event.settings ?? {}) };
|
const settings = { ...(event.settings ?? {}) };
|
||||||
|
const logoUploadValue = form.logoMode === 'upload' ? form.logoDataUrl.trim() : '';
|
||||||
|
const logoIsDataUrl = logoUploadValue.startsWith('data:image/');
|
||||||
|
const normalizedLogoPath = logoIsDataUrl ? '' : normalizeBrandingPath(logoUploadValue);
|
||||||
|
const logoValue = form.logoMode === 'upload'
|
||||||
|
? (logoIsDataUrl ? logoUploadValue : normalizedLogoPath || null)
|
||||||
|
: (form.logoValue.trim() || null);
|
||||||
|
|
||||||
settings.branding = {
|
settings.branding = {
|
||||||
...(typeof settings.branding === 'object' ? (settings.branding as Record<string, unknown>) : {}),
|
...(typeof settings.branding === 'object' ? (settings.branding as Record<string, unknown>) : {}),
|
||||||
|
use_default_branding: form.useDefaultBranding,
|
||||||
primary_color: form.primary,
|
primary_color: form.primary,
|
||||||
secondary_color: form.accent,
|
secondary_color: form.accent,
|
||||||
accent_color: form.accent,
|
accent_color: form.accent,
|
||||||
background_color: form.background,
|
background_color: form.background,
|
||||||
surface_color: form.surface,
|
surface_color: form.surface,
|
||||||
|
font_family: form.bodyFont,
|
||||||
heading_font: form.headingFont,
|
heading_font: form.headingFont,
|
||||||
body_font: form.bodyFont,
|
body_font: form.bodyFont,
|
||||||
|
font_size: form.fontSize,
|
||||||
mode: form.mode,
|
mode: form.mode,
|
||||||
|
button_style: form.buttonStyle,
|
||||||
|
button_radius: form.buttonRadius,
|
||||||
|
button_primary_color: form.buttonPrimary,
|
||||||
|
button_secondary_color: form.buttonSecondary,
|
||||||
|
link_color: form.linkColor,
|
||||||
typography: {
|
typography: {
|
||||||
...(typeof (settings.branding as Record<string, unknown> | undefined)?.typography === 'object'
|
...(typeof (settings.branding as Record<string, unknown> | undefined)?.typography === 'object'
|
||||||
? ((settings.branding as Record<string, unknown>).typography as Record<string, unknown>)
|
? ((settings.branding as Record<string, unknown>).typography as Record<string, unknown>)
|
||||||
: {}),
|
: {}),
|
||||||
heading: form.headingFont,
|
heading: form.headingFont,
|
||||||
body: form.bodyFont,
|
body: form.bodyFont,
|
||||||
|
size: form.fontSize,
|
||||||
},
|
},
|
||||||
palette: {
|
palette: {
|
||||||
...(typeof (settings.branding as Record<string, unknown> | undefined)?.palette === 'object'
|
...(typeof (settings.branding as Record<string, unknown> | undefined)?.palette === 'object'
|
||||||
@@ -185,15 +255,28 @@ export default function MobileBrandingPage() {
|
|||||||
background: form.background,
|
background: form.background,
|
||||||
surface: form.surface,
|
surface: form.surface,
|
||||||
},
|
},
|
||||||
logo_data_url: form.logoDataUrl || null,
|
buttons: {
|
||||||
logo: form.logoDataUrl
|
...(typeof (settings.branding as Record<string, unknown> | undefined)?.buttons === 'object'
|
||||||
? {
|
? ((settings.branding as Record<string, unknown>).buttons as Record<string, unknown>)
|
||||||
mode: 'upload',
|
: {}),
|
||||||
value: form.logoDataUrl,
|
style: form.buttonStyle,
|
||||||
position: 'center',
|
radius: form.buttonRadius,
|
||||||
size: 'm',
|
primary: form.buttonPrimary,
|
||||||
}
|
secondary: form.buttonSecondary,
|
||||||
: null,
|
link_color: form.linkColor,
|
||||||
|
},
|
||||||
|
logo_data_url: form.logoMode === 'upload' && logoIsDataUrl ? logoUploadValue : null,
|
||||||
|
logo_url: form.logoMode === 'upload' ? (normalizedLogoPath || null) : null,
|
||||||
|
logo_mode: form.logoMode,
|
||||||
|
logo_value: logoValue,
|
||||||
|
logo_position: form.logoPosition,
|
||||||
|
logo_size: form.logoSize,
|
||||||
|
logo: {
|
||||||
|
mode: form.logoMode,
|
||||||
|
value: logoValue,
|
||||||
|
position: form.logoPosition,
|
||||||
|
size: form.logoSize,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const watermarkPayload = buildWatermarkPayload(watermarkForm, watermarkAllowed, brandingAllowed);
|
const watermarkPayload = buildWatermarkPayload(watermarkForm, watermarkAllowed, brandingAllowed);
|
||||||
if (watermarkPayload) {
|
if (watermarkPayload) {
|
||||||
@@ -445,27 +528,117 @@ export default function MobileBrandingPage() {
|
|||||||
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
||||||
{t('events.branding.previewTitle', 'Guest App Preview')}
|
{t('events.branding.previewTitle', 'Guest App Preview')}
|
||||||
</Text>
|
</Text>
|
||||||
<YStack borderRadius={16} borderWidth={1} borderColor={border} backgroundColor={form.background} padding="$3" space="$2" alignItems="center">
|
<YStack borderRadius={16} borderWidth={1} borderColor={border} backgroundColor={previewForm.background} padding="$3" space="$2" alignItems="center">
|
||||||
<YStack width="100%" borderRadius={12} backgroundColor={form.surface} borderWidth={1} borderColor={border} overflow="hidden">
|
<YStack width="100%" borderRadius={12} backgroundColor={previewForm.surface} borderWidth={1} borderColor={border} overflow="hidden">
|
||||||
<YStack backgroundColor={form.primary} height={64} />
|
<YStack
|
||||||
<YStack padding="$3" space="$1.5">
|
height={64}
|
||||||
<Text fontSize="$md" fontWeight="800" color={previewSurfaceText} style={{ fontFamily: previewHeadingFont }}>
|
style={{ background: `linear-gradient(135deg, ${previewForm.primary}, ${previewForm.accent})` }}
|
||||||
{previewTitle}
|
/>
|
||||||
</Text>
|
<YStack padding="$3" space="$2">
|
||||||
<Text fontSize="$sm" color={previewSurfaceText} style={{ fontFamily: previewBodyFont, opacity: 0.7 }}>
|
<XStack
|
||||||
{t('events.branding.previewSubtitle', 'Aktuelle Farben & Schriften')}
|
alignItems="center"
|
||||||
</Text>
|
space="$2"
|
||||||
|
flexDirection={previewForm.logoPosition === 'center' ? 'column' : previewForm.logoPosition === 'right' ? 'row-reverse' : 'row'}
|
||||||
|
justifyContent={previewForm.logoPosition === 'center' ? 'center' : 'flex-start'}
|
||||||
|
>
|
||||||
|
<YStack
|
||||||
|
width={previewLogoSize}
|
||||||
|
height={previewLogoSize}
|
||||||
|
borderRadius={previewLogoSize}
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
backgroundColor={previewForm.accent}
|
||||||
|
>
|
||||||
|
{previewLogoUrl ? (
|
||||||
|
<img
|
||||||
|
src={previewLogoUrl}
|
||||||
|
alt={t('events.branding.logoAlt', 'Logo')}
|
||||||
|
style={{ width: previewLogoSize - 6, height: previewLogoSize - 6, borderRadius: previewLogoSize, objectFit: 'cover' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Text fontSize="$sm" color={previewSurfaceText} fontWeight="700">
|
||||||
|
{previewLogoValue || previewInitials}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</YStack>
|
||||||
|
<YStack>
|
||||||
|
<Text
|
||||||
|
fontWeight="800"
|
||||||
|
color={previewSurfaceText}
|
||||||
|
style={{ fontFamily: previewHeadingFont, fontSize: 18 * previewScale }}
|
||||||
|
>
|
||||||
|
{previewTitle}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
color={previewSurfaceText}
|
||||||
|
style={{ fontFamily: previewBodyFont, opacity: 0.7, fontSize: 13 * previewScale }}
|
||||||
|
>
|
||||||
|
{t('events.branding.previewSubtitle', 'Aktuelle Farben & Schriften')}
|
||||||
|
</Text>
|
||||||
|
</YStack>
|
||||||
|
</XStack>
|
||||||
<XStack space="$2" marginTop="$1">
|
<XStack space="$2" marginTop="$1">
|
||||||
<ColorSwatch color={form.primary} label={t('events.branding.primary', 'Primary')} />
|
<ColorSwatch color={previewForm.primary} label={t('events.branding.primary', 'Primary')} />
|
||||||
<ColorSwatch color={form.accent} label={t('events.branding.accent', 'Accent')} />
|
<ColorSwatch color={previewForm.accent} label={t('events.branding.accent', 'Accent')} />
|
||||||
<ColorSwatch color={form.background} label={t('events.branding.background', 'Background')} />
|
<ColorSwatch color={previewForm.background} label={t('events.branding.background', 'Background')} />
|
||||||
<ColorSwatch color={form.surface} label={t('events.branding.surface', 'Surface')} />
|
<ColorSwatch color={previewForm.surface} label={t('events.branding.surface', 'Surface')} />
|
||||||
|
</XStack>
|
||||||
|
<XStack marginTop="$2">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
padding: '8px 14px',
|
||||||
|
borderRadius: previewForm.buttonRadius,
|
||||||
|
background: previewForm.buttonStyle === 'outline' ? 'transparent' : previewButtonColor,
|
||||||
|
color: previewForm.buttonStyle === 'outline' ? previewForm.linkColor : previewButtonText,
|
||||||
|
border: previewForm.buttonStyle === 'outline' ? `1px solid ${previewForm.linkColor}` : 'none',
|
||||||
|
fontWeight: 700,
|
||||||
|
fontSize: 13 * previewScale,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('events.branding.previewCta', 'Fotos hochladen')}
|
||||||
|
</div>
|
||||||
</XStack>
|
</XStack>
|
||||||
</YStack>
|
</YStack>
|
||||||
</YStack>
|
</YStack>
|
||||||
</YStack>
|
</YStack>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
|
|
||||||
|
{!brandingAllowed ? (
|
||||||
|
<InfoBadge
|
||||||
|
icon={<Lock size={16} color={danger} />}
|
||||||
|
text={t('events.branding.lockedBranding', 'Branding ist in diesem Paket gesperrt.')}
|
||||||
|
tone="danger"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<MobileCard space="$3">
|
||||||
|
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
||||||
|
{t('events.branding.source', 'Branding Source')}
|
||||||
|
</Text>
|
||||||
|
<Text fontSize="$sm" color={muted}>
|
||||||
|
{t('events.branding.sourceHint', 'Nutze das Tenant-Branding oder überschreibe es für dieses Event.')}
|
||||||
|
</Text>
|
||||||
|
<XStack space="$2">
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.useDefault', 'Tenant')}
|
||||||
|
active={form.useDefaultBranding}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, useDefaultBranding: true }))}
|
||||||
|
disabled={!brandingAllowed}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.useCustom', 'Event')}
|
||||||
|
active={!form.useDefaultBranding}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, useDefaultBranding: false }))}
|
||||||
|
disabled={!brandingAllowed}
|
||||||
|
/>
|
||||||
|
</XStack>
|
||||||
|
<Text fontSize="$xs" color={muted}>
|
||||||
|
{form.useDefaultBranding
|
||||||
|
? t('events.branding.usingDefault', 'Tenant-Branding aktiv')
|
||||||
|
: t('events.branding.usingCustom', 'Event-Branding aktiv')}
|
||||||
|
</Text>
|
||||||
|
</MobileCard>
|
||||||
|
|
||||||
<MobileCard space="$3">
|
<MobileCard space="$3">
|
||||||
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
||||||
{t('events.branding.mode', 'Theme')}
|
{t('events.branding.mode', 'Theme')}
|
||||||
@@ -475,16 +648,19 @@ export default function MobileBrandingPage() {
|
|||||||
label={t('events.branding.modeLight', 'Light')}
|
label={t('events.branding.modeLight', 'Light')}
|
||||||
active={form.mode === 'light'}
|
active={form.mode === 'light'}
|
||||||
onPress={() => setForm((prev) => ({ ...prev, mode: 'light' }))}
|
onPress={() => setForm((prev) => ({ ...prev, mode: 'light' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
<ModeButton
|
<ModeButton
|
||||||
label={t('events.branding.modeAuto', 'Auto')}
|
label={t('events.branding.modeAuto', 'Auto')}
|
||||||
active={form.mode === 'auto'}
|
active={form.mode === 'auto'}
|
||||||
onPress={() => setForm((prev) => ({ ...prev, mode: 'auto' }))}
|
onPress={() => setForm((prev) => ({ ...prev, mode: 'auto' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
<ModeButton
|
<ModeButton
|
||||||
label={t('events.branding.modeDark', 'Dark')}
|
label={t('events.branding.modeDark', 'Dark')}
|
||||||
active={form.mode === 'dark'}
|
active={form.mode === 'dark'}
|
||||||
onPress={() => setForm((prev) => ({ ...prev, mode: 'dark' }))}
|
onPress={() => setForm((prev) => ({ ...prev, mode: 'dark' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
</XStack>
|
</XStack>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
@@ -497,21 +673,25 @@ export default function MobileBrandingPage() {
|
|||||||
label={t('events.branding.primary', 'Primary Color')}
|
label={t('events.branding.primary', 'Primary Color')}
|
||||||
value={form.primary}
|
value={form.primary}
|
||||||
onChange={(value) => setForm((prev) => ({ ...prev, primary: value }))}
|
onChange={(value) => setForm((prev) => ({ ...prev, primary: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
<ColorField
|
<ColorField
|
||||||
label={t('events.branding.accent', 'Accent Color')}
|
label={t('events.branding.accent', 'Accent Color')}
|
||||||
value={form.accent}
|
value={form.accent}
|
||||||
onChange={(value) => setForm((prev) => ({ ...prev, accent: value }))}
|
onChange={(value) => setForm((prev) => ({ ...prev, accent: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
<ColorField
|
<ColorField
|
||||||
label={t('events.branding.backgroundColor', 'Background Color')}
|
label={t('events.branding.backgroundColor', 'Background Color')}
|
||||||
value={form.background}
|
value={form.background}
|
||||||
onChange={(value) => setForm((prev) => ({ ...prev, background: value }))}
|
onChange={(value) => setForm((prev) => ({ ...prev, background: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
<ColorField
|
<ColorField
|
||||||
label={t('events.branding.surfaceColor', 'Surface Color')}
|
label={t('events.branding.surfaceColor', 'Surface Color')}
|
||||||
value={form.surface}
|
value={form.surface}
|
||||||
onChange={(value) => setForm((prev) => ({ ...prev, surface: value }))}
|
onChange={(value) => setForm((prev) => ({ ...prev, surface: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
|
|
||||||
@@ -528,6 +708,7 @@ export default function MobileBrandingPage() {
|
|||||||
setFontField('heading');
|
setFontField('heading');
|
||||||
setShowFontsSheet(true);
|
setShowFontsSheet(true);
|
||||||
}}
|
}}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
<InputField
|
<InputField
|
||||||
label={t('events.branding.bodyFont', 'Body Font')}
|
label={t('events.branding.bodyFont', 'Body Font')}
|
||||||
@@ -538,105 +719,259 @@ export default function MobileBrandingPage() {
|
|||||||
setFontField('body');
|
setFontField('body');
|
||||||
setShowFontsSheet(true);
|
setShowFontsSheet(true);
|
||||||
}}
|
}}
|
||||||
|
disabled={brandingDisabled}
|
||||||
/>
|
/>
|
||||||
|
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
||||||
|
{t('events.branding.fontSize', 'Font Size')}
|
||||||
|
</Text>
|
||||||
|
<XStack space="$2">
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.fontSizeSmall', 'S')}
|
||||||
|
active={form.fontSize === 's'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, fontSize: 's' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.fontSizeMedium', 'M')}
|
||||||
|
active={form.fontSize === 'm'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, fontSize: 'm' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.fontSizeLarge', 'L')}
|
||||||
|
active={form.fontSize === 'l'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, fontSize: 'l' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
</XStack>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
|
|
||||||
<MobileCard space="$3">
|
<MobileCard space="$3">
|
||||||
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
||||||
{t('events.branding.logo', 'Logo')}
|
{t('events.branding.logo', 'Logo')}
|
||||||
</Text>
|
</Text>
|
||||||
<YStack
|
<Text fontSize="$sm" color={muted}>
|
||||||
borderRadius={14}
|
{t('events.branding.logoHint', 'Upload a logo or use an emoji for the guest header.')}
|
||||||
borderWidth={1}
|
</Text>
|
||||||
borderColor={border}
|
<XStack space="$2">
|
||||||
backgroundColor={surfaceMuted}
|
<ModeButton
|
||||||
padding="$3"
|
label={t('events.branding.logoModeUpload', 'Upload')}
|
||||||
alignItems="center"
|
active={form.logoMode === 'upload'}
|
||||||
justifyContent="center"
|
onPress={() => setForm((prev) => ({ ...prev, logoMode: 'upload' }))}
|
||||||
space="$2"
|
disabled={brandingDisabled}
|
||||||
>
|
/>
|
||||||
{form.logoDataUrl ? (
|
<ModeButton
|
||||||
<>
|
label={t('events.branding.logoModeEmoticon', 'Emoticon')}
|
||||||
<img
|
active={form.logoMode === 'emoticon'}
|
||||||
src={form.logoDataUrl}
|
onPress={() => setForm((prev) => ({ ...prev, logoMode: 'emoticon' }))}
|
||||||
alt={t('events.branding.logoAlt', 'Logo')}
|
disabled={brandingDisabled}
|
||||||
style={{ maxHeight: 80, maxWidth: '100%', objectFit: 'contain' }}
|
/>
|
||||||
/>
|
</XStack>
|
||||||
<XStack space="$2">
|
|
||||||
<CTAButton
|
{form.logoMode === 'emoticon' ? (
|
||||||
label={t('events.branding.replaceLogo', 'Replace logo')}
|
<InputField
|
||||||
onPress={() => document.getElementById('branding-logo-input')?.click()}
|
label={t('events.branding.logoValue', 'Emoticon')}
|
||||||
|
value={form.logoValue}
|
||||||
|
placeholder={t('events.branding.logoValuePlaceholder', '🎉')}
|
||||||
|
onChange={(value) => setForm((prev) => ({ ...prev, logoValue: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<YStack
|
||||||
|
borderRadius={14}
|
||||||
|
borderWidth={1}
|
||||||
|
borderColor={border}
|
||||||
|
backgroundColor={surfaceMuted}
|
||||||
|
padding="$3"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
space="$2"
|
||||||
|
>
|
||||||
|
{form.logoDataUrl ? (
|
||||||
|
<>
|
||||||
|
<img
|
||||||
|
src={form.logoDataUrl}
|
||||||
|
alt={t('events.branding.logoAlt', 'Logo')}
|
||||||
|
style={{ maxHeight: 80, maxWidth: '100%', objectFit: 'contain' }}
|
||||||
/>
|
/>
|
||||||
<Pressable onPress={() => setForm((prev) => ({ ...prev, logoDataUrl: '' }))}>
|
<XStack space="$2">
|
||||||
|
<CTAButton
|
||||||
|
label={t('events.branding.replaceLogo', 'Replace logo')}
|
||||||
|
onPress={() => document.getElementById('branding-logo-input')?.click()}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<Pressable
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, logoDataUrl: '' }))}
|
||||||
|
>
|
||||||
|
<XStack
|
||||||
|
alignItems="center"
|
||||||
|
space="$1.5"
|
||||||
|
paddingHorizontal="$3"
|
||||||
|
paddingVertical="$2"
|
||||||
|
borderRadius={12}
|
||||||
|
borderWidth={1}
|
||||||
|
borderColor={border}
|
||||||
|
>
|
||||||
|
<Trash2 size={16} color={danger} />
|
||||||
|
<Text fontSize="$sm" color={danger} fontWeight="700">
|
||||||
|
{t('events.branding.removeLogo', 'Remove')}
|
||||||
|
</Text>
|
||||||
|
</XStack>
|
||||||
|
</Pressable>
|
||||||
|
</XStack>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<ImageIcon size={28} color={subtle} />
|
||||||
|
<Pressable
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
onPress={() => document.getElementById('branding-logo-input')?.click()}
|
||||||
|
>
|
||||||
<XStack
|
<XStack
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
space="$1.5"
|
space="$2"
|
||||||
paddingHorizontal="$3"
|
paddingHorizontal="$3.5"
|
||||||
paddingVertical="$2"
|
paddingVertical="$2.5"
|
||||||
borderRadius={12}
|
borderRadius={12}
|
||||||
borderWidth={1}
|
borderWidth={1}
|
||||||
borderColor={border}
|
borderColor={border}
|
||||||
|
backgroundColor={surface}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} color={danger} />
|
<UploadCloud size={18} color={primary} />
|
||||||
<Text fontSize="$sm" color={danger} fontWeight="700">
|
<Text fontSize="$sm" color={primary} fontWeight="700">
|
||||||
{t('events.branding.removeLogo', 'Remove')}
|
{t('events.branding.uploadLogo', 'Upload logo (max. 1 MB)')}
|
||||||
</Text>
|
</Text>
|
||||||
</XStack>
|
</XStack>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</XStack>
|
</>
|
||||||
</>
|
)}
|
||||||
) : (
|
<input
|
||||||
<>
|
id="branding-logo-input"
|
||||||
<ImageIcon size={28} color={subtle} />
|
type="file"
|
||||||
<Text fontSize="$sm" color={muted} textAlign="center">
|
accept="image/*"
|
||||||
{t('events.branding.logoHint', 'Upload a logo to brand guest invites and QR posters.')}
|
style={{ display: 'none' }}
|
||||||
</Text>
|
disabled={brandingDisabled}
|
||||||
<Pressable onPress={() => document.getElementById('branding-logo-input')?.click()}>
|
onChange={(event) => {
|
||||||
<XStack
|
const file = event.target.files?.[0];
|
||||||
alignItems="center"
|
if (!file) return;
|
||||||
space="$2"
|
if (file.size > 1024 * 1024) {
|
||||||
paddingHorizontal="$3.5"
|
setError(t('events.branding.logoTooLarge', 'Logo must be under 1 MB.'));
|
||||||
paddingVertical="$2.5"
|
return;
|
||||||
borderRadius={12}
|
}
|
||||||
borderWidth={1}
|
const reader = new FileReader();
|
||||||
borderColor={border}
|
reader.onload = () => {
|
||||||
backgroundColor={surface}
|
const nextLogo =
|
||||||
>
|
typeof reader.result === 'string'
|
||||||
<UploadCloud size={18} color={primary} />
|
? reader.result
|
||||||
<Text fontSize="$sm" color={primary} fontWeight="700">
|
: typeof reader.result === 'object' && reader.result !== null
|
||||||
{t('events.branding.uploadLogo', 'Upload logo (max. 1 MB)')}
|
? String(reader.result)
|
||||||
</Text>
|
: '';
|
||||||
</XStack>
|
setForm((prev) => ({ ...prev, logoDataUrl: nextLogo }));
|
||||||
</Pressable>
|
setError(null);
|
||||||
</>
|
};
|
||||||
)}
|
reader.readAsDataURL(file);
|
||||||
<input
|
}}
|
||||||
id="branding-logo-input"
|
/>
|
||||||
type="file"
|
</YStack>
|
||||||
accept="image/*"
|
)}
|
||||||
style={{ display: 'none' }}
|
|
||||||
onChange={(event) => {
|
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
||||||
const file = event.target.files?.[0];
|
{t('events.branding.logoPosition', 'Position')}
|
||||||
if (!file) return;
|
</Text>
|
||||||
if (file.size > 1024 * 1024) {
|
<XStack space="$2">
|
||||||
setError(t('events.branding.logoTooLarge', 'Logo must be under 1 MB.'));
|
<ModeButton
|
||||||
return;
|
label={t('events.branding.positionLeft', 'Left')}
|
||||||
}
|
active={form.logoPosition === 'left'}
|
||||||
const reader = new FileReader();
|
onPress={() => setForm((prev) => ({ ...prev, logoPosition: 'left' }))}
|
||||||
reader.onload = () => {
|
disabled={brandingDisabled}
|
||||||
const nextLogo =
|
|
||||||
typeof reader.result === 'string'
|
|
||||||
? reader.result
|
|
||||||
: typeof reader.result === 'object' && reader.result !== null
|
|
||||||
? String(reader.result)
|
|
||||||
: '';
|
|
||||||
setForm((prev) => ({ ...prev, logoDataUrl: nextLogo }));
|
|
||||||
setError(null);
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</YStack>
|
<ModeButton
|
||||||
|
label={t('events.branding.positionCenter', 'Center')}
|
||||||
|
active={form.logoPosition === 'center'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, logoPosition: 'center' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.positionRight', 'Right')}
|
||||||
|
active={form.logoPosition === 'right'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, logoPosition: 'right' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
</XStack>
|
||||||
|
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
||||||
|
{t('events.branding.logoSize', 'Size')}
|
||||||
|
</Text>
|
||||||
|
<XStack space="$2">
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.logoSizeSmall', 'S')}
|
||||||
|
active={form.logoSize === 's'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, logoSize: 's' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.logoSizeMedium', 'M')}
|
||||||
|
active={form.logoSize === 'm'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, logoSize: 'm' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.logoSizeLarge', 'L')}
|
||||||
|
active={form.logoSize === 'l'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, logoSize: 'l' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
</XStack>
|
||||||
|
</MobileCard>
|
||||||
|
|
||||||
|
<MobileCard space="$3">
|
||||||
|
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
||||||
|
{t('events.branding.buttons', 'Buttons & Links')}
|
||||||
|
</Text>
|
||||||
|
<Text fontSize="$sm" color={muted}>
|
||||||
|
{t('events.branding.buttonsHint', 'Style, radius, and link color for CTA buttons.')}
|
||||||
|
</Text>
|
||||||
|
<XStack space="$2">
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.buttonFilled', 'Filled')}
|
||||||
|
active={form.buttonStyle === 'filled'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, buttonStyle: 'filled' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ModeButton
|
||||||
|
label={t('events.branding.buttonOutline', 'Outline')}
|
||||||
|
active={form.buttonStyle === 'outline'}
|
||||||
|
onPress={() => setForm((prev) => ({ ...prev, buttonStyle: 'outline' }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
</XStack>
|
||||||
|
<LabeledSlider
|
||||||
|
label={t('events.branding.buttonRadius', 'Radius')}
|
||||||
|
value={form.buttonRadius}
|
||||||
|
min={0}
|
||||||
|
max={32}
|
||||||
|
step={1}
|
||||||
|
onChange={(value) => setForm((prev) => ({ ...prev, buttonRadius: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ColorField
|
||||||
|
label={t('events.branding.buttonPrimary', 'Button Primary')}
|
||||||
|
value={form.buttonPrimary}
|
||||||
|
onChange={(value) => setForm((prev) => ({ ...prev, buttonPrimary: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ColorField
|
||||||
|
label={t('events.branding.buttonSecondary', 'Button Secondary')}
|
||||||
|
value={form.buttonSecondary}
|
||||||
|
onChange={(value) => setForm((prev) => ({ ...prev, buttonSecondary: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
|
<ColorField
|
||||||
|
label={t('events.branding.linkColor', 'Link Color')}
|
||||||
|
value={form.linkColor}
|
||||||
|
onChange={(value) => setForm((prev) => ({ ...prev, linkColor: value }))}
|
||||||
|
disabled={brandingDisabled}
|
||||||
|
/>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@@ -787,10 +1122,47 @@ function renderName(name: TenantEvent['name']): string {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function ColorField({ label, value, onChange }: { label: string; value: string; onChange: (next: string) => void }) {
|
function normalizeBrandingPath(value: string): string {
|
||||||
|
const trimmed = value.trim();
|
||||||
|
if (!trimmed) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trimmed.startsWith('http://') || trimmed.startsWith('https://') || trimmed.startsWith('data:')) {
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized = trimmed.replace(/^\/+/, '');
|
||||||
|
|
||||||
|
if (normalized.startsWith('storage/')) {
|
||||||
|
return normalized.slice('storage/'.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInitials(name: string): string {
|
||||||
|
const words = name.split(' ').filter(Boolean);
|
||||||
|
if (words.length >= 2) {
|
||||||
|
return `${words[0][0]}${words[1][0]}`.toUpperCase();
|
||||||
|
}
|
||||||
|
return name.substring(0, 2).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function ColorField({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
disabled,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
onChange: (next: string) => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
}) {
|
||||||
const { textStrong, muted, border, surface } = useAdminTheme();
|
const { textStrong, muted, border, surface } = useAdminTheme();
|
||||||
return (
|
return (
|
||||||
<YStack space="$2">
|
<YStack space="$2" opacity={disabled ? 0.6 : 1}>
|
||||||
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
||||||
{label}
|
{label}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -799,6 +1171,7 @@ function ColorField({ label, value, onChange }: { label: string; value: string;
|
|||||||
type="color"
|
type="color"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(event) => onChange(event.target.value)}
|
onChange={(event) => onChange(event.target.value)}
|
||||||
|
disabled={disabled}
|
||||||
style={{ width: 52, height: 52, borderRadius: 12, border: `1px solid ${border}`, background: surface }}
|
style={{ width: 52, height: 52, borderRadius: 12, border: `1px solid ${border}`, background: surface }}
|
||||||
/>
|
/>
|
||||||
<Text fontSize="$sm" color={muted}>
|
<Text fontSize="$sm" color={muted}>
|
||||||
@@ -828,6 +1201,7 @@ function InputField({
|
|||||||
onChange,
|
onChange,
|
||||||
onPicker,
|
onPicker,
|
||||||
children,
|
children,
|
||||||
|
disabled,
|
||||||
}: {
|
}: {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
@@ -835,10 +1209,11 @@ function InputField({
|
|||||||
onChange: (next: string) => void;
|
onChange: (next: string) => void;
|
||||||
onPicker?: () => void;
|
onPicker?: () => void;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
|
disabled?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { textStrong, border, surface, primary } = useAdminTheme();
|
const { textStrong, border, surface, primary } = useAdminTheme();
|
||||||
return (
|
return (
|
||||||
<YStack space="$2">
|
<YStack space="$2" opacity={disabled ? 0.6 : 1}>
|
||||||
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
<Text fontSize="$sm" fontWeight="700" color={textStrong}>
|
||||||
{label}
|
{label}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -859,6 +1234,7 @@ function InputField({
|
|||||||
value={value}
|
value={value}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onChange={(event) => onChange(event.target.value)}
|
onChange={(event) => onChange(event.target.value)}
|
||||||
|
disabled={disabled}
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -871,7 +1247,7 @@ function InputField({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{onPicker ? (
|
{onPicker ? (
|
||||||
<Pressable onPress={onPicker}>
|
<Pressable onPress={onPicker} disabled={disabled}>
|
||||||
<ChevronDown size={16} color={primary} />
|
<ChevronDown size={16} color={primary} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -1104,10 +1480,20 @@ function TabButton({ label, active, onPress }: { label: string; active: boolean;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModeButton({ label, active, onPress }: { label: string; active: boolean; onPress: () => void }) {
|
function ModeButton({
|
||||||
|
label,
|
||||||
|
active,
|
||||||
|
onPress,
|
||||||
|
disabled,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
active: boolean;
|
||||||
|
onPress: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
}) {
|
||||||
const { backdrop, surfaceMuted, border, surface } = useAdminTheme();
|
const { backdrop, surfaceMuted, border, surface } = useAdminTheme();
|
||||||
return (
|
return (
|
||||||
<Pressable onPress={onPress} style={{ flex: 1 }}>
|
<Pressable onPress={onPress} disabled={disabled} style={{ flex: 1, opacity: disabled ? 0.6 : 1 }}>
|
||||||
<XStack
|
<XStack
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
justifyContent="center"
|
justifyContent="center"
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ const EVENT_ICON_COMPONENTS: Record<string, React.ComponentType<{ className?: st
|
|||||||
camera: Camera,
|
camera: Camera,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type LogoSize = 's' | 'm' | 'l';
|
||||||
|
|
||||||
|
const LOGO_SIZE_CLASSES: Record<LogoSize, { container: string; image: string; emoji: string; icon: string }> = {
|
||||||
|
s: { container: 'h-8 w-8', image: 'h-7 w-7', emoji: 'text-lg', icon: 'h-4 w-4' },
|
||||||
|
m: { container: 'h-10 w-10', image: 'h-9 w-9', emoji: 'text-xl', icon: 'h-5 w-5' },
|
||||||
|
l: { container: 'h-12 w-12', image: 'h-11 w-11', emoji: 'text-2xl', icon: 'h-6 w-6' },
|
||||||
|
};
|
||||||
|
|
||||||
|
function getLogoClasses(size?: LogoSize) {
|
||||||
|
return LOGO_SIZE_CLASSES[size ?? 'm'];
|
||||||
|
}
|
||||||
|
|
||||||
const NOTIFICATION_ICON_MAP: Record<string, React.ComponentType<{ className?: string }>> = {
|
const NOTIFICATION_ICON_MAP: Record<string, React.ComponentType<{ className?: string }>> = {
|
||||||
broadcast: MessageSquare,
|
broadcast: MessageSquare,
|
||||||
feedback_request: MessageSquare,
|
feedback_request: MessageSquare,
|
||||||
@@ -69,18 +81,25 @@ function getInitials(name: string): string {
|
|||||||
return name.substring(0, 2).toUpperCase();
|
return name.substring(0, 2).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEventAvatar(name: string, icon: unknown, accentColor: string, textColor: string, logo?: { mode: 'emoticon' | 'upload'; value: string | null }) {
|
function renderEventAvatar(
|
||||||
|
name: string,
|
||||||
|
icon: unknown,
|
||||||
|
accentColor: string,
|
||||||
|
textColor: string,
|
||||||
|
logo?: { mode: 'emoticon' | 'upload'; value: string | null; size?: LogoSize }
|
||||||
|
) {
|
||||||
|
const sizes = getLogoClasses(logo?.size);
|
||||||
if (logo?.mode === 'upload' && logo.value) {
|
if (logo?.mode === 'upload' && logo.value) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-white shadow-sm">
|
<div className={`flex items-center justify-center rounded-full bg-white shadow-sm ${sizes.container}`}>
|
||||||
<img src={logo.value} alt={name} className="h-9 w-9 rounded-full object-contain" />
|
<img src={logo.value} alt={name} className={`rounded-full object-contain ${sizes.image}`} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (logo?.mode === 'emoticon' && logo.value && isLikelyEmoji(logo.value)) {
|
if (logo?.mode === 'emoticon' && logo.value && isLikelyEmoji(logo.value)) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex h-10 w-10 items-center justify-center rounded-full text-xl shadow-sm"
|
className={`flex items-center justify-center rounded-full shadow-sm ${sizes.container} ${sizes.emoji}`}
|
||||||
style={{ backgroundColor: accentColor, color: textColor }}
|
style={{ backgroundColor: accentColor, color: textColor }}
|
||||||
>
|
>
|
||||||
<span aria-hidden>{logo.value}</span>
|
<span aria-hidden>{logo.value}</span>
|
||||||
@@ -94,21 +113,21 @@ function renderEventAvatar(name: string, icon: unknown, accentColor: string, tex
|
|||||||
if (trimmed) {
|
if (trimmed) {
|
||||||
const normalized = trimmed.toLowerCase();
|
const normalized = trimmed.toLowerCase();
|
||||||
const IconComponent = EVENT_ICON_COMPONENTS[normalized];
|
const IconComponent = EVENT_ICON_COMPONENTS[normalized];
|
||||||
if (IconComponent) {
|
if (IconComponent) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex h-10 w-10 items-center justify-center rounded-full shadow-sm"
|
className={`flex items-center justify-center rounded-full shadow-sm ${sizes.container}`}
|
||||||
style={{ backgroundColor: accentColor, color: textColor }}
|
style={{ backgroundColor: accentColor, color: textColor }}
|
||||||
>
|
>
|
||||||
<IconComponent className="h-5 w-5" aria-hidden />
|
<IconComponent className={sizes.icon} aria-hidden />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLikelyEmoji(trimmed)) {
|
if (isLikelyEmoji(trimmed)) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex h-10 w-10 items-center justify-center rounded-full text-xl shadow-sm"
|
className={`flex items-center justify-center rounded-full shadow-sm ${sizes.container} ${sizes.emoji}`}
|
||||||
style={{ backgroundColor: accentColor, color: textColor }}
|
style={{ backgroundColor: accentColor, color: textColor }}
|
||||||
>
|
>
|
||||||
<span aria-hidden>{trimmed}</span>
|
<span aria-hidden>{trimmed}</span>
|
||||||
@@ -188,6 +207,7 @@ export default function Header({ eventToken, title = '' }: { eventToken?: string
|
|||||||
|
|
||||||
const headerFont = branding.typography?.heading ?? branding.fontFamily ?? undefined;
|
const headerFont = branding.typography?.heading ?? branding.fontFamily ?? undefined;
|
||||||
const bodyFont = branding.typography?.body ?? branding.fontFamily ?? undefined;
|
const bodyFont = branding.typography?.body ?? branding.fontFamily ?? undefined;
|
||||||
|
const logoPosition = branding.logo?.position ?? 'left';
|
||||||
const headerStyle: React.CSSProperties = {
|
const headerStyle: React.CSSProperties = {
|
||||||
background: `linear-gradient(135deg, ${branding.primaryColor}, ${branding.secondaryColor})`,
|
background: `linear-gradient(135deg, ${branding.primaryColor}, ${branding.secondaryColor})`,
|
||||||
color: headerTextColor,
|
color: headerTextColor,
|
||||||
@@ -219,9 +239,20 @@ export default function Header({ eventToken, title = '' }: { eventToken?: string
|
|||||||
className="guest-header z-20 flex items-center justify-between border-b border-white/10 px-4 py-3 text-white shadow-sm backdrop-blur"
|
className="guest-header z-20 flex items-center justify-between border-b border-white/10 px-4 py-3 text-white shadow-sm backdrop-blur"
|
||||||
style={headerStyle}
|
style={headerStyle}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-3">
|
<div
|
||||||
|
className={
|
||||||
|
logoPosition === 'center'
|
||||||
|
? 'flex flex-col items-center gap-2 text-center'
|
||||||
|
: logoPosition === 'right'
|
||||||
|
? 'flex flex-row-reverse items-center gap-3'
|
||||||
|
: 'flex items-center gap-3'
|
||||||
|
}
|
||||||
|
>
|
||||||
{renderEventAvatar(event.name, event.type?.icon, accentColor, headerTextColor, branding.logo)}
|
{renderEventAvatar(event.name, event.type?.icon, accentColor, headerTextColor, branding.logo)}
|
||||||
<div className="flex flex-col" style={headerFont ? { fontFamily: headerFont } : undefined}>
|
<div
|
||||||
|
className={`flex flex-col${logoPosition === 'center' ? ' items-center text-center' : ''}`}
|
||||||
|
style={headerFont ? { fontFamily: headerFont } : undefined}
|
||||||
|
>
|
||||||
<div className="font-semibold text-lg">{event.name}</div>
|
<div className="font-semibold text-lg">{event.name}</div>
|
||||||
<div className="flex items-center gap-2 text-xs text-white/70" style={bodyFont ? { fontFamily: bodyFont } : undefined}>
|
<div className="flex items-center gap-2 text-xs text-white/70" style={bodyFont ? { fontFamily: bodyFont } : undefined}>
|
||||||
{stats && tasksEnabled && (
|
{stats && tasksEnabled && (
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ export const DEFAULT_EVENT_BRANDING: EventBranding = {
|
|||||||
const DEFAULT_PRIMARY = DEFAULT_EVENT_BRANDING.primaryColor.toLowerCase();
|
const DEFAULT_PRIMARY = DEFAULT_EVENT_BRANDING.primaryColor.toLowerCase();
|
||||||
const DEFAULT_SECONDARY = DEFAULT_EVENT_BRANDING.secondaryColor.toLowerCase();
|
const DEFAULT_SECONDARY = DEFAULT_EVENT_BRANDING.secondaryColor.toLowerCase();
|
||||||
const DEFAULT_BACKGROUND = DEFAULT_EVENT_BRANDING.backgroundColor.toLowerCase();
|
const DEFAULT_BACKGROUND = DEFAULT_EVENT_BRANDING.backgroundColor.toLowerCase();
|
||||||
|
const FONT_SCALE_MAP: Record<'s' | 'm' | 'l', number> = {
|
||||||
|
s: 0.94,
|
||||||
|
m: 1,
|
||||||
|
l: 1.08,
|
||||||
|
};
|
||||||
|
|
||||||
const EventBrandingContext = createContext<EventBrandingContextValue | undefined>(undefined);
|
const EventBrandingContext = createContext<EventBrandingContextValue | undefined>(undefined);
|
||||||
|
|
||||||
@@ -62,7 +67,8 @@ function resolveBranding(input?: EventBranding | null): EventBranding {
|
|||||||
|
|
||||||
const headingFont = input.typography?.heading ?? input.fontFamily ?? null;
|
const headingFont = input.typography?.heading ?? input.fontFamily ?? null;
|
||||||
const bodyFont = input.typography?.body ?? input.fontFamily ?? null;
|
const bodyFont = input.typography?.body ?? input.fontFamily ?? null;
|
||||||
const sizePreset = input.typography?.sizePreset ?? 'm';
|
const rawSize = input.typography?.sizePreset ?? 'm';
|
||||||
|
const sizePreset = rawSize === 's' || rawSize === 'm' || rawSize === 'l' ? rawSize : 'm';
|
||||||
|
|
||||||
const logoMode = input.logo?.mode ?? (input.logoUrl ? 'upload' : 'emoticon');
|
const logoMode = input.logo?.mode ?? (input.logoUrl ? 'upload' : 'emoticon');
|
||||||
const logoValue = input.logo?.value ?? input.logoUrl ?? null;
|
const logoValue = input.logo?.value ?? input.logoUrl ?? null;
|
||||||
@@ -116,6 +122,7 @@ function applyCssVariables(branding: EventBranding) {
|
|||||||
root.style.setProperty('--guest-radius', `${branding.buttons?.radius ?? 12}px`);
|
root.style.setProperty('--guest-radius', `${branding.buttons?.radius ?? 12}px`);
|
||||||
root.style.setProperty('--guest-link', branding.buttons?.linkColor ?? branding.secondaryColor);
|
root.style.setProperty('--guest-link', branding.buttons?.linkColor ?? branding.secondaryColor);
|
||||||
root.style.setProperty('--guest-button-style', branding.buttons?.style ?? 'filled');
|
root.style.setProperty('--guest-button-style', branding.buttons?.style ?? 'filled');
|
||||||
|
root.style.setProperty('--guest-font-scale', String(FONT_SCALE_MAP[branding.typography?.sizePreset ?? 'm'] ?? 1));
|
||||||
|
|
||||||
const headingFont = branding.typography?.heading ?? branding.fontFamily;
|
const headingFont = branding.typography?.heading ?? branding.fontFamily;
|
||||||
const bodyFont = branding.typography?.body ?? branding.fontFamily;
|
const bodyFont = branding.typography?.body ?? branding.fontFamily;
|
||||||
@@ -149,6 +156,7 @@ function resetCssVariables() {
|
|||||||
root.style.removeProperty('--guest-radius');
|
root.style.removeProperty('--guest-radius');
|
||||||
root.style.removeProperty('--guest-link');
|
root.style.removeProperty('--guest-link');
|
||||||
root.style.removeProperty('--guest-button-style');
|
root.style.removeProperty('--guest-button-style');
|
||||||
|
root.style.removeProperty('--guest-font-scale');
|
||||||
root.style.removeProperty('--guest-font-family');
|
root.style.removeProperty('--guest-font-family');
|
||||||
root.style.removeProperty('--guest-body-font');
|
root.style.removeProperty('--guest-body-font');
|
||||||
root.style.removeProperty('--guest-heading-font');
|
root.style.removeProperty('--guest-heading-font');
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ const sampleBranding: EventBranding = {
|
|||||||
backgroundColor: '#fef2f2',
|
backgroundColor: '#fef2f2',
|
||||||
fontFamily: 'Montserrat, sans-serif',
|
fontFamily: 'Montserrat, sans-serif',
|
||||||
logoUrl: null,
|
logoUrl: null,
|
||||||
|
typography: {
|
||||||
|
heading: null,
|
||||||
|
body: null,
|
||||||
|
sizePreset: 'l',
|
||||||
|
},
|
||||||
mode: 'dark',
|
mode: 'dark',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -17,6 +22,7 @@ describe('EventBrandingProvider', () => {
|
|||||||
document.documentElement.classList.remove('guest-theme', 'dark');
|
document.documentElement.classList.remove('guest-theme', 'dark');
|
||||||
document.documentElement.style.removeProperty('color-scheme');
|
document.documentElement.style.removeProperty('color-scheme');
|
||||||
document.documentElement.style.removeProperty('--guest-background');
|
document.documentElement.style.removeProperty('--guest-background');
|
||||||
|
document.documentElement.style.removeProperty('--guest-font-scale');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('applies guest theme classes and variables', async () => {
|
it('applies guest theme classes and variables', async () => {
|
||||||
@@ -31,6 +37,7 @@ describe('EventBrandingProvider', () => {
|
|||||||
expect(document.documentElement.classList.contains('dark')).toBe(true);
|
expect(document.documentElement.classList.contains('dark')).toBe(true);
|
||||||
expect(document.documentElement.style.colorScheme).toBe('dark');
|
expect(document.documentElement.style.colorScheme).toBe('dark');
|
||||||
expect(document.documentElement.style.getPropertyValue('--guest-background')).toBe(sampleBranding.backgroundColor);
|
expect(document.documentElement.style.getPropertyValue('--guest-background')).toBe(sampleBranding.backgroundColor);
|
||||||
|
expect(document.documentElement.style.getPropertyValue('--guest-font-scale')).toBe('1.08');
|
||||||
});
|
});
|
||||||
|
|
||||||
unmount();
|
unmount();
|
||||||
|
|||||||
@@ -232,6 +232,48 @@ class EventControllerTest extends TenantTestCase
|
|||||||
$this->assertSame('blur_last', data_get($settings, 'live_show.background_mode'));
|
$this->assertSame('blur_last', data_get($settings, 'live_show.background_mode'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_update_event_uploads_branding_logo_data_url(): void
|
||||||
|
{
|
||||||
|
Storage::fake('public');
|
||||||
|
|
||||||
|
$eventType = EventType::factory()->create();
|
||||||
|
$event = Event::factory()->for($this->tenant)->create([
|
||||||
|
'event_type_id' => $eventType->id,
|
||||||
|
'name' => 'Branding Event',
|
||||||
|
'slug' => 'branding-event',
|
||||||
|
'date' => now()->addDays(5),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$logoFile = UploadedFile::fake()->image('logo.png', 64, 64);
|
||||||
|
$logoContents = file_get_contents($logoFile->getRealPath());
|
||||||
|
$this->assertIsString($logoContents);
|
||||||
|
$logoDataUrl = 'data:image/png;base64,'.base64_encode($logoContents);
|
||||||
|
|
||||||
|
$response = $this->authenticatedRequest('PUT', "/api/v1/tenant/events/{$event->slug}", [
|
||||||
|
'name' => 'Branding Event',
|
||||||
|
'event_date' => now()->addDays(5)->toDateString(),
|
||||||
|
'event_type_id' => $eventType->id,
|
||||||
|
'settings' => [
|
||||||
|
'branding' => [
|
||||||
|
'logo_data_url' => $logoDataUrl,
|
||||||
|
'logo' => [
|
||||||
|
'mode' => 'upload',
|
||||||
|
'value' => $logoDataUrl,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
|
||||||
|
$event->refresh();
|
||||||
|
$logoPath = (string) data_get($event->settings, 'branding.logo_url');
|
||||||
|
$this->assertNotEmpty($logoPath);
|
||||||
|
Storage::disk('public')->assertExists($logoPath);
|
||||||
|
$this->assertSame($logoPath, data_get($event->settings, 'branding.logo.value'));
|
||||||
|
$this->assertNull(data_get($event->settings, 'branding.logo_data_url'));
|
||||||
|
}
|
||||||
|
|
||||||
public function test_upload_exceeds_package_limit_fails(): void
|
public function test_upload_exceeds_package_limit_fails(): void
|
||||||
{
|
{
|
||||||
$tenant = $this->tenant;
|
$tenant = $this->tenant;
|
||||||
|
|||||||
Reference in New Issue
Block a user