99import { getColors } from "#/dev/map/rockd-strabospot/map-style" ;
1010import { useInDarkMode } from "@macrostrat/ui-components" ;
1111import { SaveLocationForm } from "./save-location" ;
12+ import mapboxgl from "mapbox-gl" ;
1213import React , { useState , useEffect } from "react" ;
1314
1415
@@ -17,7 +18,7 @@ import React, { useState, useEffect } from "react";
1718const h = hyper . styled ( styles ) ;
1819export function DetailsPanel ( { position, nearbyFeatures, onClose } ) {
1920 if ( position == null ) return null ;
20- let count = 22 ;
21+ let count = 24 ;
2122
2223 return h (
2324 LocationPanel ,
@@ -26,34 +27,13 @@ export function DetailsPanel({ position, nearbyFeatures, onClose }) {
2627 position,
2728 } ,
2829 [
29- h ( SaveLocationForm , { position, count } ) ,
30- //h(CheckinsPanel, { nearbyFeatures }),
31- h ( SpotsPanel , {
32- nearbyFeatures,
33- } ) ,
30+ h ( SaveLocationForm , { position, count } )
31+ //h(CheckinsPanel, { nearbyFeatures })
3432 ]
3533 ) ;
3634}
3735
38- //implement tileserver api to reorient user to an exact location
39- /*
40- export function CheckinsPanel({ nearbyFeatures }) {
41- const checkins = useNearbyCheckins(nearbyFeatures);
42- const titleComponent = () =>
43- h(PanelHeader, {
44- title: "Checkins",
45- sourceLink: h(SystemLink, { href: "https://rockd.org" }, "Rockd"),
46- hasData: checkins.length != 0,
47- });
48-
49- return h(FeatureTypePanel, {
50- features: checkins,
51- titleComponent,
52- featureComponent: CheckinFeature,
53- });
54- }
55- */
56- export function SpotsPanel ( { nearbyFeatures } ) {
36+ export function SpotsPanel ( { onSelectPosition, map } ) {
5737 const [ features , setFeatures ] = useState ( [ ] ) ; // State to store features
5838 const [ loading , setLoading ] = useState ( true ) ; // State to track loading
5939 const [ error , setError ] = useState ( null ) ; // State to track errors
@@ -79,11 +59,19 @@ export function SpotsPanel({ nearbyFeatures }) {
7959 fetchFeatures ( ) ;
8060 } , [ ] ) ;
8161
82- console . log ( "features!!" , features )
83-
84- const FeatureComponent = ( { data } ) => {
62+ const FeatureComponent = ( { data, onSelectPosition, map } ) => {
63+ const handleLinkClick = ( ) => {
64+ if ( onSelectPosition ) {
65+ onSelectPosition ( { lng : data . longitude , lat : data . latitude , zoom : 7 } , map ) ;
66+ }
67+ } ;
8568 return h ( "div.feature" , [
86- h ( "h3.feature-title" , data . location_name ) ,
69+ h ( "h3.feature-title" ,
70+ {
71+ style : { cursor : "pointer" , textDecoration : "bold" , color : "purple" } , // Optional styling for a clickable look
72+ onClick : handleLinkClick ,
73+ } ,
74+ data . location_name ) ,
8775 h ( "p.feature-description" , data . location_description ) ,
8876 h ( "p.feature-coordinates" , [
8977 `Latitude: ${ data . latitude } , Longitude: ${ data . longitude } ` ,
@@ -107,7 +95,7 @@ export function SpotsPanel({ nearbyFeatures }) {
10795 titleComponent,
10896 loading,
10997 error,
110- featureComponent : FeatureComponent ,
98+ featureComponent : ( props ) => h ( FeatureComponent , { ... props , onSelectPosition , map } ) ,
11199 } ) ;
112100}
113101
@@ -166,40 +154,6 @@ function SystemLink({ href, children }) {
166154 ] ) ;
167155}
168156
169- export function LegendList ( ) {
170- const darkMode = useInDarkMode ( ) ;
171- const colors = getColors ( darkMode ) ;
172- return h ( "ul.legend-list" , [
173- h (
174- LegendItem ,
175- {
176- color : colors . checkins ,
177- name : "My saved locations" ,
178- } ,
179- "Will show the user locations on the map. Need to build it within the tileserver."
180- ) ,
181- ] ) ;
182- }
183-
184- function LegendItem ( { color, name, sourceLink, children } ) {
185- let child = children ;
186- if ( typeof children === "string" ) {
187- child = h ( "p.description" , children ) ;
188- }
189-
190- return h ( "li.legend-item" , [
191- h ( LegendHeader , { color, name, sourceLink } ) ,
192- h ( "div.legend-body" , child ) ,
193- ] ) ;
194- }
195-
196- function LegendHeader ( { color, name, sourceLink = null } ) {
197- return h ( "div.legend-header" , [
198- h ( Swatch , { color } ) ,
199- h ( "h4" , name ) ,
200- sourceLink ,
201- ] ) ;
202- }
203157
204158function Swatch ( { color } ) {
205159 return h ( "span.swatch" , { style : { backgroundColor : color } } ) ;
0 commit comments