Skip to content

Commit b41a854

Browse files
authored
Merge pull request #21 from UW-Macrostrat/separate-frontend-modules
Separate frontend modules
2 parents 516d197 + 445a6a3 commit b41a854

File tree

18 files changed

+150
-59
lines changed

18 files changed

+150
-59
lines changed

frontend/packages/corelle/src/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

frontend/packages/demo-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"prettier": {},
1919
"dependencies": {
2020
"@blueprintjs/core": "^5",
21-
"@macrostrat/corelle": "workspace:^",
21+
"@corelle/svg-map-layers": "workspace:^",
2222
"@macrostrat/hyper": "^3.0.6",
2323
"@macrostrat/svg-map-components": "^1.0.2",
2424
"@macrostrat/ui-components": "^4.1.0",

frontend/packages/demo-app/src/app.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState, useContext, useEffect, useCallback } from "react";
22
import { WorldMap } from "./world-map";
33
import ControlPanel from "./control-panel";
44
import h from "@macrostrat/hyper";
5-
import { RotationsProvider } from "@macrostrat/corelle";
5+
import { RotationsProvider } from "@corelle/svg-map-layers";
66
import { MapSettingsProvider } from "./map-settings";
77
import { Spinner } from "@blueprintjs/core";
88
import {
@@ -13,7 +13,7 @@ import {
1313
getQueryString,
1414
} from "@macrostrat/ui-components";
1515

16-
import "./app.styl"
16+
import "./app.styl";
1717

1818
const qs = getQueryString();
1919

@@ -31,16 +31,16 @@ function App(props) {
3131

3232
const setTime = useCallback(
3333
(time) => setState({ ...state, time }),
34-
[setState]
34+
[setState],
3535
);
3636
const setModel = useCallback(
3737
(model) => setState({ ...state, model }),
38-
[setState]
38+
[setState],
3939
);
4040

4141
const { baseURL } = useContext(APIContext);
4242
const models = useAPIResult<string[]>("/model", null, (data: any) =>
43-
data.map((d) => d.name)
43+
data.map((d) => d.name),
4444
);
4545
const featureDatasets = useAPIResult<string[]>("/feature");
4646

frontend/packages/demo-app/src/control-panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Alignment,
88
NumericInput,
99
} from "@blueprintjs/core";
10-
import { RotationsContext } from "@macrostrat/corelle";
10+
import { RotationsContext } from "@corelle/svg-map-layers";
1111
import * as styles from "./app.styl";
1212
import { MapSettingsContext } from "./map-settings";
1313

frontend/packages/demo-app/src/world-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import h from "@macrostrat/hyper";
22
import { useContext, useRef } from "react";
3+
import { Globe, MapContext } from "@macrostrat/svg-map-components";
34
import {
45
PlateFeatureLayer,
56
RotationsContext,
67
PlatePolygons,
78
PlateFeature,
8-
} from "@macrostrat/corelle";
9-
import { Globe, MapContext } from "@macrostrat/svg-map-components";
9+
} from "@corelle/svg-map-layers";
1010

1111
import { MapSettingsContext } from "./map-settings";
1212

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. The format
4+
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
5+
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.0.0] - 2024-02-15
8+
9+
Split off `@corelle/rotations` module from legacy `@macrostrat/corelle` package.
10+
The React components for creating an SVG map have been moved to the
11+
`@corelle/svg-map-layers` package.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@corelle/rotations",
3+
"version": "1.0.0",
4+
"description": "A client library for the Corelle plate-rotation API",
5+
"scripts": {
6+
"build": "rm -rf dist && parcel build",
7+
"prepare": "npm run build"
8+
},
9+
"author": "Daven Quinn",
10+
"license": "MIT",
11+
"module": "dist/esm/index.js",
12+
"main": "dist/cjs/index.js",
13+
"source": "src/index.ts",
14+
"types": "dist/esm/index.d.ts",
15+
"dependencies": {
16+
"@types/d3-geo": "^3.0",
17+
"d3-geo": "^3.1.1",
18+
"quaternion": "^2.0.2"
19+
},
20+
"peerDependencies": {
21+
"react": "^16.13.1||^17.0.0||^18.0.0||^19.0.0"
22+
},
23+
"exports": {
24+
".": {
25+
"source": "./src/index.ts",
26+
"import": "./dist/esm/index.js",
27+
"require": "./dist/cjs/index.js",
28+
"types": "./dist/esm/index.d.ts"
29+
}
30+
},
31+
"devDependencies": {
32+
"@babel/core": "^7.12.0",
33+
"parcel": "^2.13.3"
34+
}
35+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { geoTransform, geoPath, GeoProjection } from "d3-geo";
2+
3+
type RotateFunction = (coords: [number, number]) => [number, number];
4+
5+
export function pathGenerator(
6+
projection: GeoProjection,
7+
rotation: RotateFunction,
8+
canvasContext = null,
9+
) {
10+
/** Returns a composite of a geo projection and a rotation
11+
* Optionally, a canvas context can be provided to render to a canvas
12+
* */
13+
// Filter out features that are too young
14+
const trans = geoTransform({
15+
point(lon, lat) {
16+
const [x, y] = rotation([lon, lat]);
17+
return this.stream.point(x, y);
18+
},
19+
});
20+
21+
// This ordering makes no sense but whatever
22+
const stream = (s) =>
23+
// https://stackoverflow.com/questions/27557724/what-is-the-proper-way-to-use-d3s-projection-stream
24+
trans.stream(projection.stream(s));
25+
26+
return geoPath({ stream }, canvasContext);
27+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from "./rotations";
2+
export * from "./math";
3+
export * from "./geometry";

0 commit comments

Comments
 (0)