Skip to content

Commit 3ec08ac

Browse files
authored
Merge pull request #159 from UW-Macrostrat/info-panel
Location details
2 parents 206b563 + 92a51a2 commit 3ec08ac

34 files changed

+290
-773
lines changed

packages/data-components/src/field-locations/rockd-checkins/checkins.stories.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,27 @@ WithImage.args = {
306306
result: [checkinWithImage],
307307
mapRef: null,
308308
setInspectPosition: () => {},
309-
rockdAPIUrl: "https://dev.rockd.org/api/v2",
309+
rockdCheckinURL: "https://dev.rockd.org/checkin",
310+
rockdImageURL: "https://dev.rockd.org/api/v2/protected/image",
311+
rockdProfilePicURL: "https://dev.rockd.org/api/v2/protected/gravatar",
310312
};
311313

312314
export const WithoutImage = Template.bind({});
313315
WithoutImage.args = {
314316
result: [checkinWithoutImage],
315317
mapRef: null,
316318
setInspectPosition: () => {},
317-
rockdAPIUrl: "https://dev.rockd.org/api/v2",
319+
rockdCheckinURL: "https://dev.rockd.org",
320+
rockdImageURL: "https://dev.rockd.org/api/v2/protected/image",
321+
rockdProfilePicURL: "https://dev.rockd.org/api/v2/protected/gravatar",
318322
};
319323

320324
export const Multiple = Template.bind({});
321325
Multiple.args = {
322326
result: [checkinWithImage, checkinWithoutImage],
323327
mapRef: null,
324328
setInspectPosition: () => {},
325-
rockdAPIUrl: "https://dev.rockd.org/api/v2",
329+
rockdCheckinURL: "https://dev.rockd.org",
330+
rockdImageURL: "https://dev.rockd.org/api/v2/protected/image",
331+
rockdProfilePicURL: "https://dev.rockd.org/api/v2/protected/gravatar",
326332
};

packages/data-components/src/field-locations/rockd-checkins/index.ts

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,34 @@ export interface CheckinProps {
5252
}>;
5353
mapRef?: React.RefObject<mapboxgl.Map>;
5454
setInspectPosition?: (position: { lat: number; lng: number }) => void;
55-
rockdAPIUrl: string;
55+
rockdCheckinURL: string;
56+
rockdImageURL: string;
57+
rockdProfilePicURL: string;
5658
}
5759

5860
export function RockdWebsiteCheckinList(props: CheckinProps) {
5961
/** Checkin list component used in the Rockd website */
60-
const { result, mapRef, setInspectPosition, rockdAPIUrl } = props;
61-
const isDarkMode = useDarkMode().isEnabled;
62-
let checkins = [];
62+
const {
63+
result,
64+
mapRef,
65+
setInspectPosition,
66+
rockdCheckinURL,
67+
rockdImageURL,
68+
rockdProfilePicURL,
69+
} = props;
6370
const map = mapRef?.current;
6471
const len = result.length;
65-
const color = isDarkMode ? "white" : "black";
6672

6773
return h(
6874
result.map((checkin) => {
6975
// format rating
7076
let ratingArr = [];
7177
for (var i = 0; i < checkin.rating; i++) {
72-
ratingArr.push(
73-
h(Icon, { className: "star", icon: "star", style: { color } }),
74-
);
78+
ratingArr.push(h(Icon, { className: "star", icon: "star" }));
7579
}
7680

7781
for (var i = 0; i < 5 - checkin.rating; i++) {
78-
ratingArr.push(
79-
h(Icon, { className: "star", icon: "star-empty", style: { color } }),
80-
);
82+
ratingArr.push(h(Icon, { className: "star", icon: "star-empty" }));
8183
}
8284

8385
let imageView = null;
@@ -86,7 +88,7 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
8688
const imgSrc = getImageUrl(
8789
checkin.person_id,
8890
checkin.photo,
89-
rockdAPIUrl,
91+
rockdImageURL,
9092
);
9193
imageView = h([
9294
h("img.observation-img", {
@@ -98,7 +100,6 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
98100
h(Icon, {
99101
className: "details-image",
100102
icon: "arrow-right",
101-
style: { color },
102103
}),
103104
]),
104105
]);
@@ -108,7 +109,6 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
108109
h(Icon, {
109110
className: "details-image",
110111
icon: "arrow-right",
111-
style: { color },
112112
}),
113113
]);
114114
}
@@ -159,7 +159,10 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
159159
"h3.profile-pic",
160160

161161
h("img.profile-pic", {
162-
src: getProfilePicUrl(checkin.person_id, rockdAPIUrl),
162+
src: getProfilePicUrl(
163+
checkin.person_id,
164+
rockdProfilePicURL,
165+
),
163166
}),
164167
)
165168
: null,
@@ -182,35 +185,30 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
182185
"a",
183186
{
184187
className: "checkin-link",
185-
href: "/checkin/" + checkin.checkin_id,
188+
href: rockdCheckinURL + "/" + checkin.checkin_id,
186189
target: "_blank",
187190
},
188191
imageView,
189192
),
190193
h("div", { className: "checkin-footer" }, [
191194
h("div", { className: "likes-container" }, [
192195
h(Icon, {
193-
className: "likes-icon " + (isDarkMode ? "icon-dark-mode" : ""),
196+
className: "likes-icon",
194197
icon: "thumbs-up",
195-
style: { color },
196198
}),
197199
h("h3", { className: "likes" }, checkin.likes),
198200
]),
199201
h("div", { className: "observations-container" }, [
200202
h(Icon, {
201-
className:
202-
"observations-icon " + (isDarkMode ? "icon-dark-mode" : ""),
203+
className: "observations-icon",
203204
icon: "camera",
204-
style: { color },
205205
}),
206206
h("h3", { className: "likes" }, checkin.observations.length),
207207
]),
208208
h("div", { className: "comments-container" }, [
209209
h(Icon, {
210-
className:
211-
"comments-icon " + (isDarkMode ? "icon-dark-mode" : ""),
210+
className: "comments-icon",
212211
icon: "comment",
213-
style: { color },
214212
}),
215213
h("h3", { className: "comments" }, checkin.comments),
216214
]),
@@ -221,12 +219,10 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
221219
);
222220
}
223221

224-
function getImageUrl(person_id, photo_id, rockdAPIUrl) {
225-
return (
226-
rockdAPIUrl + "/protected/image/" + person_id + "/thumb_large/" + photo_id
227-
);
222+
function getImageUrl(person_id, photo_id, rockdImageURL) {
223+
return rockdImageURL + "/" + person_id + "/thumb_large/" + photo_id;
228224
}
229225

230-
function getProfilePicUrl(person_id, rockdAPIUrl) {
231-
return rockdAPIUrl + "/protected/gravatar/" + person_id;
226+
function getProfilePicUrl(person_id, rockdProfilePicURL) {
227+
return rockdProfilePicURL + "/" + person_id;
232228
}

packages/map-interface/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.5.3] - 2025-07-31
8+
9+
Broke apart info panel into 5 components
10+
11+
- Regional Stratigraphy
12+
- Physiography
13+
- Macrostrat Linked Data
14+
- xDD Info
15+
- Fossils
16+
717
## [1.5.2] - 2025-07-23
818

919
Map panel supports fossils clicks now

packages/map-interface/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/map-interface",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"description": "Map interface for Macrostrat",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

packages/map-interface/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export * from "./helpers";
88
export * from "./utils";
99
export * from "./location-info";
1010
export * from "./expansion-panel";
11-
export * from "./map-panel";
11+
export * from "./location-details";
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { useAPIResult } from "@macrostrat/ui-components";
2+
3+
const apiV2Prefix = `https://dev.macrostrat.org/api/v2`;
4+
const gddDomain = `https://xdd.wisc.edu`;
5+
const paleobioDomain = `https://paleobiodb.org`;
6+
7+
export function fetchMapInfo(lng, lat, z) {
8+
return useAPIResult(`${apiV2Prefix}/mobile/map_query_v2`, {
9+
lng,
10+
lat,
11+
z,
12+
})?.success?.data;
13+
}
14+
15+
export function fetchColumnInfo(lng, lat) {
16+
return useAPIResult(`${apiV2Prefix}/columns`, {
17+
lat,
18+
lng,
19+
response: "long",
20+
})?.success?.data?.[0];
21+
}
22+
23+
export function fetchXddInfo(stratNames) {
24+
return useAPIResult(`${gddDomain}/api/v1/snippets`, {
25+
article_limit: 20,
26+
term: stratNames?.map((d) => d.rank_name).join(","),
27+
})?.success?.data;
28+
}
29+
30+
export function fetchFossilInfo(lng, lat) {
31+
const collectionResponse = useAPIResult(
32+
`${paleobioDomain}/data1.2/colls/list.json?lngmin=${lng - 0.1}&lngmax=${lng + 0.1}&latmin=${lat - 0.1}&latmax=${lat + 0.1}`,
33+
)?.records;
34+
35+
const occurrences = useAPIResult(
36+
`${paleobioDomain}/data1.2/occs/list.json?lngmin=${lng - 0.1}&lngmax=${lng + 0.1}&latmin=${lat - 0.1}&latmax=${lat + 0.1}`,
37+
)?.records;
38+
39+
if (!collectionResponse || !occurrences) {
40+
return null;
41+
}
42+
43+
try {
44+
return collectionResponse.map((col) => {
45+
col.occurrences = [];
46+
occurrences.forEach((occ) => {
47+
if (occ.cid === col.oid) {
48+
col.occurrences.push(occ);
49+
}
50+
});
51+
return col;
52+
});
53+
} catch (error) {
54+
console.log(error);
55+
return [];
56+
}
57+
}

packages/map-interface/src/map-panel/components/info-drawer/fossil-collections/collections.tsx renamed to packages/map-interface/src/location-details/fossil-collections/collections.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { Tabs, Tab } from "@blueprintjs/core";
3-
import { makeOccurrenceTree } from "../../../utils";
3+
import { makeOccurrenceTree } from "../utils";
44
import hyper from "@macrostrat/hyper";
55
import styles from "./main.module.sass";
66
const h = hyper.styled(styles);
@@ -14,7 +14,6 @@ export default function PBDBCollections({ data }) {
1414
}
1515

1616
function FossilCollection({ col }) {
17-
console.log("FossilCollection", col);
1817
let occurrenceTree = makeOccurrenceTree(col.occurrences);
1918
return h(
2019
"div.fossil-collection",

packages/map-interface/src/map-panel/components/info-drawer/fossil-collections/index.ts renamed to packages/map-interface/src/location-details/fossil-collections/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ExpansionPanel } from "@macrostrat/map-interface";
33
import PBDBCollections from "./collections";
44

55
export function FossilCollections(props) {
6-
const { data, expanded } = props;
6+
const { data, expanded = false } = props;
77

88
if (!data || data.length <= 0) {
99
return null;

packages/map-interface/src/map-panel/components/info-drawer/fossil-collections/main.module.sass renamed to packages/map-interface/src/location-details/fossil-collections/main.module.sass

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from "./fossil-collections";
2+
export * from "./xdd-panel";
3+
export * from "./reg-strat";
4+
export * from "./physiography";
5+
export * from "./macrostrat-linked";

0 commit comments

Comments
 (0)