Skip to content

Commit 5810582

Browse files
committed
use map component
1 parent e4cbafd commit 5810582

File tree

2 files changed

+143
-2
lines changed

2 files changed

+143
-2
lines changed

pages/columns/+Page.client.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { Divider, AnchorButton, Tag, Card, Collapse, Icon } from "@blueprintjs/c
44
import { useData } from "vike-react/useData";
55
import { useState } from "react";
66
import "./main.scss";
7-
import h from "@macrostrat/hyper";
7+
import { hyperStyled } from "@macrostrat/hyper";
8+
import styles from "./index.module.sass";
89
import {
910
MapAreaContainer,
1011
MapMarker,
@@ -14,7 +15,13 @@ import {
1415
import { SETTINGS } from "@macrostrat-web/settings";
1516
import mapboxgl, { LngLat } from "mapbox-gl";
1617
import { MapPosition } from "@macrostrat/mapbox-utils";
17-
import { useEffect } from "react";
18+
import { useEffect, useCallback } from "react";
19+
import { onDemand } from "~/_utils";
20+
import { navigate } from "vike/client/router";
21+
22+
const h = hyperStyled(styles);
23+
24+
const ColumnMap = onDemand(() => import("./map").then((mod) => mod.ColumnMap));
1825

1926
export function Page(props) {
2027
return h(ColumnListPage, props);
@@ -24,6 +31,7 @@ function ColumnListPage({ title = "Columns", linkPrefix = "/" }) {
2431
const { columnGroups } = useData();
2532
const [columnInput, setColumnInput] = useState("");
2633
const [mapInstance, setMapInstance] = useState<mapboxgl.Map | null>(null);
34+
const [selectedUnitID, setSelectedUnitID] = useState<number>(null);
2735

2836
const filteredGroups = columnGroups.filter((group) => {
2937
const name = group.name.toLowerCase();
@@ -32,6 +40,8 @@ function ColumnListPage({ title = "Columns", linkPrefix = "/" }) {
3240
return name.includes(input) || columns.some((col) => col.includes(input));
3341
});
3442

43+
/*
44+
3545
const mapPosition: MapPosition = {
3646
camera: {
3747
lat: 39,
@@ -127,18 +137,40 @@ function ColumnListPage({ title = "Columns", linkPrefix = "/" }) {
127137
const source = mapInstance.getSource("geojson-data") as mapboxgl.GeoJSONSource;
128138
if (source) source.setData(geojson);
129139
}, [filteredGroups, mapInstance]);
140+
*/
141+
130142

131143
const handleInputChange = (event) => {
132144
setColumnInput(event.target.value.toLowerCase());
133145
};
134146

147+
const onSelectColumn = useCallback(
148+
(col_id: number) => {
149+
// do nothing
150+
// We could probably find a more elegant way to do this
151+
setSelectedUnitID(null);
152+
navigate(linkPrefix + `columns/${col_id}`, {
153+
overwriteLastHistoryEntry: true,
154+
});
155+
},
156+
[setSelectedUnitID]
157+
);
158+
135159
return h("div.column-list-page", [
136160
h(AssistantLinks, [
137161
h(AnchorButton, { href: "/projects", minimal: true }, "Projects"),
138162
h(DevLinkButton, { href: "/columns/correlation" }, "Correlation chart"),
139163
]),
140164
h(ContentPage, [
141165
h(PageHeader, { title }),
166+
h(ColumnMap, {
167+
className: "column-map",
168+
inProcess: true,
169+
projectID: null,
170+
selectedColumn: null,
171+
onSelectColumn,
172+
}),
173+
/*
142174
h("div.map-section", [
143175
h("h2", "Map of Columns"),
144176
h("div.map-container",
@@ -152,6 +184,7 @@ function ColumnListPage({ title = "Columns", linkPrefix = "/" }) {
152184
)
153185
),
154186
]),
187+
*/
155188
h(Card, { className: "search-bar" }, [
156189
h(Icon, { icon: "search" }),
157190
h("input", {

pages/columns/index.module.sass

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
.page-container
2+
overflow-y: scroll
3+
height: 100vh
4+
position: relative
5+
6+
.main
7+
--column-background-color: var(--background-color)
8+
--column-stroke-color: var(--text-color)
9+
10+
display: flex
11+
flex-direction: row
12+
13+
max-width: 80rem
14+
margin: 0 auto
15+
16+
17+
.left-column
18+
flex-grow: 1
19+
20+
.right-column
21+
min-width: 200px
22+
width: 40%
23+
max-width: 500px
24+
height: 100vh
25+
position: sticky
26+
top: 0
27+
display: flex
28+
flex-direction: column
29+
padding: 2em 0
30+
31+
.right-column-boxes
32+
display: flex
33+
flex-direction: column
34+
gap: 2em
35+
36+
37+
.column-view
38+
margin: 0 4em 4em
39+
padding: 0
40+
41+
.column-header
42+
margin: 1em 4em
43+
44+
h1
45+
font-size: 1.5em
46+
47+
.subtitle
48+
font-weight: normal
49+
50+
nav
51+
position: sticky
52+
top: 2em
53+
54+
.column-nav
55+
position: sticky
56+
top: 2.2em
57+
58+
h3
59+
color: #444
60+
margin-bottom: 0.3em
61+
62+
.default-buttons
63+
width: 100%
64+
margin: 0 -10px
65+
66+
.column-map
67+
width: 100%
68+
aspect-ratio: 3/2
69+
cursor: pointer
70+
z-index: 100
71+
72+
&.expanded
73+
cursor: inherit
74+
75+
.columns path:hover
76+
stroke: rgba(255, 0, 0, .4) !important
77+
78+
79+
.close-button
80+
position: absolute
81+
top: 1em
82+
right: 1em
83+
84+
.land
85+
background-color: rgb(233, 252, 234)
86+
87+
div.section
88+
display: flex
89+
flex-direction: row
90+
91+
div.timescale
92+
width: 7em
93+
--timescale-level-size: 1.5em
94+
95+
96+
.section .divisions .unit
97+
cursor: pointer
98+
99+
rect.selection-overlay
100+
fill: rgba(255, 0, 0, .5)
101+
102+
.unit-details-panel
103+
flex: 1
104+
min-height: 0
105+
106+
.column-map, .unit-details-panel
107+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3)
108+
border-radius: 6px

0 commit comments

Comments
 (0)