mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
Webatrice: update deps (#4700)
* save work * fix reset styling * fix toast reducer * update non-react deps * update react libraries * remove jquery, use sanitize-html instead * add missing change * fix deps and dev deps * update workflow to target Node 16 * run @mui/codemod to remove @mui/styles * add default body font size * update react 17 to 18 * declare enum before use * add rel attr to links * fix font sizing issue * trailing commas * refactor deep destructuring Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
5854a635ca
commit
26d7fe2ff0
17 changed files with 26225 additions and 3552 deletions
|
|
@ -6,41 +6,54 @@ export const ACTIONS = {
|
|||
}
|
||||
|
||||
export const initialState = {
|
||||
toasts: new Map()
|
||||
toasts: {}
|
||||
}
|
||||
|
||||
export function reducer(state, action) {
|
||||
const { type, payload } = action
|
||||
export function reducer(state, { type, payload }) {
|
||||
const { key, children } = payload;
|
||||
|
||||
switch (type) {
|
||||
case ACTIONS.ADD_TOAST: {
|
||||
const newState = { ...state }
|
||||
newState.toasts = new Map(Array.from(state.toasts))
|
||||
const { toasts } = newState;
|
||||
const { key, children } = payload
|
||||
toasts.set(key, { isOpen: false, children })
|
||||
return newState
|
||||
return {
|
||||
...state,
|
||||
toasts: {
|
||||
...state.toasts,
|
||||
[key]: {
|
||||
isOpen: false,
|
||||
children,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ACTIONS.OPEN_TOAST: {
|
||||
const newState = { ...state }
|
||||
newState.toasts = new Map(Array.from(state.toasts))
|
||||
const { toasts } = newState;
|
||||
const toast = toasts.get(payload)
|
||||
toasts.set(payload, { isOpen: true, children: toast.children })
|
||||
return newState
|
||||
return {
|
||||
...state,
|
||||
toasts: {
|
||||
...state.toasts,
|
||||
[key]: {
|
||||
...state.toasts[key],
|
||||
isOpen: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ACTIONS.CLOSE_TOAST: {
|
||||
const newState = { ...state }
|
||||
newState.toasts = new Map(Array.from(state.toasts))
|
||||
const { toasts } = newState;
|
||||
const toast = toasts.get(payload)
|
||||
toasts.set(payload, { isOpen: false, children: toast.children })
|
||||
return newState
|
||||
return {
|
||||
...state,
|
||||
toasts: {
|
||||
...state.toasts,
|
||||
[key]: {
|
||||
...state.toasts[key],
|
||||
isOpen: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ACTIONS.REMOVE_TOAST: {
|
||||
const newState = { ...state }
|
||||
newState.toasts = new Map(Array.from(state.toasts))
|
||||
newState.toasts.delete(payload)
|
||||
return newState
|
||||
const newState = { ...state };
|
||||
delete newState.toasts[key];
|
||||
|
||||
return newState;
|
||||
}
|
||||
default:
|
||||
throw Error('Please pick an available action')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue