session-desktop/ts/themes/switchPrimaryColor.tsx
William Grant e5bfda37af feat: primary color switching now persists
fixed isDarkMode, will need to confirm when we add ocean themes
2022-09-26 15:52:31 +10:00

14 lines
482 B
TypeScript

import { Dispatch } from 'redux';
import { applyPrimaryColor } from '../state/ducks/primaryColor';
import { COLORS, PrimaryColorStateType } from './colors';
export async function switchPrimaryColor(color: PrimaryColorStateType, dispatch: Dispatch | null) {
await window.Events.setPrimaryColorSetting(color);
document.documentElement.style.setProperty(
'--primary-color',
(COLORS.PRIMARY as any)[`${color.toUpperCase()}`]
);
dispatch?.(applyPrimaryColor(color));
}