Skip to content

Commit

Permalink
Merge pull request #121 from UW-Macrostrat/vike-redesign
Browse files Browse the repository at this point in the history
Vike redesign
  • Loading branch information
davenquinn authored Jan 21, 2024
2 parents 2a9e75e + 19af62d commit a241799
Show file tree
Hide file tree
Showing 29 changed files with 266 additions and 243 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"use-debounce": "^9.0.4",
"use-react-router-breadcrumbs": "^3.2.1",
"use-resize-observer": "^9.1.0",
"vike": "0.4.150-commit-63b1c32",
"vike": "^0.4.159",
"vite": "^4.4.9",
"vite-plugin-cesium": "^1.2.22"
},
Expand Down
13 changes: 13 additions & 0 deletions src/pages/+Page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import h from "@macrostrat/hyper";
import { Link } from "~/renderer/Link";

export function Page() {
return h([
h("h1", "Macrostrat dev"),
h("ul", [
h("li", h(Link, { href: "map" }, "Map")),
h("li", h(Link, { href: "maps" }, "Map index")),
h("li", h(Link, { href: "dev" }, "Dev layers")),
]),
]);
}
14 changes: 14 additions & 0 deletions src/pages/_error/+Page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export { Page };

import h from "@macrostrat/hyper";

function Page({ is404 }: { is404: boolean }) {
if (is404) {
return h([
h("h1", "404 Page Not Found"),
h("p", "This page could not be found."),
]);
} else {
return h([h("h1", "500 Internal Error"), h("p", "Something went wrong.")]);
}
}
6 changes: 0 additions & 6 deletions src/pages/about/code.css

This file was deleted.

14 changes: 0 additions & 14 deletions src/pages/about/index.page.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hyper from "@macrostrat/hyper";
import { Breadcrumbs, HotkeysProvider } from "@blueprintjs/core";
import hyper from "@macrostrat/hyper";
import { ClientOnly } from "~/renderer/client-only";
import style from "./main.module.sass";
import style from "../main.module.sass";

const h = hyper.styled(style);

Expand Down
20 changes: 0 additions & 20 deletions src/pages/index.page.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/renderer/+config.h.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Config } from "vike/types";

export default {
passToClient: ["pageProps", "urlPathname"],
} satisfies Config;
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export { render };
export { render as onRenderClient };

import { FocusStyleManager } from "@blueprintjs/core";
import h from "@macrostrat/hyper";
import { hydrateRoot } from "react-dom/client";
import { PageShell } from "./page-shell";
import type { PageContextClient } from "./types";
import { FocusStyleManager } from "@blueprintjs/core";

// This render() hook only supports SSR, see https://vike.dev/render-modes for how to modify render() to support SPA
async function render(pageContext: PageContextClient) {
Expand All @@ -18,12 +19,7 @@ async function render(pageContext: PageContextClient) {
console.log("Rendering on client");
const root = document.getElementById("app-container");
if (!root) throw new Error("DOM element #react-root not found");
hydrateRoot(
root,
<PageShell pageContext={pageContext}>
<Page {...pageProps} />
</PageShell>
);
hydrateRoot(root, h(PageShell, { pageContext }, h(Page, pageProps)));
}

/* To enable Client-side Routing:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { render };
export { render as onRenderHtml };
// See https://vike.dev/data-fetching
export const passToClient = ["pageProps", "urlPathname"];

import h from "@macrostrat/hyper";
import ReactDOMServer from "react-dom/server";
import { dangerouslySkipEscape, escapeInject } from "vike/server";
import { PageShell } from "./page-shell";
import { escapeInject, dangerouslySkipEscape } from "vike/server";
import type { PageContextServer } from "./types";

async function render(pageContext: PageContextServer) {
Expand All @@ -13,9 +13,7 @@ async function render(pageContext: PageContextServer) {
if (!Page)
throw new Error("render() hook expects pageContext.Page to be defined");
const pageHtml = ReactDOMServer.renderToString(
<PageShell pageContext={pageContext}>
<Page {...pageProps} />
</PageShell>
h(PageShell, { pageContext }, h(Page, pageProps))
);

// See https://vike.dev/head
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/Link.tsx → src/renderer/Link.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import h from "@macrostrat/hyper";
import { usePageContext } from "./page-context";

export function Link(props: {
Expand All @@ -12,5 +13,5 @@ export function Link(props: {
]
.filter(Boolean)
.join(" ");
return <a {...props} className={className} />;
return h("a", { ...props, className });
}
19 changes: 0 additions & 19 deletions src/renderer/_error.page.tsx

This file was deleted.

Loading

0 comments on commit a241799

Please sign in to comment.