mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
6818a82cd1
* feat: add dark mode theme * fix: feature metrics * fix: add color * styling * fix: add switch * fix: form sidebar * fix: remove console log * fix: add properties * fix: strategy container * feat: feature flag * fix: tests * fix: build * fix: logo * fix: icon * fix: update snapshots * fix: CES operator * fix: typography * fix: input styling * fix: remove initial load * fix: change flag name * fix: refactor to custom hook * fix: remove unused import * fix: dialog headers * fix: use uiConfig flags instead of flags
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import { 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;
|