1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-10 01:19:53 +01:00
unleash.unleash/frontend/src/contexts/UIContext.ts
Christopher Kolstad 53354224fc
chore: Bump biome and configure husky (#6589)
Upgrades biome to 1.6.1, and updates husky pre-commit hook.

Most changes here are making type imports explicit.
2024-03-18 13:58:05 +01:00

48 lines
1.2 KiB
TypeScript

import React from 'react';
import type { IToast } from 'interfaces/toast';
interface IUIContext {
toastData: IToast;
setToast: React.Dispatch<React.SetStateAction<IToast>>;
showFeedback: boolean;
setShowFeedback: React.Dispatch<React.SetStateAction<boolean>>;
setThemeMode: React.Dispatch<React.SetStateAction<themeMode>>;
themeMode: themeMode;
}
export type themeMode = 'light' | 'dark';
export const createEmptyToast = (): IToast => {
return {
type: 'success',
title: '',
text: '',
components: [],
show: false,
persist: false,
};
};
const setToastPlaceholder = () => {
throw new Error('setToast called outside UIContext');
};
const setShowFeedbackPlaceholder = () => {
throw new Error('setShowFeedback called outside UIContext');
};
const setThemeModePlaceholder = () => {
throw new Error('setMode called outside UIContext');
};
const UIContext = React.createContext<IUIContext>({
toastData: createEmptyToast(),
setToast: setToastPlaceholder,
showFeedback: false,
setShowFeedback: setShowFeedbackPlaceholder,
themeMode: 'light',
setThemeMode: setThemeModePlaceholder,
});
export default UIContext;