-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4463c9
commit 9c41d87
Showing
3 changed files
with
84 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,89 @@ | ||
import { | ||
Links, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
ScrollRestoration, | ||
isRouteErrorResponse, | ||
Links, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
ScrollRestoration, | ||
useRouteError, | ||
} from "@remix-run/react"; | ||
import { ChakraProvider } from "@chakra-ui/react"; | ||
import { ChakraProvider, Text, VStack } from "@chakra-ui/react"; | ||
import { FullPage } from "./components/FullPage"; | ||
|
||
export function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<noscript> | ||
<style> | ||
{`.scriptonly { display: none !important; }`} | ||
</style> | ||
</noscript> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
{children} | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
function MyLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<noscript> | ||
<style> | ||
{`.scriptonly { display: none !important; }`} | ||
</style> | ||
</noscript> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
{children} | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<ChakraProvider> | ||
<Outlet /> | ||
</ChakraProvider> | ||
) | ||
return ( | ||
<MyLayout> | ||
<ChakraProvider> | ||
<Outlet /> | ||
</ChakraProvider> | ||
</MyLayout> | ||
) | ||
} | ||
|
||
function ErrorDisplay({ error }: { error: unknown }) { | ||
if (isRouteErrorResponse(error)) { | ||
return ( | ||
<VStack> | ||
<img | ||
alt="Error icon" | ||
src="/images/error.svg" | ||
style={{ width: "5rem", height: "5rem" }} | ||
/> | ||
<Text>{error.status} {error.statusText}</Text> | ||
<Text>{error.data}</Text> | ||
</VStack> | ||
); | ||
} else if (error instanceof Error) { | ||
return ( | ||
<VStack> | ||
<img | ||
alt="Error icon" | ||
src="/images/error.svg" | ||
style={{ width: "5rem", height: "5rem" }} | ||
/> | ||
<Text>{error.message}</Text> | ||
<pre style={{"display":"none"}}>{error.stack}</pre> | ||
</VStack> | ||
); | ||
} else { | ||
return <h1>Unknown Error</h1>; | ||
} | ||
} | ||
|
||
export function ErrorBoundary() { | ||
const error = useRouteError(); | ||
console.error(error); | ||
return ( | ||
<MyLayout> | ||
<ChakraProvider> | ||
<FullPage> | ||
<ErrorDisplay error={error} /> | ||
</FullPage> | ||
</ChakraProvider> | ||
</MyLayout> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters