11import { LngLatCoords } from "@macrostrat/map-interface" ;
22import { useState , useCallback } from 'react' ;
33import 'mapbox-gl/dist/mapbox-gl.css' ;
4- import { BlankImage , Footer , getProfilePicUrl , getImageUrl } from "~/components/general" ;
5- import { Icon , Divider } from "@blueprintjs/core" ;
4+ import { BlankImage , Footer , getProfilePicUrl , getImageUrl , Comments } from "~/components/general" ;
5+ import { Icon , Divider , H2 } from "@blueprintjs/core" ;
66import h from "./main.module.sass" ;
77import { SETTINGS } from "@macrostrat-web/settings" ;
88import "@macrostrat/style-system" ;
99import { Overlay2 } from "@blueprintjs/core" ;
1010import { LithologyList } from "@macrostrat/data-components" ;
1111import { ClientOnly } from "vike-react/ClientOnly" ;
12- import { ExpansionPanel } from "@macrostrat/map-interface" ;
1312
1413function Map ( props ) {
1514 return h (
@@ -23,34 +22,6 @@ function Map(props) {
2322}
2423
2524export function Checkins ( { checkin, comments} ) {
26- console . log ( "checkin" , comments )
27- /*
28- const [isOpen, setIsOpen] = useState(false);
29- const toggleOverlay = useCallback(() => setIsOpen(open => !open), [setIsOpen]);
30-
31- return h("div.container", [
32- h('button', {
33- className: "bp3-button bp3-intent-primary",
34- onClick: toggleOverlay
35- }, "Open Overlay"),
36- h(Overlay2,
37- {
38- isOpen,
39- onClose: toggleOverlay,
40- className: "checkin-overlay",
41- usePortal: true,
42- canEscapeKeyClose: true,
43- canOutsideClickClose: true,
44- hasBackdrop: true,
45- }, "hello"
46-
47- )
48- ]);
49- */
50-
51- const [ overlayOpen , setOverlayOpen ] = useState ( false ) ;
52- const [ showMap , setShowMap ] = useState ( false ) ;
53-
5425 const center = {
5526 lat : checkin . lat ,
5627 lng : checkin . lng
@@ -112,7 +83,7 @@ const [isOpen, setIsOpen] = useState(false);
11283
11384
11485 let main = h ( 'div' , { className : "container" } , [
115- h ( 'div' , { className : showMap ? 'hide' : 'main' } , [
86+ h ( 'div' , { className : 'main' } , [
11687 h ( 'div' , { className : "checkin-head" } , [
11788 h ( 'h1' , checkin . notes ) ,
11889 ] ) ,
@@ -125,7 +96,11 @@ const [isOpen, setIsOpen] = useState(false);
12596 } ) ,
12697 h ( 'div' , { className : 'observations' } , observations ) ,
12798 ] ) ,
128- h ( Comments , { comments } ) ,
99+ h . if ( comments ?. length > 0 ) ( 'div.comments-container' , [
100+ h ( 'h2' , 'Comments' ) ,
101+ h ( Divider ) ,
102+ h ( Comments , { comments } ) ,
103+ ] ) ,
129104 h ( Footer ) ,
130105 ] )
131106
@@ -250,42 +225,4 @@ function observationFooter(observation) {
250225 h ( 'p' , { className : "notes" } , rocks . notes ) ,
251226 ] ) ,
252227 ] ) ;
253- }
254-
255- function Comments ( { comments} ) {
256- const commentArr = [ ] ;
257-
258- comments . forEach ( ( item , index ) => {
259- const { created, comment, person_id, name, likes } = item ;
260-
261- const commentNode = h ( 'div.comment' , [
262- h ( 'div.comment-author' , [
263- h ( BlankImage , {
264- className : 'comment-pic' ,
265- src : getProfilePicUrl ( person_id ) ,
266- alt : "profile picture"
267- } ) ,
268- h ( 'p' , { className : 'comment-author' } , name ) ,
269- ] ) ,
270- h ( 'p' , { className : 'comment-text' } , comment ) ,
271- h ( 'p' , { className : 'comment-date' } , created ) ,
272- h ( 'div.comment-likes' , [
273- h ( Icon , { icon : 'thumbs-up' , className : 'like-icon' } ) ,
274- h ( 'p' , { className : 'comment-likes' } , String ( likes ) ) ,
275- ] )
276- ] ) ;
277-
278- commentArr . push ( commentNode ) ;
279-
280- // Add divider between comments (but not after the last one)
281- if ( index < comments . length - 1 ) {
282- commentArr . push ( h ( Divider ) ) ;
283- }
284- } ) ;
285-
286- return h ( 'div.comments' , [
287- h ( 'h2' , 'Comments' ) ,
288- h ( Divider ) ,
289- ...commentArr
290- ] ) ;
291228}
0 commit comments