Files
openchamber/packages/ui/src/contexts/theme-sync-payload.ts
T

15 lines
494 B
TypeScript
Raw Normal View History

2026-06-16 23:33:29 +03:00
import type { Theme } from '@/types/theme';
import { isValidTheme } from './theme-validation';
export type ThemeSyncPayloadShape = {
currentTheme?: unknown;
};
export const getSyncedThemeFromPayload = (payload: ThemeSyncPayloadShape): Theme | null => (
isValidTheme(payload.currentTheme) ? payload.currentTheme : null
);
export const getSyncedThemeVariant = (payload: ThemeSyncPayloadShape): 'light' | 'dark' | null => (
getSyncedThemeFromPayload(payload)?.metadata.variant ?? null
);