@xyd-js/apidocs-demo 0.0.0-build

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/root.tsx ADDED
@@ -0,0 +1,106 @@
1
+ import {
2
+ isRouteErrorResponse,
3
+ Links,
4
+ Meta,
5
+ Outlet,
6
+ Scripts,
7
+ ScrollRestoration,
8
+ } from "react-router";
9
+ import React, { } from 'react';
10
+
11
+ import { GlobalStateProvider } from './context';
12
+ import type { Route } from "./+types/root";
13
+ import { SETTINGS } from "./settings";
14
+
15
+ import gestaltCss from 'gestalt/dist/gestalt.css?url';
16
+ import poetryCss from '@xyd-js/theme-poetry/index.css?url';
17
+ import openerCss from '@xyd-js/theme-opener/index.css?url';
18
+ import cosmoCss from '@xyd-js/theme-cosmo/index.css?url';
19
+ import picassoCss from '@xyd-js/theme-picasso/index.css?url';
20
+ import gustoCss from '@xyd-js/theme-gusto/index.css?url';
21
+ import solarCss from '@xyd-js/theme-solar/index.css?url';
22
+
23
+ import indexCss from './index.css?url';
24
+
25
+ export const links: Route.LinksFunction = () => {
26
+ const links = [
27
+ { rel: "stylesheet", href: gestaltCss },
28
+ { rel: "stylesheet", href: indexCss },
29
+ ]
30
+
31
+ switch (SETTINGS?.theme?.name) {
32
+ case "poetry":
33
+ links.push({ rel: "stylesheet", href: poetryCss });
34
+ break;
35
+ case "opener":
36
+ links.push({ rel: "stylesheet", href: openerCss });
37
+ break;
38
+ case "cosmo":
39
+ links.push({ rel: "stylesheet", href: cosmoCss });
40
+ break;
41
+ case "picasso":
42
+ links.push({ rel: "stylesheet", href: picassoCss, "data-xyd-theme-default": "true" });
43
+ case "gusto":
44
+ links.push({ rel: "stylesheet", href: gustoCss });
45
+ break;
46
+ case "solar":
47
+ links.push({ rel: "stylesheet", href: solarCss });
48
+ break;
49
+ }
50
+
51
+ return links;
52
+ }
53
+
54
+ export function Layout({ children }: { children: React.ReactNode }) {
55
+ return (
56
+ <html lang="en">
57
+ <head>
58
+ <meta charSet="utf-8" />
59
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
60
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
61
+ <Meta />
62
+ <Links />
63
+ </head>
64
+ <body>
65
+ <GlobalStateProvider>
66
+ {children}
67
+ <ScrollRestoration />
68
+ <Scripts />
69
+ </GlobalStateProvider>
70
+ </body>
71
+ </html>
72
+ );
73
+ }
74
+
75
+ export default function App() {
76
+ return <Outlet />;
77
+ }
78
+
79
+ export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
80
+ let message = "Oops!";
81
+ let details = "An unexpected error occurred.";
82
+ let stack: string | undefined;
83
+
84
+ if (isRouteErrorResponse(error)) {
85
+ message = error.status === 404 ? "404" : "Error";
86
+ details =
87
+ error.status === 404
88
+ ? "The requested page could not be found."
89
+ : error.statusText || details;
90
+ } else if (import.meta.env.DEV && error && error instanceof Error) {
91
+ details = error.message;
92
+ stack = error.stack;
93
+ }
94
+
95
+ return (
96
+ <main className="pt-16 p-4 container mx-auto">
97
+ <h1>{message}</h1>
98
+ <p>{details}</p>
99
+ {stack && (
100
+ <pre className="w-full p-4 overflow-x-auto">
101
+ <code>{stack}</code>
102
+ </pre>
103
+ )}
104
+ </main>
105
+ );
106
+ }