Skip to content

Commit

Permalink
Merge branch 'streamline-renderer'
Browse files Browse the repository at this point in the history
* streamline-renderer:
  Somewhat improved styles for hyperscript
  Change import prefix for page routes
  Hoisted pages directory
  Updated style merging to preserve atmosphere characteristics
  Updated pages
  Simplified renderer functions
  • Loading branch information
davenquinn committed Jul 21, 2024
2 parents b11c0df + 4d109ce commit 389a953
Show file tree
Hide file tree
Showing 402 changed files with 536 additions and 542 deletions.
2 changes: 1 addition & 1 deletion packages/globe-dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import hyper from "@macrostrat/hyper";
import { MapPosition } from "@macrostrat/mapbox-utils";
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Link } from "~/components/navigation/link-component";
import { Link } from "~/components/navigation/Link";
import CesiumView from "./cesium-view";

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/sift/src/js/components/Column.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import h from "@macrostrat/hyper";
import React from "react";
import { useParams } from "react-router-dom";
import { Link as VikeLink } from "~/components/navigation/link-component";
import { Link as VikeLink } from "~/components/navigation/Link";
import Chart from "./Chart";
import Footer from "./Footer";
import { SiftLink } from "./Link";
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/Head.ts → pages/+Head.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import h from "@macrostrat/hyper";
import { usePageContext } from "vike-react/usePageContext";
import favicon from "./assets/favicon.png";
import favicon from "~/_assets/favicon.png";

export default function Head() {
const ctx = usePageContext();
const { environment } = ctx;
const { scripts = [] } = ctx.exports;
const { scripts = [] } = ctx.config;

return h([
h("meta", {
Expand Down
14 changes: 7 additions & 7 deletions src/renderer/Layout.ts → pages/+Layout.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { DarkModeProvider } from "@macrostrat/ui-components";
import React from "react";
import { ReactNode } from "react";

import { AuthProvider } from "../_providers/auth";
import { AuthProvider } from "~/_providers/auth";
import { usePageContext } from "vike-react/usePageContext";

import "~/styles/blueprint-core";
import "../styles/_theme.styl";
import "../styles/core.sass";
import "../styles/padding.css";
import "~/styles/_theme.styl";
import "~/styles/core.sass";
import "~/styles/padding.css";
//
import h from "./layout.module.sass";

export default function Layout({ children }: { children: React.ReactNode }) {
export default function Layout({ children }: { children: ReactNode }) {
const pageContext = usePageContext();
const { exports = {}, config, user } = pageContext;
const supportsDarkMode = config?.supportsDarkMode ?? true;
const supportsDarkMode = true;
const pageStyle = exports?.pageStyle ?? "fullscreen";

return h(
Expand Down
File renamed without changes.
10 changes: 2 additions & 8 deletions src/pages/+config.ts → pages/+config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
import vikeReact from "vike-react/config";
import type { Config } from "vike/types";

const Layout = "import:../renderer/Layout.ts:default";
const Head = "import:../renderer/Head.ts:default";

// import Head from "../renderer/Head.js";

// Default config (can be overridden by pages)
export default {
Layout,
Head,
// <title>
title: "Macrostrat",
description:
"A platform for geological data exploration, integration, and analysis.",
Expand All @@ -26,8 +18,10 @@ export default {
"title",
"environment",
"urlPathname",
"scripts",
],
clientRouting: true,
supportsDarkMode: true,
meta: {
supportsDarkMode: {
env: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FocusStyleManager } from "@blueprintjs/core";
import { updatePageMeta } from "~/renderer/page-meta";
import { updatePageMeta } from "~/renderer/updatePageMeta";

export function onBeforeRenderClient(pageContext) {
// Adjust title and description as needed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://vike.dev/onPageTransitionEnd
export { onPageTransitionEnd };
import { usePageTransitionStore } from "../renderer/transitions";
import { usePageTransitionStore } from "~/renderer/usePageTransitionStore";

function onPageTransitionEnd() {
document.querySelector("body").classList.remove("in-page-transition");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { onPageTransitionStart };
import { usePageTransitionStore } from "../renderer/transitions";
import { usePageTransitionStore } from "~/renderer/usePageTransitionStore";

async function onPageTransitionStart() {
// This function is called when a page transition starts.
Expand Down
5 changes: 3 additions & 2 deletions src/pages/+onRenderHtml.ts → pages/+onRenderHtml.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { onRenderHtml as _onRenderHtml } from "vike-react/renderer/onRenderHtml";
import { updatePageMeta } from "~/renderer/page-meta";
import { updatePageMeta } from "~/renderer/updatePageMeta";

// there is no onBeforeRenderHtml hook in vike-react, so we need to call updatePageMeta here
// there is no onBeforeRenderHtml hook in vike-react, so we need to call updatePageMeta here to rewrite titles etc.
// There might be a better way to handle this.

export function onRenderHtml(pageContext) {
return _onRenderHtml(updatePageMeta(pageContext));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/columns/+Page.ts → pages/columns/+Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import h from "@macrostrat/hyper";
import { ContentPage } from "~/layouts";
import { PageHeader, Link, AssistantLinks, DevLinkButton } from "~/components";
import { AnchorButton, Tag } from "@blueprintjs/core";
import { usePageProps } from "~/renderer";
import { usePageProps } from "~/renderer/usePageProps";

export function Page() {
const { columnGroups, title, linkPrefix } = usePageProps();
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ColumnPage from "./column-inspector";
import h from "@macrostrat/hyper";
import { usePageProps } from "~/renderer";
import { usePageProps } from "~/renderer/usePageProps";

export function Page() {
const props = usePageProps();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { apiV2Prefix } from "@macrostrat-web/settings";
import { preprocessUnits } from "@macrostrat/column-views/src/helpers";
import fetch from "node-fetch";

import { ColumnSummary } from "~/pages/map/map-interface/app-state/handlers/columns";
import { fetchAPIData } from "~/pages/columns/utils";
import { ColumnSummary } from "#/map/map-interface/app-state/handlers/columns";
import { fetchAPIData } from "#/columns/utils";

export async function onBeforeRender(pageContext) {
// `.page.server.js` files always run in Node.js; we could use SQL/ORM queries here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ModalUnitPanel from "./modal-panel";
import { BasePage } from "~/layouts";

import { navigate } from "vike/client/router";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";

const h = hyperStyled(styles);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FullscreenPage } from "~/layouts";
import h from "./main.module.sass";
import { compose, C } from "@macrostrat/hyper";
import { baseMapURL, mapboxAccessToken } from "@macrostrat-web/settings";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import { Feature, FeatureCollection, LineString, Point } from "geojson";
import { useEffect, useMemo } from "react";
import { setGeoJSON } from "@macrostrat/mapbox-utils";
Expand All @@ -27,7 +27,7 @@ import {
UnitSelectionProvider,
useSelectedUnit,
} from "@macrostrat/column-views";
import { UnitDescription } from "~/pages/columns/correlation/column";
import { UnitDescription } from "#/columns/correlation/column";

export function Page() {
const startup = useCorrelationDiagramStore((state) => state.startup);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
LegendPanelHeader,
UnitDetailsPopover,
} from "~/components/unit-details";
import { useCorrelationDiagramStore } from "~/pages/columns/correlation/state";
import { useCorrelationDiagramStore } from "#/columns/correlation/state";

export function MacrostratColumnProvider(props) {
// A column provider specialized the Macrostrat API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {
preprocessUnits,
useUnitSelectionDispatch,
} from "@macrostrat/column-views";
import { runColumnQuery } from "~/pages/map/map-interface/app-state/handlers/fetch";
import { runColumnQuery } from "#/map/map-interface/app-state/handlers/fetch";
import { Column, TimescaleColumn } from "./column";
import { UnitLong } from "@macrostrat/api-types";
import { GapBoundPackage, SectionRenderData, AgeComparable } from "./types";

import h from "./main.module.sass";
import { useCorrelationDiagramStore } from "~/pages/columns/correlation/state";
import { useCorrelationDiagramStore } from "#/columns/correlation/state";

export interface ColumnIdentifier {
col_id: number;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { LineString, Point } from "geojson";
import { create } from "zustand";
import { ColumnGeoJSONRecord } from "~/pages/map/map-interface/app-state/handlers/columns";
import { ColumnGeoJSONRecord } from "#/map/map-interface/app-state/handlers/columns";
// Turf intersection
import { fetchAllColumns } from "~/pages/map/map-interface/app-state/handlers/fetch";
import { fetchAllColumns } from "#/map/map-interface/app-state/handlers/fetch";
import {
getCorrelationHashParams,
setHashStringForCorrelation,
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/pages/dev/+Page.mdx → pages/dev/+Page.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { ContentPage as default } from "~/layouts";
import { PageHeader } from "~/components";
import { PageBreadcrumbs } from "~/renderer";
import { PageHeader, PageBreadcrumbs } from "~/components";

<PageHeader title="Development pages"></PageHeader>
<PageBreadcrumbs></PageBreadcrumbs>
Expand Down
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,5 +1,5 @@
export { ContentPage as default } from "~/layouts";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";

<PageBreadcrumbs></PageBreadcrumbs>

Expand Down
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.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/pages/dev/docs/+Page.ts → pages/dev/docs/+Page.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import h from "@macrostrat/hyper";
import { Link } from "~/components";
import { usePageContext } from "~/renderer/page-context";
import { usePageContext } from "vike-react/usePageContext";
import { ErrorBoundary } from "@macrostrat/ui-components";
import { ContentPage } from "~/layouts";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import { Popover, Tag } from "@blueprintjs/core";

export function Page() {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import h from "@macrostrat/hyper";

import { ContentPage } from "~/layouts";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import { FeedbackWrap } from "@macrostrat/feedback-components";

export function Page() {
Expand Down
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,5 +1,5 @@
import { PageHeader } from "~/components";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import "./main.styl";
import { Image } from "./index";
import { MacrostratIcon } from "~/components";
Expand Down
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.
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
Expand Up @@ -17,7 +17,7 @@ import {
FeatureSelectionHandler,
} from "@macrostrat/map-interface";
import { NonIdealState } from "@blueprintjs/core";
import { LinkItem } from "~/pages/map/dev/map-layers";
import { LinkItem } from "#/map/dev/map-layers";
import { Link } from "~/components";

export function Page() {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageHeader } from "~/components";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import { Image, Navbar, Footer } from "../index";
import "./main.styl";
import "../main.styl";
Expand All @@ -24,4 +24,4 @@ import { MacrostratIcon } from "~/components";
</div>

[//]: # "Footer"
<Footer></Footer>
<Footer></Footer>
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,5 +1,5 @@
import { PageHeader } from "~/components";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import { Image, Navbar, Footer } from "../index";
import "./main.styl";
import "../main.styl";
Expand Down Expand Up @@ -42,7 +42,7 @@ import { MacrostratIcon } from "~/components";
<a href="mailto: mazko@wisc.edu"><e>mazko -at wisc.edu</e></a>
</div>
</div>

<div class="person-info" id="michael">
<Image className="back-img" src="michael.jpg"></Image>
<div class="text">
Expand All @@ -56,31 +56,31 @@ import { MacrostratIcon } from "~/components";
<Image className="back-img" src="casey.jpg"></Image>
<div class="text">
<n><a href="https://idzikowski-casey.github.io/personal-site/" target="_blank">Casey Idzikowski</a></n> \
<t>Research Specialist, Developer (former)</t>
<t>Research Specialist, Developer (former)</t>
</div>
</div>

<div class="person-info" id="daniel">
<Image className="back-img" src="daniel.jpg"></Image>
<div class="text">
<n><a href="http://strata.geology.wisc.edu" target="_blank">Daniel Segessenmen</a></n> \
<t>Graduate Student (former)</t>
<t>Graduate Student (former)</t>
</div>
</div>

<div class="person-info" id="shan">
<Image className="back-img" src="shan.jpg"></Image>
<div class="text">
<n><a href="https://www.wisc.edu/directories/person.php?name=Victoria+Khoo&email=vkhoo%40wisc.edu&query=victoria%20khoo" target="_blank">Shan Ye</a></n> \
<t>Graduate Student (former)</t>
<t>Graduate Student (former)</t>
</div>
</div>

<div class="person-info" id="ben">
<Image className="back-img" src="ben.jpg"></Image>
<div class="text">
<n><a href="http://strata.geology.wisc.edu" target="_blank">Ben Linzmeier</a></n> \
<t>Postdoctoral Scholar (former)</t>
<t>Postdoctoral Scholar (former)</t>
</div>
</div>
</div>
Expand All @@ -90,15 +90,15 @@ import { MacrostratIcon } from "~/components";
<Image className="back-img" src="afiqah.jpg"></Image>
<div class="text">
<n><a href="https://www.wisc.edu/directories/person.php?name=Victoria+Khoo&email=vkhoo%40wisc.edu&query=victoria%20khoo" target="_blank">Afiqah Rafi</a></n> \
<t>Undergrad Student (former)</t>
<t>Undergrad Student (former)</t>
</div>
</div>

<div class="person-info" id="sharon">
<Image className="back-img" src="sharon.jpg"></Image>
<div class="text">
<n><a href="http://geoscience.wisc.edu/geoscience/people/student/?id=1007" target="_blank">Sharon McMullen</a></n> \
<t>Researcher (former)</t>
<t>Researcher (former)</t>
</div>
</div>

Expand All @@ -124,23 +124,23 @@ import { MacrostratIcon } from "~/components";
<Image className="back-img" src="erika.jpg"></Image>
<div class="text">
<n><a href="https://github.com/ItoErika" target="_blank">Erika Ito</a></n> \
<t>Research Intern (former)</t>
<t>Research Intern (former)</t>
</div>
</div>

<div class="person-info" id="noel">
<Image className="back-img" src="noel.jpg"></Image>
<div class="text">
<n><a href="http://sedpaleo.org" target="_blank">Noel Heim</a></n> \
<t>Researcher (former)</t>
<t>Researcher (former)</t>
</div>
</div>

<div class="person-info" id="john">
<Image className="back-img" src="john.jpg"></Image>
<div class="text">
<n><a href="http://www.johnjcz.com" target="_blank">John Czaplewski</a></n> \
<t>Next-level Developer (former)</t>
<t>Next-level Developer (former)</t>
</div>
</div>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageHeader } from "~/components";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";
import { Image, Navbar, Footer } from "../index";
import "./main.styl";
import "../main.styl";
Expand Down Expand Up @@ -97,4 +97,4 @@ import { MacrostratIcon } from "~/components";
[//]: # "Footer"
<Footer></Footer>

</div>
</div>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import h from "@macrostrat/hyper";
import { ContentPage } from "~/layouts";
import { PageBreadcrumbs } from "~/renderer";
import { PageBreadcrumbs } from "~/components";

export function Page() {
return h(ContentPage, [
Expand Down
Loading

0 comments on commit 389a953

Please sign in to comment.