rework of the event admin UI
This commit is contained in:
36
resources/js/admin/lib/branding.ts
Normal file
36
resources/js/admin/lib/branding.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { TenantEvent } from '../api';
|
||||
|
||||
export type BrandingPalette = {
|
||||
colors: string[];
|
||||
font?: string;
|
||||
};
|
||||
|
||||
export function extractBrandingPalette(settings: TenantEvent['settings'] | null | undefined): BrandingPalette {
|
||||
const colors: string[] = [];
|
||||
let font: string | undefined;
|
||||
|
||||
if (settings && typeof settings === 'object') {
|
||||
const brand = (settings as Record<string, unknown>).branding;
|
||||
if (brand && typeof brand === 'object') {
|
||||
const colorPalette = (brand as Record<string, unknown>).colors;
|
||||
if (colorPalette && typeof colorPalette === 'object') {
|
||||
const paletteRecord = colorPalette as Record<string, unknown>;
|
||||
for (const key of Object.keys(paletteRecord)) {
|
||||
const value = paletteRecord[key];
|
||||
if (typeof value === 'string' && value.trim().length) {
|
||||
colors.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
const fontValue = (brand as Record<string, unknown>).font_family;
|
||||
if (typeof fontValue === 'string' && fontValue.trim()) {
|
||||
font = fontValue.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
colors,
|
||||
font,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user