Port Login UI

This commit is contained in:
Paul
2021-06-18 20:21:54 +01:00
parent aa81ebb298
commit 68a35751b3
18 changed files with 749 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import { isTouchscreenDevice } from "../lib/isTouchscreenDevice";
import { createGlobalStyle } from "styled-components";
import { Children } from "../types/Preact";
import { createContext } from "preact";
import { Helmet } from "react-helmet";
export type Variables =
@@ -111,6 +112,8 @@ const GlobalTheme = createGlobalStyle<{ theme: Theme }>`
}
`;
export const ThemeContext = createContext<Theme>({} as any);
interface Props {
children: Children;
}
@@ -119,7 +122,7 @@ export default function Theme(props: Props) {
const theme = PRESETS.dark;
return (
<>
<ThemeContext.Provider value={theme}>
<Helmet>
<meta
name="theme-color"
@@ -132,6 +135,6 @@ export default function Theme(props: Props) {
</Helmet>
<GlobalTheme theme={theme} />
{props.children}
</>
</ThemeContext.Provider>
);
}

View File

@@ -0,0 +1,18 @@
export function takeError(
error: any
): string {
const type = error?.response?.data?.type;
let id = type;
if (!type) {
if (error?.response?.status === 403) {
return "Unauthorized";
} else if (error && (!!error.isAxiosError && !error.response)) {
return "NetworkError";
}
console.error(error);
return "UnknownError";
}
return id;
}