Skip to content

Commit 67528f3

Browse files
committed
Merge branch 'heatmap' into usage-stats
2 parents dbe101c + 2d6c7b6 commit 67528f3

File tree

1 file changed

+45
-56
lines changed

1 file changed

+45
-56
lines changed

pages/heatmap/+Page.client.ts

Lines changed: 45 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,41 @@ import { MapPosition } from "@macrostrat/mapbox-utils";
1010
import {
1111
MapAreaContainer,
1212
MapView,
13+
buildInspectorStyle
1314
} from "@macrostrat/map-interface";
14-
import { mapboxAccessToken, tileserverDomain } from "@macrostrat-web/settings";
15+
import { mapboxAccessToken, matomoToken, matomoApiURL, tileserverDomain } from "@macrostrat-web/settings";
1516
import { Footer } from "~/components/general";
16-
import { Tabs, Tab } from "@blueprintjs/core";
17+
import { Divider, Spinner, Tabs, Tab } from "@blueprintjs/core";
18+
import { useEffect, useState } from "react";
1719
import { mergeStyles } from "@macrostrat/mapbox-utils";
20+
import { useDarkMode } from "@macrostrat/ui-components";
21+
1822

1923
export function Page() {
2024
return h('div.main', [
2125
h('div.heatmap-page', [
2226
h(PageHeader),
23-
h(
24-
Tabs,
25-
{
26-
id: 'heatmap-tabs',
27-
},
28-
[
29-
h(Tab, { id: 'all', title: 'All', panelClassName: 'all-tab-panel', panel: h(Heatmap, { mapboxToken: mapboxAccessToken, today: false }) }),
30-
h(Tab, { id: 'today', title: 'Today', panelClassName: 'today-tab-panel', panel: h(Heatmap, { mapboxToken: mapboxAccessToken, today: true }) }),
31-
]
32-
)
27+
h(HeatMap)
3328
]),
3429
h(Footer)
3530
]);
3631
}
3732

38-
mapboxgl.accessToken = SETTINGS.mapboxAccessToken;
33+
function PageHeader() {
34+
return h('div.page-header', [
35+
h('h1', 'Heatmap'),
36+
h(Divider),
37+
h('p', 'This is a heatmap of all the locations where Rockd has been accessed.'),
38+
h('p', 'The blue markers indicate today\'s accesses, while the grey markers indicate accesses from other days.'),
39+
]);
40+
}
3941

4042
function todayStyle() {
4143
return {
4244
sources: {
4345
today: {
4446
type: "vector",
45-
tiles: [ tileserverDomain + "/usage-stats/rockd/{z}/{x}/{y}?date=today" ],
47+
tiles: [ tileserverDomain + "/usage-stats/rockd/{z}/{x}/{y}?today=true" ],
4648
}
4749
},
4850
layers: [
@@ -52,7 +54,7 @@ function todayStyle() {
5254
source: 'today',
5355
"source-layer": "default",
5456
paint: {
55-
'circle-color': "#6488ea",
57+
'circle-color': "#373ec4",
5658
'circle-radius': 4,
5759
}
5860
},
@@ -65,7 +67,7 @@ function allStyle() {
6567
sources: {
6668
all: {
6769
type: "vector",
68-
tiles: [ tileserverDomain + "/usage-stats/rockd/{z}/{x}/{y}" ],
70+
tiles: [ tileserverDomain + "/usage-stats/rockd/{z}/{x}/{y}"],
6971
}
7072
},
7173
layers: [
@@ -75,37 +77,53 @@ function allStyle() {
7577
source: 'all',
7678
"source-layer": "default",
7779
paint: {
78-
'circle-color': "#5e5e5e",
80+
'circle-color': "#838383",
7981
'circle-radius': 4,
8082
}
8183
},
8284
],
8385
};
8486
}
8587

86-
function Heatmap({
88+
89+
function HeatMap({
8790
mapboxToken,
88-
today,
8991
}: {
90-
mapboxToken: string;
91-
today: boolean;
92+
headerElement?: React.ReactElement;
93+
title?: string;
94+
children?: React.ReactNode;
95+
mapboxToken?: string;
9296
}) {
93-
const style = useMapStyle(mapboxToken, today);
9497

98+
const style = useMapStyle();
9599
if(style == null) return null;
96100

97-
const mapPosition: MapPosition = {
101+
const mapPosition = {
98102
camera: {
99103
lat: 39,
100104
lng: -98,
101105
altitude: 6000000,
102106
},
103107
};
104108

105-
return h(MapContainer, {style, mapPosition});
109+
return h(
110+
"div.map-container",
111+
[
112+
// The Map Area Container
113+
h(
114+
MapAreaContainer,
115+
{
116+
className: 'map-area-container',
117+
},
118+
[
119+
h(MapView, { style, mapboxToken: mapboxAccessToken, mapPosition }),
120+
]
121+
),
122+
]
123+
);
106124
}
107125

108-
function useMapStyle(mapboxToken, today) {
126+
function useMapStyle() {
109127
const dark = useDarkMode();
110128
const isEnabled = dark?.isEnabled;
111129

@@ -114,46 +132,17 @@ function useMapStyle(mapboxToken, today) {
114132
: "mapbox://styles/mapbox/light-v10";
115133

116134
const [actualStyle, setActualStyle] = useState(null);
117-
const overlayStyle = today ? todayStyle() : mergeStyles(allStyle(), todayStyle());
135+
const overlayStyle = mergeStyles(allStyle(), todayStyle());
118136

119137
// Auto select sample type
120138
useEffect(() => {
121139
buildInspectorStyle(baseStyle, overlayStyle, {
122-
mapboxToken,
140+
mapboxToken: mapboxAccessToken,
123141
inDarkMode: isEnabled,
124142
}).then((s) => {
125143
setActualStyle(s);
126144
});
127145
}, [isEnabled]);
128146

129147
return actualStyle;
130-
}
131-
132-
export function MapContainer({style, mapPosition}) {
133-
return h(
134-
"div.map-container",
135-
[
136-
// The Map Area Container
137-
h(
138-
MapAreaContainer,
139-
{
140-
className: "map-area-container",
141-
style: { "paddingLeft": "calc(30% + 14px)",},
142-
},
143-
[
144-
h(MapView, { style, mapboxToken: mapboxAccessToken, mapPosition }),
145-
]
146-
),
147-
]
148-
);
149-
}
150-
151-
152-
function PageHeader() {
153-
return h('div.page-header', [
154-
h('h1', 'Heatmap'),
155-
h(Divider),
156-
h('p', 'This is a heatmap of all the locations where Macrostrat has been accessed.'),
157-
h('p', 'The blue markers indicate today\'s accesses, while the grey markers indicate accesses from other days.'),
158-
]);
159148
}

0 commit comments

Comments
 (0)