Skip to content

Commit c473faa

Browse files
committed
Merge branch 'checkin-style'
2 parents 904d539 + 37ac761 commit c473faa

File tree

4 files changed

+118
-69
lines changed

4 files changed

+118
-69
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@macrostrat/web",
33
"private": true,
4-
"version": "5.1.1",
4+
"version": "2.0.0",
55
"description": "Macrostrat map interface",
66
"type": "module",
77
"scripts": {
@@ -12,7 +12,6 @@
1212
"server:dev": "tsx --env-file=.env ./server/index.ts",
1313
"format": "prettier --write src packages",
1414
"server:prod": "NODE_NO_WARNINGS=1 NODE_ENV=production yarn run server",
15-
"dev:storybook": "yarn workspace @macrostrat/storybook run dev",
1615
"start": "yarn run build && yarn run server",
1716
"test:runtime": "tsx tests/test-urls.ts",
1817
"test": "vitest"

pages/dev/test-site/explore/+Page.client.ts

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { useCallback, useEffect, useState } from "react";
2222
import { tileserverDomain } from "@macrostrat-web/settings";
2323
import "./main.styl";
2424
import { BlankImage, Image } from "../index";
25+
import { pipeNodeStream } from "vike/dist/esm/node/runtime/html/stream";
2526

2627
export function Page() {
2728
return h(
@@ -141,8 +142,34 @@ function FeatureDetails() {
141142

142143
if (result == null) return h(Spinner);
143144
result = result.success.data;
145+
console.log("result:",result)
146+
147+
checkins = createCheckins(result, mapRef, true);
148+
149+
return h("div", {className: 'checkin-container'}, [
150+
h('div', checkins)
151+
]);
152+
}
153+
154+
function createCheckins(result, mapRef, showPin) {
155+
let checkins = [];
156+
let map = mapRef?.current;
144157

145158
result.forEach((checkin) => {
159+
let pin = null;
160+
161+
if(showPin) {
162+
pin = h(Image,
163+
{ src: "marker_red.png",
164+
className: "marker",
165+
onClick: () => {
166+
console.log("clicked at: ", checkin.lat + " " + checkin.lng);
167+
map.flyTo({center: [checkin.lng, checkin.lat], zoom: 12});
168+
}
169+
})
170+
}
171+
172+
146173
// format rating
147174
let ratingArr = [];
148175
for(var i = 0; i < checkin.rating; i++) {
@@ -156,11 +183,12 @@ function FeatureDetails() {
156183

157184
if (imageExists("https://rockd.org/api/v1/protected/image/" + checkin.person_id + "/thumb_large/" + checkin.photo)) {
158185
image = h(BlankImage, {className: 'observation-img', src: "https://rockd.org/api/v1/protected/image/" + checkin.person_id + "/thumb_large/" + checkin.photo});
186+
} else {
187+
image = h(Image, { className: 'observation-img', src: "rockd.jpg"});
159188
}
160189

161190

162-
let temp = h('a', {className: 'checkin-link', href: "/dev/test-site/checkin?checkin=" + checkin.checkin_id}, [
163-
h('div', { className: 'checkin' }, [
191+
let temp = h('div', { className: 'checkin' }, [
164192
h('div', {className: 'checkin-header'}, [
165193
h('h3', {className: 'profile-pic'}, h(BlankImage, {src: "https://rockd.org/api/v2/protected/gravatar/" + checkin.person_id, className: "profile-pic"})),
166194
h('div', {className: 'checkin-info'}, [
@@ -169,19 +197,32 @@ function FeatureDetails() {
169197
h('p', "Near " + checkin.near),
170198
h('h3', {className: 'rating'}, ratingArr),
171199
]),
200+
pin,
172201
]),
173202
h('p', {className: 'description'}, checkin.notes),
174-
image
175-
]),
176-
]);
203+
h('a', {className: 'checkin-link', href: "/dev/test-site/checkin?checkin=" + checkin.checkin_id, target: "_blank"}, [
204+
image,
205+
h('div', {className: "image-details"}, [
206+
h('h1', "Details"),
207+
h(Image, {className: 'details-image', src: "explore/white-arrow.png"})
208+
])
209+
]),
210+
h('div', {className: 'checkin-footer'}, [
211+
h('div', {className: 'likes-container'}, [
212+
h(Image, {className: 'likes-image', src: "explore/thumbs-up.png"}),
213+
h('h3', {className: 'likes'}, checkin.likes),
214+
]),
215+
h('div', {className: 'comments-container'}, [
216+
h(Image, {className: 'comments-image', src: "explore/comment.png"}),
217+
h('h3', {className: 'comments'}, checkin.comments),
218+
])
219+
]),
220+
]);
177221

178222
checkins.push(temp);
179223
});
180-
181224

182-
return h("div", {className: 'checkin-container'}, [
183-
h('div', checkins)
184-
]);
225+
return checkins;
185226
}
186227

187228
function WeaverMap({
@@ -192,8 +233,6 @@ function WeaverMap({
192233
children?: React.ReactNode;
193234
mapboxToken?: string;
194235
}) {
195-
const mapRef = useMapRef();
196-
197236
const [isOpen, setOpen] = useState(false);
198237

199238
const [type, setType] = useState(types[0]);
@@ -268,48 +307,14 @@ function WeaverMap({
268307

269308
function getSelectedCheckins(result) {
270309
let checkins = [];
271-
console.log("result", result);
310+
let mapRef = useMapRef();
272311

273312
// Selected checkin
274313
if (result == null) {
275314
return h(Spinner);
276315
} else {
277316
result = result.success.data;
278-
result.forEach((checkin) => {
279-
// format rating
280-
let ratingArr = [];
281-
for(var i = 0; i < checkin.rating; i++) {
282-
ratingArr.push(h(Image, {className: "star", src: "blackstar.png"}));
283-
}
284-
285-
for(var i = 0; i < 5 - checkin.rating; i++) {
286-
ratingArr.push(h(Image, {className: "star", src: "emptystar.png"}));
287-
}
288-
let image;
289-
290-
if (imageExists("https://rockd.org/api/v1/protected/image/" + checkin.person_id + "/thumb_large/" + checkin.photo)) {
291-
image = h(BlankImage, {className: 'observation-img', src: "https://rockd.org/api/v1/protected/image/" + checkin.person_id + "/thumb_large/" + checkin.photo});
292-
}
293-
294-
295-
let temp = h('a', {className: 'checkin-link', href: "/dev/test-site/checkin?checkin=" + checkin.checkin_id}, [
296-
h('div', { className: 'checkin' }, [
297-
h('div', {className: 'checkin-header'}, [
298-
h('h3', {className: 'profile-pic'}, h(BlankImage, {src: "https://rockd.org/api/v2/protected/gravatar/" + checkin.person_id, className: "profile-pic"})),
299-
h('div', {className: 'checkin-info'}, [
300-
h('h3', {className: 'name'}, checkin.first_name + " " + checkin.last_name),
301-
h('h4', {className: 'edited'}, checkin.created),
302-
h('p', "Near " + checkin.near),
303-
h('h3', {className: 'rating'}, ratingArr),
304-
]),
305-
]),
306-
h('p', {className: 'description'}, checkin.notes),
307-
image
308-
]),
309-
]);
310-
311-
checkins.push(temp);
312-
});
317+
checkins = createCheckins(result, mapRef, false);
313318

314319
if (checkins.length > 0) {
315320
return h("div", {className: 'checkin-container'}, checkins);

pages/dev/test-site/explore/main.styl

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
text-align left
44
box-shadow -4px 0px 7px #aaa
55
padding 15px
6+
padding-bottom 6px
67
border-radius 2%
78
font-size 14px
89
color #666
@@ -48,29 +49,39 @@
4849
margin auto
4950
margin-left 0
5051

51-
.checkin-link:hover
52-
text-decoration none
53-
background-color green
54-
55-
.checkin
56-
background-color #c9c9c9
57-
58-
.checkin-link
59-
text-decoration none
60-
background-color green
61-
62-
.checkin
52+
.checkin
6353
background-color white
6454

6555
h3,h4,p
6656
margin 0
6757

68-
.observation-img
69-
margin-top 10px
70-
width 100%
71-
height 250px
72-
object-fit cover
73-
border-radius 2%
58+
.checkin-link
59+
position relative
60+
61+
.image-details
62+
position: absolute;
63+
top: -250px;
64+
left: 0;
65+
right: 0;
66+
bottom: 0
67+
display: flex;
68+
justify-content: center
69+
align-items: center
70+
display none
71+
color white
72+
73+
.observation-img
74+
margin-top 10px
75+
width 100%
76+
height 250px
77+
object-fit cover
78+
border-radius 2%
79+
80+
.checkin-link:hover
81+
.observation-img
82+
-webkit-filter: brightness(70%)
83+
.image-details
84+
display: flex
7485

7586
.description
7687
margin-top 10px
@@ -123,4 +134,39 @@ h3,h4,p
123134
width 100%
124135

125136
.no-checkins
126-
color black
137+
color black
138+
139+
.checkin-footer
140+
display flex
141+
justify-content center
142+
143+
.likes-container
144+
display grid
145+
grid-template-columns 30% 30%
146+
width 50%
147+
justify-content end
148+
place-items center
149+
150+
151+
.likes-image
152+
width 40px
153+
154+
.comments-container
155+
display grid
156+
grid-template-columns 30% 30%
157+
width 50%
158+
place-items center
159+
160+
.comments-image
161+
width 40px
162+
163+
.marker
164+
height 7vh
165+
display grid
166+
margin auto
167+
margin-right 10px
168+
169+
.details-image
170+
width 40px
171+
margin-left 10px
172+
margin-top 4px

0 commit comments

Comments
 (0)