Skip to content

Commit 397fb28

Browse files
committed
Use comments component
1 parent 6a8f24f commit 397fb28

File tree

2 files changed

+10
-97
lines changed

2 files changed

+10
-97
lines changed

pages/checkin/index.ts

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { LngLatCoords } from "@macrostrat/map-interface";
22
import { useState, useCallback } from 'react';
33
import '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";
66
import h from "./main.module.sass";
77
import { SETTINGS } from "@macrostrat-web/settings";
88
import "@macrostrat/style-system";
99
import { Overlay2 } from "@blueprintjs/core";
1010
import { LithologyList } from "@macrostrat/data-components";
1111
import { ClientOnly } from "vike-react/ClientOnly";
12-
import { ExpansionPanel } from "@macrostrat/map-interface";
1312

1413
function Map(props) {
1514
return h(
@@ -23,34 +22,6 @@ function Map(props) {
2322
}
2423

2524
export 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
}

pages/checkin/main.module.sass

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -247,30 +247,6 @@ h4
247247
width: 50%
248248
text-align: center
249249

250-
.comments
251-
margin-left: 20%
250+
.comments-container
252251
width: 60%
253-
margin-bottom: 2em
254-
255-
h2
256-
margin: 0
257-
258-
.comment
259-
display: grid
260-
grid-template-columns: 25% 55% 15% 5%
261-
padding: .5em
262-
align-items: center
263-
264-
.comment-likes
265-
display: flex
266-
gap: .5em
267-
268-
.comment-author
269-
display: flex
270-
flex-direction: column
271-
justify-content: center
272-
align-items: center
273-
274-
.comment-pic
275-
height: 6em
276-
width: 6em
252+
margin: 0 0 2em 20%

0 commit comments

Comments
 (0)