* Added Overview page * Revised Getting Started page * Minor revision * Edited readme, minor modifications to docs * Removed sweep.yaml, .devcontainer, .ergomake * Moved security.md to .github, added contributing.md * changes as per code review * updated contributing.md * fixed broken links & added missing links in doc, improved structure * fixed link in wsl setup * fixed server link, added https cloning in yarn-setup * removed package-lock.json * added doc card, admonitions * removed underline from nav buttons * refactoring modules/ui * refactoring modules/ui * Change folder case * Fix theme location * Fix case 2 * Fix storybook --------- Co-authored-by: Nimra Ahmed <nimra1408@gmail.com> Co-authored-by: Nimra Ahmed <50912134+nimraahmed@users.noreply.github.com>
41 lines
950 B
TypeScript
41 lines
950 B
TypeScript
import { atom, selector } from 'recoil';
|
|
|
|
import { SnackBarProps } from '../components/SnackBar';
|
|
|
|
export type SnackBarOptions = SnackBarProps & {
|
|
id: string;
|
|
};
|
|
|
|
type SnackBarState = {
|
|
maxQueue: number;
|
|
queue: SnackBarOptions[];
|
|
};
|
|
|
|
export const snackBarInternalState = atom<SnackBarState>({
|
|
key: 'snackBarState',
|
|
default: {
|
|
maxQueue: 3,
|
|
queue: [],
|
|
},
|
|
});
|
|
|
|
// TODO: use a recoil callback
|
|
export const snackBarSetQueueState = selector<SnackBarOptions | null>({
|
|
key: 'snackBarQueueState',
|
|
get: ({ get: _get }) => null, // We don't care about getting the value
|
|
set: ({ set }, newValue) =>
|
|
set(snackBarInternalState, (prev) => {
|
|
if (prev.queue.length >= prev.maxQueue) {
|
|
return {
|
|
...prev,
|
|
queue: [...prev.queue.slice(1), newValue] as SnackBarOptions[],
|
|
};
|
|
}
|
|
|
|
return {
|
|
...prev,
|
|
queue: [...prev.queue, newValue] as SnackBarOptions[],
|
|
};
|
|
}),
|
|
});
|