Skip to content

Commit e473727

Browse files
committed
Litholgies, strat names, and intervals clickable
1 parent c9fc7a8 commit e473727

File tree

4 files changed

+259
-44
lines changed

4 files changed

+259
-44
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@macrostrat-web/utility-functions": "workspace:*",
5555
"@macrostrat/color-utils": "^1.0.0",
5656
"@macrostrat/corelle": "^2.0.1",
57-
"@macrostrat/data-components": "latest",
57+
"@macrostrat/data-components": "^0.2.0",
5858
"@macrostrat/form-components": "^0.1.2",
5959
"@macrostrat/hyper": "^3.0.6",
6060
"@macrostrat/map-interface": "^1.2.2",

packages/settings/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { getRuntimeConfig } from "./utils";
33

44
export const rockdApiURL = getRuntimeConfig("ROCKD_API_URL");
5+
export const macrostratApiURL = getRuntimeConfig("MACROSTRAT_API_DOMAIN");
56
export const rockdApiOldURL = "https://rockd.org/api/v2/";
67

78
export const darkMapURL =

pages/checkin/index.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import 'mapbox-gl/dist/mapbox-gl.css';
44
import { BlankImage, Footer, getProfilePicUrl, getImageUrl, Comments } from "~/components/general";
55
import { Icon, Divider, H2 } from "@blueprintjs/core";
66
import h from "./main.module.sass";
7-
import { SETTINGS } from "@macrostrat-web/settings";
7+
import { rockdApiOldURL, SETTINGS } from "@macrostrat-web/settings";
88
import "@macrostrat/style-system";
99
import { Overlay2 } from "@blueprintjs/core";
1010
import { LithologyList } from "@macrostrat/data-components";
1111
import { ClientOnly } from "vike-react/ClientOnly";
12+
import { macrostratApiURL } from "@macrostrat-web/settings";
1213

1314
function Map(props) {
1415
return h(
@@ -172,22 +173,30 @@ function observationFooter(observation) {
172173
return `#${red}${green}${blue}`;
173174
}
174175

175-
let obsAge = observation.age_est ? observation.age_est.name + " (" + observation.age_est.b_age + " - " + observation?.age_est?.t_age + ")" : null;
176-
177176
let lithologies = [];
178177
rocks.liths?.forEach(lith => {
179178
if(!lith.color.includes("#")) {
180179
lithologies.push({
181-
name: lith.name,
182-
color: rgbaStringToHex(lith.color)});
180+
...lith,
181+
color: rgbaStringToHex(lith.color),
182+
});
183183
} else {
184184
lithologies.push(lith);
185185
}
186186
});
187187

188+
if(rocks.interval?.name) {
189+
lithologies.push({
190+
name: rocks.interval.name,
191+
int_id: rocks.interval.int_id,
192+
color: `rgba(${rocks.interval.color})`,
193+
})
194+
}
195+
188196
if (rocks.strat_name?.strat_name_long) {
189197
lithologies.push({
190198
name: rocks.strat_name?.strat_name_long,
199+
strat_id: rocks.strat_name?.strat_name_id
191200
})
192201
}
193202

@@ -197,16 +206,6 @@ function observationFooter(observation) {
197206
})
198207
}
199208

200-
if(obsAge) {
201-
lithologies.push({
202-
name: obsAge
203-
})
204-
}
205-
if(rocks.interval?.name) {
206-
lithologies.push({
207-
name: rocks.interval.name
208-
})
209-
}
210209
if(observation.orientation.feature?.name) {
211210
lithologies.push({
212211
name: observation.orientation.feature?.name
@@ -215,14 +214,26 @@ function observationFooter(observation) {
215214

216215
const show = lithologies.length > 0 || rocks?.notes?.length > 0 && observation.lat && rocks.strat_name?.strat_name_long;
217216

217+
const handleClick = (e, data) => {
218+
if (data.int_id) {
219+
window.open(macrostratApiURL + `/lex/intervals/${data.int_id}`, '_blank');
220+
}
221+
if (data.strat_id) {
222+
window.open(macrostratApiURL + `/lex/strat-names/${data.strat_id}`, '_blank');
223+
}
224+
if (data.lith_id) {
225+
window.open(macrostratApiURL + `/lex/lithology/${data.lith_id}`, '_blank');
226+
}
227+
};
228+
218229
// observation body
219230
return h.if(show)("div", {className: 'observation-body'}, [
220231
observation.lat && rocks.strat_name?.strat_name_long ? h('h4', {className: 'observation-header'}, [
221232
rocks.strat_name?.strat_name_long,
222233
observation.lat ? LngLatCoords(LngLatProps) : null,
223234
]) : null,
224235
h('div', {className: 'observation-details'}, [
225-
h(LithologyList, { lithologies }),
236+
h(LithologyList, { lithologies, onClickItem: handleClick }),
226237
h('p', {className: "notes"}, rocks.notes),
227238
]),
228239
]);

0 commit comments

Comments
 (0)