@@ -14,7 +14,9 @@ import {
1414import { mapboxAccessToken } from "@macrostrat-web/settings" ;
1515import { Footer } from "~/components/general" ;
1616import { Tabs , Tab } from "@blueprintjs/core" ;
17+ import { mergeStyles } from "@macrostrat/mapbox-utils" ;
1718
19+ const tileServer = 'http://localhost:5500' ;
1820
1921export function Page ( ) {
2022 return h ( 'div.main' , [
@@ -26,7 +28,8 @@ export function Page() {
2628 id : 'heatmap-tabs' ,
2729 } ,
2830 [
29- h ( Tab , { id : 'all' , title : 'All' , panelClassName : 'all-tab-panel' , panel : h ( UsageMap , { mapboxToken : mapboxAccessToken } ) } ) ,
31+ h ( Tab , { id : 'all' , title : 'All' , panelClassName : 'all-tab-panel' , panel : h ( Heatmap , { mapboxToken : mapboxAccessToken , today : false } ) } ) ,
32+ h ( Tab , { id : 'today' , title : 'Today' , panelClassName : 'today-tab-panel' , panel : h ( Heatmap , { mapboxToken : mapboxAccessToken , today : true } ) } ) ,
3033 ]
3134 )
3235 ] ) ,
@@ -36,40 +39,60 @@ export function Page() {
3639
3740mapboxgl . accessToken = SETTINGS . mapboxAccessToken ;
3841
39- function weaverStyle ( ) {
42+ function todayStyle ( ) {
4043 return {
4144 sources : {
42- usage : {
45+ today : {
4346 type : "vector" ,
44- tiles : [ "http://localhost:5500/ stats-tile/{z}/{x}/{y}?cluster=false" ] ,
47+ tiles : [ tileServer + "/ stats-tile/{z}/{x}/{y}?date=today" ] ,
4548 }
4649 } ,
4750 layers : [
4851 {
49- id : 'unclustered-point ' ,
52+ id : 'today-points ' ,
5053 type : 'circle' ,
51- source : 'usage ' ,
54+ source : 'today ' ,
5255 "source-layer" : "default" ,
5356 paint : {
54- 'circle-color' : "#00f " ,
57+ 'circle-color' : "#6488ea " ,
5558 'circle-radius' : 4 ,
56- 'circle-stroke-width' : 1 ,
57- 'circle-stroke-color' : '#fff'
5859 }
5960 } ,
6061 ] ,
6162 } ;
6263}
6364
64- function UsageMap ( {
65+ function allStyle ( ) {
66+ return {
67+ sources : {
68+ all : {
69+ type : "vector" ,
70+ tiles : [ tileServer + "/stats-tile/{z}/{x}/{y}" ] ,
71+ }
72+ } ,
73+ layers : [
74+ {
75+ id : 'all-points' ,
76+ type : 'circle' ,
77+ source : 'all' ,
78+ "source-layer" : "default" ,
79+ paint : {
80+ 'circle-color' : "#5e5e5e" ,
81+ 'circle-radius' : 4 ,
82+ }
83+ } ,
84+ ] ,
85+ } ;
86+ }
87+
88+ function Heatmap ( {
6589 mapboxToken,
90+ today,
6691} : {
67- headerElement ?: React . ReactElement ;
68- title ?: string ;
69- children ?: React . ReactNode ;
70- mapboxToken ?: string ;
92+ mapboxToken : string ;
93+ today : boolean ;
7194} ) {
72- const style = useMapStyle ( mapboxToken ) ;
95+ const style = useMapStyle ( mapboxToken , today ) ;
7396
7497 if ( style == null ) return null ;
7598
@@ -84,7 +107,7 @@ function UsageMap({
84107 return h ( MapContainer , { style, mapPosition} ) ;
85108}
86109
87- function useMapStyle ( mapboxToken ) {
110+ function useMapStyle ( mapboxToken , today ) {
88111 const dark = useDarkMode ( ) ;
89112 const isEnabled = dark ?. isEnabled ;
90113
@@ -93,7 +116,7 @@ function useMapStyle(mapboxToken) {
93116 : "mapbox://styles/mapbox/light-v10" ;
94117
95118 const [ actualStyle , setActualStyle ] = useState ( null ) ;
96- const overlayStyle = weaverStyle ( ) ;
119+ const overlayStyle = today ? todayStyle ( ) : mergeStyles ( allStyle ( ) , todayStyle ( ) ) ;
97120
98121 // Auto select sample type
99122 useEffect ( ( ) => {
0 commit comments