Skip to content

Commit 3bd9957

Browse files
committed
Made map page column slightly nicer
1 parent 9ef7a6a commit 3bd9957

File tree

8 files changed

+120
-39
lines changed

8 files changed

+120
-39
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"@react-hook/size": "^2.1.2",
8484
"@supabase/postgrest-js": "^1.18.1",
8585
"@turf/bbox": "^6.5.0",
86+
"@turf/boolean-contains": "^7.2.0",
8687
"@turf/centroid": "^7.0.0",
8788
"@turf/distance": "^7.0.0",
8889
"@types/compression": "^1.7.2",

pages/+Layout.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export default function Layout({ children }: { children: ReactNode }) {
1717
const pageContext = usePageContext();
1818
const { exports = {}, config, user } = pageContext;
1919
const pageStyle = exports?.pageStyle ?? "fullscreen";
20-
21-
const devTools = exports.devTools ?? [];
20+
// const devTools = exports.devTools ?? [];
2221

2322
return h(
2423
AuthProvider,

pages/columns/@column/column-inspector/modal-panel.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { Button, ButtonGroup } from "@blueprintjs/core";
2-
import {
3-
UnitDetailsPanel,
4-
useSelectedUnit,
5-
useUnitSelectionDispatch,
6-
} from "@macrostrat/column-views";
7-
import { JSONView, ModalPanel, useKeyHandler } from "@macrostrat/ui-components";
1+
import { Button } from "@blueprintjs/core";
2+
import { UnitDetailsPanel } from "@macrostrat/column-views";
3+
import { useKeyHandler } from "@macrostrat/ui-components";
84
import h from "@macrostrat/hyper";
95

106
export function ModalUnitPanel(props) {
11-
const { unitData, className, selectedUnit, onSelectUnit } = props;
7+
const { unitData, className, selectedUnit, onSelectUnit, features } = props;
128

139
const ix = unitData?.findIndex(
1410
(unit) => unit.unit_id === selectedUnit?.unit_id
@@ -59,5 +55,6 @@ export function ModalUnitPanel(props) {
5955
showLithologyProportions: true,
6056
onSelectUnit,
6157
columnUnits: unitData,
58+
features,
6259
});
6360
}

pages/map/map-interface/components/info-drawer/strat-column/index.ts

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import { hyperStyled } from "@macrostrat/hyper";
2-
import { preprocessUnits, Column } from "@macrostrat/column-views";
2+
import {
3+
Column,
4+
ColoredUnitComponent,
5+
UnitDetailsFeature,
6+
} from "@macrostrat/column-views";
37

48
import styles from "./strat-column.module.styl";
59
import { ColumnSummary } from "#/map/map-interface/app-state/handlers/columns";
610
import { NonIdealState } from "@blueprintjs/core";
711
import useBreadcrumbs from "use-react-router-breadcrumbs";
812
import { LinkButton } from "../../buttons";
9-
import { InfoPanelSection } from "@macrostrat/map-interface";
13+
import { ExpansionPanel, InfoPanelSection } from "@macrostrat/map-interface";
1014
import { PatternProvider } from "~/_providers";
11-
import { useMemo } from "react";
15+
import { useMemo, useState } from "react";
16+
import { ModalUnitPanel } from "#/columns/@column/column-inspector/modal-panel";
1217

1318
const h = hyperStyled(styles);
1419

@@ -21,13 +26,19 @@ function BackButton() {
2126

2227
function ColumnOverlay({ columnInfo }: { columnInfo: ColumnSummary | null }) {
2328
const units = columnInfo?.units;
29+
30+
const [selectedUnitID, setSelectedUnitID] = useState<number>(null);
31+
32+
const selectedUnit = useMemo(() => {
33+
if (selectedUnitID == null || units == null) return null;
34+
return units.find((d) => d.unit_id == selectedUnitID);
35+
}, [selectedUnitID]);
36+
2437
if (units == null)
2538
return h(NonIdealState, { title: "No column available", icon: "error" }, [
2639
h("p", "A stratigraphic column has not been assigned for this location."),
2740
]);
2841

29-
const unitsA = useMemo(() => preprocessUnits(units), []);
30-
3142
const headerElement = h([
3243
h("div.controls", [h(BackButton)]),
3344
h("h4", columnInfo.col_name),
@@ -39,20 +50,33 @@ function ColumnOverlay({ columnInfo }: { columnInfo: ColumnSummary | null }) {
3950
),
4051
]);
4152

42-
return h(
43-
InfoPanelSection,
44-
{ className: "strat-column-panel", headerElement },
45-
h("div.strat-column-container", [
46-
h(Column, {
47-
data: unitsA,
48-
showLabels: true,
49-
targetUnitHeight: 25,
50-
unconformityLabels: true,
51-
width: 280,
52-
columnWidth: 180,
53-
}),
54-
])
55-
);
53+
return h([
54+
h(InfoPanelSection, { className: "strat-column-panel", headerElement }, [
55+
h("div.strat-column-container", [
56+
h(Column, {
57+
units,
58+
unitComponent: ColoredUnitComponent,
59+
showLabelColumn: false,
60+
targetUnitHeight: 25,
61+
unconformityLabels: true,
62+
width: 280,
63+
columnWidth: 240,
64+
selectedUnit: selectedUnitID,
65+
onUnitSelected: setSelectedUnitID,
66+
}),
67+
]),
68+
]),
69+
h(ModalUnitPanel, {
70+
unitData: units,
71+
className: "unit-details-panel",
72+
selectedUnit,
73+
onSelectUnit: setSelectedUnitID,
74+
features: new Set([
75+
UnitDetailsFeature.JSONToggle,
76+
UnitDetailsFeature.DepthRange,
77+
]),
78+
}),
79+
]);
5680
}
5781

5882
export function StratColumn(props) {
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
.strat-column-container
2-
min-height: 500px
32
padding: 0 1em 1em
43
--column-background-color: var(--panel-background-color)
54
--column-stroke-color: var(--text-color)
65
--column-note-color: var(--text-color)
76

8-
:global
9-
.timescale-container .timescale
10-
width: calc(6em + 6px)
11-
--timescale-level-size: 1.5em
12-
137
.strat-column-panel h3
148
text-overflow: ellipsis
15-
overflow: hidden
9+
overflow: hidden
10+
11+
.unit-details-panel
12+
position: sticky
13+
bottom: 0
14+
background-color: var(--panel-background-color)
15+
max-height: 40vh
16+
font-size: 0.9em
17+
min-height: 200px
18+

pages/map/map-interface/components/transitions/main.module.styl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ transitionable()
1515
transitionable()
1616

1717
.loading-area
18-
position: relative
1918
.spinner, .data
2019
transition: height 0.5s ease-in, opacity 0.2s ease-in
20+
2121
.spinner
2222
position absolute
2323
top 0
@@ -27,22 +27,28 @@ transitionable()
2727
min-height: 90px
2828
background-color: var(--panel-background-color)
2929
padding: 15px
30+
3031
&.enter
3132
.spinner
3233
height: 0
3334
opacity: 0
35+
3436
.data
3537
opacity: 1
38+
3639
&.from
3740
.spinner
3841
height: 90px
3942
opacity: 1
43+
4044
.data
4145
opacity: 0
46+
4247
&.leave
4348
.spinner
4449
height: 90px
4550
opacity: 1
51+
4652
.data
4753
opacity: 0
4854

pages/map/map-interface/map-page/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import {
1717
import Searchbar from "../components/navbar";
1818
import MapContainer from "./map-view";
1919
import { MenuPage } from "./menu";
20-
import h from "./main.module.styl";
2120
import { ErrorBoundary } from "@macrostrat/ui-components";
2221

22+
import h from "./main.module.styl";
23+
2324
const ElevationChart = loadable(() => import("../components/elevation-chart"));
2425
const InfoDrawer = loadable(() => import("../components/info-drawer"));
2526
const Menu = loadable(() => import("./menu"));

yarn.lock

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,6 +3465,7 @@ __metadata:
34653465
"@react-hook/size": "npm:^2.1.2"
34663466
"@supabase/postgrest-js": "npm:^1.18.1"
34673467
"@turf/bbox": "npm:^6.5.0"
3468+
"@turf/boolean-contains": "npm:^7.2.0"
34683469
"@turf/centroid": "npm:^7.0.0"
34693470
"@turf/distance": "npm:^7.0.0"
34703471
"@types/compression": "npm:^1.7.2"
@@ -4992,6 +4993,46 @@ __metadata:
49924993
languageName: node
49934994
linkType: hard
49944995

4996+
"@turf/boolean-contains@npm:^7.2.0":
4997+
version: 7.2.0
4998+
resolution: "@turf/boolean-contains@npm:7.2.0"
4999+
dependencies:
5000+
"@turf/bbox": "npm:^7.2.0"
5001+
"@turf/boolean-point-in-polygon": "npm:^7.2.0"
5002+
"@turf/boolean-point-on-line": "npm:^7.2.0"
5003+
"@turf/helpers": "npm:^7.2.0"
5004+
"@turf/invariant": "npm:^7.2.0"
5005+
"@types/geojson": "npm:^7946.0.10"
5006+
tslib: "npm:^2.8.1"
5007+
checksum: 10/1648a44269a4d5b185666ef87a9c05d742da1147dd51d48f942eecbd3d249401fec6d1337f4c6fd7e505b4fc2ab4c16f783e2a3d0b06a6a5ab865e6a0277124c
5008+
languageName: node
5009+
linkType: hard
5010+
5011+
"@turf/boolean-point-in-polygon@npm:^7.2.0":
5012+
version: 7.2.0
5013+
resolution: "@turf/boolean-point-in-polygon@npm:7.2.0"
5014+
dependencies:
5015+
"@turf/helpers": "npm:^7.2.0"
5016+
"@turf/invariant": "npm:^7.2.0"
5017+
"@types/geojson": "npm:^7946.0.10"
5018+
point-in-polygon-hao: "npm:^1.1.0"
5019+
tslib: "npm:^2.8.1"
5020+
checksum: 10/37624a62d88e7d8c39a37d774399e3a9322f8b544e708c5f6eb4ad34ed86f57c7ac1ef6fafcc66297eb77b44aa28cccb9c8c583bf317471d142c0fbefc4aeb9c
5021+
languageName: node
5022+
linkType: hard
5023+
5024+
"@turf/boolean-point-on-line@npm:^7.2.0":
5025+
version: 7.2.0
5026+
resolution: "@turf/boolean-point-on-line@npm:7.2.0"
5027+
dependencies:
5028+
"@turf/helpers": "npm:^7.2.0"
5029+
"@turf/invariant": "npm:^7.2.0"
5030+
"@types/geojson": "npm:^7946.0.10"
5031+
tslib: "npm:^2.8.1"
5032+
checksum: 10/1f9388b181fc4e02d0106a0fb17a19c397a257691e3fee533fac357eb7e4c07495cffb9a801fad90383e06fb105dc0f07f789e0423bc4c8f9026b243c3204548
5033+
languageName: node
5034+
linkType: hard
5035+
49955036
"@turf/buffer@npm:^7.2.0":
49965037
version: 7.2.0
49975038
resolution: "@turf/buffer@npm:7.2.0"
@@ -15154,6 +15195,15 @@ __metadata:
1515415195
languageName: node
1515515196
linkType: hard
1515615197

15198+
"point-in-polygon-hao@npm:^1.1.0":
15199+
version: 1.2.4
15200+
resolution: "point-in-polygon-hao@npm:1.2.4"
15201+
dependencies:
15202+
robust-predicates: "npm:^3.0.2"
15203+
checksum: 10/cba3e1cda20343056797afe18eafbde01da8e3ce5e76f8ae232b22ff502b27471fd55390b5d3cc20ef5e2021cb0a3a80d34c257c49abd0b5231f38f9c35de75e
15204+
languageName: node
15205+
linkType: hard
15206+
1515715207
"popper.js@npm:^1.14.4, popper.js@npm:^1.16.1":
1515815208
version: 1.16.1
1515915209
resolution: "popper.js@npm:1.16.1"
@@ -17046,7 +17096,7 @@ __metadata:
1704617096
languageName: node
1704717097
linkType: hard
1704817098

17049-
"robust-predicates@npm:^3.0.0":
17099+
"robust-predicates@npm:^3.0.0, robust-predicates@npm:^3.0.2":
1705017100
version: 3.0.2
1705117101
resolution: "robust-predicates@npm:3.0.2"
1705217102
checksum: 10/88bd7d45a6b89e88da2631d4c111aaaf0443de4d7078e9ab7f732245790a3645cf79bf91882a9740dbc959cf56ba75d5dced5bf2259410f8b6de19fd240cd08c

0 commit comments

Comments
 (0)