Update guest v2 branding and theming
This commit is contained in:
@@ -131,6 +131,10 @@ function resolveThemeVariant(
|
||||
? 'dark'
|
||||
: null;
|
||||
|
||||
if (appearanceOverride) {
|
||||
return appearanceOverride;
|
||||
}
|
||||
|
||||
if (mode === 'dark') {
|
||||
return 'dark';
|
||||
}
|
||||
@@ -139,10 +143,6 @@ function resolveThemeVariant(
|
||||
return 'light';
|
||||
}
|
||||
|
||||
if (appearanceOverride) {
|
||||
return appearanceOverride;
|
||||
}
|
||||
|
||||
if (backgroundPrefers) {
|
||||
return backgroundPrefers;
|
||||
}
|
||||
|
||||
@@ -70,4 +70,27 @@ describe('EventBrandingProvider', () => {
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('prefers explicit appearance over branding mode', async () => {
|
||||
localStorage.setItem('theme', 'light');
|
||||
const darkBranding: EventBranding = {
|
||||
...sampleBranding,
|
||||
mode: 'dark',
|
||||
backgroundColor: '#0f172a',
|
||||
};
|
||||
|
||||
const { unmount } = render(
|
||||
<AppearanceProvider>
|
||||
<EventBrandingProvider branding={darkBranding}>
|
||||
<div>Guest</div>
|
||||
</EventBrandingProvider>
|
||||
</AppearanceProvider>
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(false);
|
||||
});
|
||||
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -561,6 +561,10 @@ export const messages: Record<LocaleCode, NestedMessages> = {
|
||||
flash: 'Blitz',
|
||||
upload: 'Upload',
|
||||
},
|
||||
toast: {
|
||||
queued: 'Offline – in der Warteschlange gespeichert.',
|
||||
uploaded: 'Upload abgeschlossen.',
|
||||
},
|
||||
queue: {
|
||||
summary: '{waiting} wartend, {sending} sendend',
|
||||
uploading: 'Upload {name} · {progress}%',
|
||||
@@ -1461,6 +1465,10 @@ export const messages: Record<LocaleCode, NestedMessages> = {
|
||||
flash: 'Flash',
|
||||
upload: 'Upload',
|
||||
},
|
||||
toast: {
|
||||
queued: 'Offline — added to upload queue.',
|
||||
uploaded: 'Upload complete.',
|
||||
},
|
||||
queue: {
|
||||
summary: '{waiting} waiting, {sending} sending',
|
||||
uploading: 'Uploading {name} · {progress}%',
|
||||
|
||||
33
resources/js/guest/services/__tests__/photosApi.test.ts
Normal file
33
resources/js/guest/services/__tests__/photosApi.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createPhotoShareLink } from '../photosApi';
|
||||
|
||||
const fetchMock = vi.fn();
|
||||
|
||||
describe('photosApi', () => {
|
||||
beforeEach(() => {
|
||||
fetchMock.mockReset();
|
||||
global.fetch = fetchMock as unknown as typeof fetch;
|
||||
document.head.innerHTML = '<meta name="csrf-token" content="csrf-token-demo" />';
|
||||
localStorage.setItem('device-id', 'device-123');
|
||||
});
|
||||
|
||||
it('creates a share link with CSRF headers', async () => {
|
||||
fetchMock.mockResolvedValueOnce(
|
||||
new Response(JSON.stringify({ slug: 'demo', url: 'http://example.com/share/demo' }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
);
|
||||
|
||||
const payload = await createPhotoShareLink('token', 123);
|
||||
|
||||
expect(payload.url).toBe('http://example.com/share/demo');
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
const [, options] = fetchMock.mock.calls[0];
|
||||
const headers = options?.headers as Record<string, string>;
|
||||
expect(headers['X-CSRF-TOKEN']).toBe('csrf-token-demo');
|
||||
expect(headers['X-XSRF-TOKEN']).toBe('csrf-token-demo');
|
||||
expect(headers['X-Device-Id']).toBe('device-123');
|
||||
});
|
||||
});
|
||||
@@ -1,18 +1,7 @@
|
||||
import type { LocaleCode } from '../i18n/messages';
|
||||
import type { EventBrandingPayload } from './eventApi';
|
||||
|
||||
export interface GalleryBranding {
|
||||
primary_color: string;
|
||||
secondary_color: string;
|
||||
background_color: string;
|
||||
surface_color?: string;
|
||||
mode?: 'light' | 'dark' | 'auto';
|
||||
palette?: {
|
||||
primary?: string | null;
|
||||
secondary?: string | null;
|
||||
background?: string | null;
|
||||
surface?: string | null;
|
||||
} | null;
|
||||
}
|
||||
export type GalleryBranding = EventBrandingPayload;
|
||||
|
||||
export interface GalleryMetaResponse {
|
||||
event: {
|
||||
|
||||
@@ -174,7 +174,7 @@ export async function uploadPhoto(
|
||||
}
|
||||
|
||||
export async function createPhotoShareLink(eventToken: string, photoId: number): Promise<{ slug: string; url: string; expires_at?: string }> {
|
||||
const headers = getCsrfHeaders();
|
||||
const headers = buildCsrfHeaders();
|
||||
|
||||
const res = await fetch(`/api/v1/events/${encodeURIComponent(eventToken)}/photos/${photoId}/share`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user