Skip to content

Commit eb46b0a

Browse files
committed
Comment styling
1 parent 7179e22 commit eb46b0a

File tree

2 files changed

+62
-19
lines changed

2 files changed

+62
-19
lines changed

pages/checkin/index.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { LngLatCoords } from "@macrostrat/map-interface";
22
import { useState, useCallback } from 'react';
33
import 'mapbox-gl/dist/mapbox-gl.css';
44
import { BlankImage, Footer, getProfilePicUrl, getImageUrl } from "~/components/general";
5-
import { Icon } from "@blueprintjs/core";
5+
import { Icon, Divider } 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";
1213

1314
function Map(props) {
1415
return h(
@@ -252,22 +253,39 @@ function observationFooter(observation) {
252253
}
253254

254255
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+
255286
return h('div.comments', [
256-
h('h3', 'Comments'),
257-
comments.map(item => {
258-
const { created, comment, person_id, name, likes } = item;
259-
return h('div.comment', [
260-
h('div.comment-author', [
261-
h(BlankImage, { className: 'profile-picture', src: getProfilePicUrl(person_id), alt: "profile picture" }),
262-
h('p', {className: 'comment-author'}, name),
263-
]),
264-
h('p', {className: 'comment-text'}, comment),
265-
h('p', {className: 'comment-date'}, created),
266-
h('div.comment-likes', [
267-
h(Icon, {icon: 'thumbs-up', className: 'like-icon'}),
268-
h('p', {className: 'comment-likes'}, likes),
269-
])
270-
]);
271-
})
287+
h('h2', 'Comments'),
288+
h(Divider),
289+
...commentArr
272290
]);
273291
}

pages/checkin/main.module.sass

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

250-
.commment
251-
display: flex
250+
.comments
251+
margin-left: 20%
252+
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

0 commit comments

Comments
 (0)