@@ -13,6 +13,7 @@ import { MapAreaContainer, MapView, MapMarker } from "@macrostrat/map-interface"
1313import 'mapbox-gl/dist/mapbox-gl.css' ;
1414import { MapPosition } from "@macrostrat/mapbox-utils" ;
1515import { PanelCard } from "@macrostrat/map-interface" ;
16+ import { LithologyList } from "@macrostrat/data-components" ;
1617
1718const h = hyper . styled ( styles ) ;
1819
@@ -63,19 +64,15 @@ export function Checkins({checkinID}) {
6364
6465 observations . push (
6566 h ( 'div' , { className : 'observation' } , [
66- headerImgUrl ? h ( BlankImage , { className : 'observation-image' , src : headerImgUrl , onClick : ( ) => {
67- setOverlayBody ( h ( 'div.observation-body' , headerBody ) ) ;
68- setOverlayImage ( headerImgUrl ) ;
69- setOverlayOpen ( ! overlayOpen ) ;
70- }
71- } ) : null ,
67+ headerImgUrl ? h ( 'a' , { href : "/photo/" + checkin . photo } ,
68+ h ( BlankImage , { className : 'observation-image' , src : headerImgUrl } )
69+ ) : null ,
7270 h ( "div.observation-body" , headerBody ) ,
7371 ] )
7472 ) ;
7573
7674 // add observations
7775 checkin . observations . forEach ( observation => {
78- console . log ( "obs" , observation . photo , observation ) ;
7976 if ( Object . keys ( observation . rocks ) . length != 0 ) {
8077 // if photo exists
8178 const imageSrc = apiURL + "protected/image/" + checkin . person_id + "/thumb_large/" + observation . photo ;
@@ -84,11 +81,9 @@ export function Checkins({checkinID}) {
8481
8582 observations . push (
8683 h ( 'div' , { className : 'observation' } , [
87- observationURL ? h ( BlankImage , { className : 'observation-image' , src : observationURL , onClick : ( ) => {
88- setOverlayImage ( imageSrc ) ;
89- setOverlayBody ( observationBody ) ;
90- setOverlayOpen ( ! overlayOpen ) ;
91- } } ) : null ,
84+ observationURL ? h ( 'a' , { href : "/photo/" + observation . photo } ,
85+ h ( BlankImage , { className : 'observation-image' , src : observationURL } )
86+ ) : null ,
9287 observationBody ,
9388 ] )
9489 ) ;
@@ -125,7 +120,6 @@ export function Checkins({checkinID}) {
125120 h ( 'div' , { className : showMap ? 'hide' : 'main' } , [
126121 h ( 'div' , { className : "checkin-head" } , [
127122 h ( 'h1' , checkin . notes ) ,
128- h ( DarkModeButton , { className : 'dark-mode-button' , showText : true } ) ,
129123 ] ) ,
130124 h ( BlankImage , { className : "location-img" , src : "https://api.mapbox.com/styles/v1/jczaplewski/cje04mr9l3mo82spihpralr4i/static/geojson(%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B" + checkin . lng + "%2C" + checkin . lat + "%5D%7D)/" + checkin . lng + "," + checkin . lat + ",5,0/1200x400?access_token=" + SETTINGS . mapboxAccessToken } ) ,
131125 h ( 'div' , { className : 'stop-header' , onClick : ( ) => { setShowMap ( true ) ; console . log ( "center" , center ) } } , [
@@ -168,22 +162,75 @@ function observationFooter(observation) {
168162 let liths = [ ] ;
169163 for ( var j = 0 ; j < rocks . liths . length ; j ++ ) {
170164 liths . push ( h ( 'p' , { className : "observation-detail liths" } , rocks . liths [ j ] . name ) ) ;
165+ }
166+
167+ function rgbaStringToHex ( rgba : string ) : string {
168+ // Split the input string by commas and trim whitespace
169+ const values = rgba . split ( ',' ) . map ( value => value . trim ( ) ) ;
170+
171+ // Extract r, g, b values and ignore alpha
172+ const r = parseInt ( values [ 0 ] , 10 ) ;
173+ const g = parseInt ( values [ 1 ] , 10 ) ;
174+ const b = parseInt ( values [ 2 ] , 10 ) ;
175+
176+ // Convert r, g, b to two-digit hex values
177+ const red = r . toString ( 16 ) . padStart ( 2 , '0' ) ;
178+ const green = g . toString ( 16 ) . padStart ( 2 , '0' ) ;
179+ const blue = b . toString ( 16 ) . padStart ( 2 , '0' ) ;
180+
181+ // Return the HEX string without alpha
182+ return `#${ red } ${ green } ${ blue } ` ;
171183 }
172184
173- // observation body
174185 let obsAge = observation . age_est ? observation . age_est . name + " (" + observation . age_est . b_age + " - " + observation ?. age_est ?. t_age + ")" : null ;
186+
187+ let lithologies = [ ] ;
188+ rocks . liths . forEach ( lith => {
189+ if ( ! lith . color . includes ( "#" ) ) {
190+ lithologies . push ( {
191+ name : lith . name ,
192+ color : rgbaStringToHex ( lith . color ) } ) ;
193+ } else {
194+ lithologies . push ( lith ) ;
195+ }
196+ } ) ;
197+
198+ if ( rocks . strat_name ?. strat_name_long ) {
199+ lithologies . push ( {
200+ name : rocks . strat_name ?. strat_name_long ,
201+ } )
202+ }
203+
204+ if ( rocks . map_unit ?. unit_name ) {
205+ lithologies . push ( {
206+ name : rocks . map_unit ?. unit_name
207+ } )
208+ }
209+
210+ if ( obsAge ) {
211+ lithologies . push ( {
212+ name : obsAge
213+ } )
214+ }
215+ if ( rocks . interval . name ) {
216+ lithologies . push ( {
217+ name : rocks . interval . name
218+ } )
219+ }
220+ if ( observation . orientation . feature ?. name ) {
221+ lithologies . push ( {
222+ name : observation . orientation . feature ?. name
223+ } )
224+ }
225+
226+ // observation body
175227 return h ( 'div' , { className : 'observation-body' } , [
176228 observation . lat && rocks . strat_name ?. strat_name_long ? h ( 'h4' , { className : 'observation-header' } , [
177229 rocks . strat_name ?. strat_name_long ,
178230 observation . lat ? LngLatCoords ( LngLatProps ) : null ,
179231 ] ) : null ,
180232 h ( 'div' , { className : 'observation-details' } , [
181- rocks . strat_name ?. strat_name_long ? h ( 'p' , { className : 'observation-detail' } , rocks . strat_name ?. strat_name_long ) : null ,
182- rocks . map_unit ?. unit_name ? h ( 'p' , { className : 'observation-detail' } , rocks . map_unit ?. unit_name ) : null ,
183- obsAge ? h ( 'p' , { className : 'observation-detail' } , obsAge ) : null ,
184- rocks . interval . name ? h ( 'p' , { className : 'observation-detail interval' } , rocks . interval . name ) : null ,
185- liths ,
186- observation . orientation . feature ?. name ? h ( 'p' , { className : 'observation-detail' } , observation . orientation . feature ?. name ) : null ,
233+ h ( LithologyList , { lithologies } ) ,
187234 h ( 'p' , { className : "notes" } , rocks . notes ) ,
188235 ] ) ,
189236 ] ) ;
@@ -221,7 +268,6 @@ function Map({center, showMap, setShowMap}) {
221268 setShowMap ( ! showMap ) ;
222269 } } ) ,
223270 h ( PanelCard , { className : "banner-button" , onClick : ( ) => {
224- console . log ( "clicked" ) ;
225271 setStyle ( style == whiteStyle ? sateliteStyle : whiteStyle ) ;
226272 setStyleText ( styleText == whiteText ? sateliteText : whiteText ) ;
227273 } } , styleText ) ,
0 commit comments