Fixed build
This commit is contained in:
parent
14421c875c
commit
0c4d43b891
|
@ -1,111 +0,0 @@
|
||||||
import { atomWithStorage } from "jotai/utils";
|
|
||||||
import { atom } from "jotai";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import { useLayoutEffect, useEffect } from "react";
|
|
||||||
import { atomPairing, useAtomGetter, useAtomPair } from "helpers/atoms";
|
|
||||||
import { getDefaultPreferredLanguages } from "helpers/locales";
|
|
||||||
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
|
||||||
import { usePrefersDarkMode } from "hooks/useMediaQuery";
|
|
||||||
import { SettingsPopup } from "components/Panels/SettingsPopup";
|
|
||||||
|
|
||||||
export enum ThemeMode {
|
|
||||||
Dark = "dark",
|
|
||||||
Auto = "auto",
|
|
||||||
Light = "light",
|
|
||||||
}
|
|
||||||
|
|
||||||
const preferredLanguagesAtom = atomPairing(atomWithStorage<string[]>("preferredLanguages", []));
|
|
||||||
const themeModeAtom = atomPairing(atomWithStorage<ThemeMode>("themeMode", ThemeMode.Auto));
|
|
||||||
const darkModeAtom = atomPairing(atom(false));
|
|
||||||
const fontSizeAtom = atomPairing(atomWithStorage("fontSize", 1));
|
|
||||||
const dyslexicAtom = atomPairing(atomWithStorage("isDyslexic", false));
|
|
||||||
const currencyAtom = atomPairing(atomWithStorage("currency", "USD"));
|
|
||||||
const playerNameAtom = atomPairing(atomWithStorage("playerName", ""));
|
|
||||||
|
|
||||||
export const settings = {
|
|
||||||
preferredLanguages: preferredLanguagesAtom,
|
|
||||||
themeMode: themeModeAtom,
|
|
||||||
darkMode: darkModeAtom,
|
|
||||||
fontSize: fontSizeAtom,
|
|
||||||
dyslexic: dyslexicAtom,
|
|
||||||
currency: currencyAtom,
|
|
||||||
playerName: playerNameAtom,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const UserSettingsProvider = ({ children }: { children: React.ReactNode }): JSX.Element => {
|
|
||||||
const router = useRouter();
|
|
||||||
const [preferredLanguages, setPreferredLanguages] = useAtomPair(settings.preferredLanguages);
|
|
||||||
const fontSize = useAtomGetter(settings.fontSize);
|
|
||||||
const isDyslexic = useAtomGetter(settings.dyslexic);
|
|
||||||
const [isDarkMode, setDarkMode] = useAtomPair(settings.darkMode);
|
|
||||||
const themeMode = useAtomGetter(settings.themeMode);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const html = document.getElementsByTagName("html")[0];
|
|
||||||
if (isDefined(html)) {
|
|
||||||
html.style.fontSize = `${fontSize * 100}%`;
|
|
||||||
}
|
|
||||||
}, [fontSize]);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const next = document.getElementById("__next");
|
|
||||||
if (isDefined(next)) {
|
|
||||||
if (isDyslexic) {
|
|
||||||
next.classList.add("set-theme-font-dyslexic");
|
|
||||||
next.classList.remove("set-theme-font-standard");
|
|
||||||
} else {
|
|
||||||
next.classList.add("set-theme-font-standard");
|
|
||||||
next.classList.remove("set-theme-font-dyslexic");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [isDyslexic]);
|
|
||||||
|
|
||||||
/* DARK MODE */
|
|
||||||
const prefersDarkMode = usePrefersDarkMode();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setDarkMode(themeMode === ThemeMode.Auto ? prefersDarkMode : themeMode === ThemeMode.Dark);
|
|
||||||
}, [prefersDarkMode, setDarkMode, themeMode]);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const next = document.getElementById("__next");
|
|
||||||
if (isDefined(next)) {
|
|
||||||
if (isDarkMode) {
|
|
||||||
next.classList.add("set-theme-dark");
|
|
||||||
next.classList.remove("set-theme-light");
|
|
||||||
} else {
|
|
||||||
next.classList.add("set-theme-light");
|
|
||||||
next.classList.remove("set-theme-dark");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [isDarkMode]);
|
|
||||||
|
|
||||||
/* PREFERRED LANGUAGES */
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (preferredLanguages.length === 0) {
|
|
||||||
if (isDefinedAndNotEmpty(router.locale) && router.locales) {
|
|
||||||
setPreferredLanguages(getDefaultPreferredLanguages(router.locale, router.locales));
|
|
||||||
}
|
|
||||||
} else if (router.locale !== preferredLanguages[0]) {
|
|
||||||
/*
|
|
||||||
* Using a timeout to the code getting stuck into a loop when reaching the website with a
|
|
||||||
* different preferredLanguages[0] from router.locale
|
|
||||||
*/
|
|
||||||
setTimeout(
|
|
||||||
async () =>
|
|
||||||
router.replace(router.asPath, router.asPath, {
|
|
||||||
locale: preferredLanguages[0],
|
|
||||||
}),
|
|
||||||
250
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [preferredLanguages, router, setPreferredLanguages]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<SettingsPopup />
|
|
||||||
{children}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -60,7 +60,7 @@ export const lightBox = atomPairing(
|
||||||
const previousLines = atomPairing(atom<string[]>([]));
|
const previousLines = atomPairing(atom<string[]>([]));
|
||||||
const previousCommands = atomPairing(atom<string[]>([]));
|
const previousCommands = atomPairing(atom<string[]>([]));
|
||||||
|
|
||||||
export const terminal = {
|
const terminal = {
|
||||||
previousLines,
|
previousLines,
|
||||||
previousCommands,
|
previousCommands,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { atomWithStorage } from "jotai/utils";
|
|
||||||
import { atom } from "jotai";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import { useLayoutEffect, useEffect } from "react";
|
|
||||||
import { atomPairing, useAtomGetter, useAtomPair } from "helpers/atoms";
|
|
||||||
import { getDefaultPreferredLanguages } from "helpers/locales";
|
|
||||||
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
|
||||||
import { usePrefersDarkMode } from "hooks/useMediaQuery";
|
|
||||||
import { SettingsPopup } from "components/Panels/SettingsPopup";
|
|
||||||
|
|
||||||
export enum ThemeMode {
|
|
||||||
Dark = "dark",
|
|
||||||
Auto = "auto",
|
|
||||||
Light = "light",
|
|
||||||
}
|
|
||||||
|
|
||||||
const preferredLanguagesAtom = atomPairing(atomWithStorage<string[]>("preferredLanguages", []));
|
|
||||||
const themeModeAtom = atomPairing(atomWithStorage<ThemeMode>("themeMode", ThemeMode.Auto));
|
|
||||||
const darkModeAtom = atomPairing(atom(false));
|
|
||||||
const fontSizeAtom = atomPairing(atomWithStorage("fontSize", 1));
|
|
||||||
const dyslexicAtom = atomPairing(atomWithStorage("isDyslexic", false));
|
|
||||||
const currencyAtom = atomPairing(atomWithStorage("currency", "USD"));
|
|
||||||
const playerNameAtom = atomPairing(atomWithStorage("playerName", ""));
|
|
||||||
|
|
||||||
export const settings = {
|
|
||||||
preferredLanguages: preferredLanguagesAtom,
|
|
||||||
themeMode: themeModeAtom,
|
|
||||||
darkMode: darkModeAtom,
|
|
||||||
fontSize: fontSizeAtom,
|
|
||||||
dyslexic: dyslexicAtom,
|
|
||||||
currency: currencyAtom,
|
|
||||||
playerName: playerNameAtom,
|
|
||||||
};
|
|
|
@ -49,7 +49,6 @@ const Channel = ({ channel, ...otherProps }: Props): JSX.Element => {
|
||||||
const hoverable = useDeviceSupportsHover();
|
const hoverable = useDeviceSupportsHover();
|
||||||
const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl);
|
const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl);
|
||||||
|
|
||||||
|
|
||||||
const [searchName, setSearchName] = useState(DEFAULT_FILTERS_STATE.searchName);
|
const [searchName, setSearchName] = useState(DEFAULT_FILTERS_STATE.searchName);
|
||||||
|
|
||||||
const subPanel = useMemo(
|
const subPanel = useMemo(
|
||||||
|
|
|
@ -53,7 +53,6 @@ const Contents = ({ contents, ...otherProps }: Props): JSX.Element => {
|
||||||
const langui = useAtomGetter(atoms.localData.langui);
|
const langui = useAtomGetter(atoms.localData.langui);
|
||||||
const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl);
|
const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl);
|
||||||
|
|
||||||
|
|
||||||
const [groupingMethod, setGroupingMethod] = useState<number>(
|
const [groupingMethod, setGroupingMethod] = useState<number>(
|
||||||
DEFAULT_FILTERS_STATE.groupingMethod
|
DEFAULT_FILTERS_STATE.groupingMethod
|
||||||
);
|
);
|
||||||
|
|
|
@ -37,7 +37,6 @@ const ContentsFolder = ({ openGraph, folder, ...otherProps }: Props): JSX.Elemen
|
||||||
const langui = useAtomGetter(atoms.localData.langui);
|
const langui = useAtomGetter(atoms.localData.langui);
|
||||||
const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl);
|
const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl);
|
||||||
|
|
||||||
|
|
||||||
const subPanel = useMemo(
|
const subPanel = useMemo(
|
||||||
() => (
|
() => (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
|
|
@ -45,12 +45,6 @@ export interface ChronicleWithTranslations extends Omit<Chronicle, "translations
|
||||||
|
|
||||||
// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
|
// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
|
||||||
|
|
||||||
export type RequiredNonNullable<T> = {
|
|
||||||
[P in keyof T]-?: NonNullable<T[P]>;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
|
|
||||||
|
|
||||||
export enum LibraryItemUserStatus {
|
export enum LibraryItemUserStatus {
|
||||||
None = 0,
|
None = 0,
|
||||||
Want = 1,
|
Want = 1,
|
||||||
|
|
Loading…
Reference in New Issue