Skip to content

Commit cb23841

Browse files
committed
merged branches
2 parents c473faa + 610a870 commit cb23841

File tree

2 files changed

+102
-30
lines changed

2 files changed

+102
-30
lines changed

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

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ function FeatureDetails() {
118118
let checkins = [];
119119
let result;
120120

121-
if(mapRef == null) {
122-
result = getCheckins(0, 100, 0, 100);
121+
if(mapRef?.current == null) {
122+
return h(Spinner)
123123
} else {
124124
let map = mapRef.current;
125125

@@ -140,7 +140,7 @@ function FeatureDetails() {
140140
}, [bounds]);
141141
}
142142

143-
if (result == null) return h(Spinner);
143+
if (result == null) return h("div.checkin-container",Spinner);
144144
result = result.success.data;
145145
console.log("result:",result)
146146

@@ -240,16 +240,20 @@ function WeaverMap({
240240
const style = useMapStyle(type, mapboxToken);
241241

242242
const [featuredCheckins, setFeaturedCheckin] = useState(h(Spinner));
243+
// overlay
244+
const [isOpenSelected, setOpenSelected] = useState(true);
245+
243246

244247
const [inspectPosition, setInspectPosition] =
245248
useState<mapboxgl.LngLat | null>(null);
246249

247250
const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {
248251
setInspectPosition(position);
252+
setOpenSelected(true);
249253
}, []);
250254

251255
let detailElement = null;
252-
let selectedCheckin = h('h1', { className: 'no-checkins' }, "No Checkin(s) Selected");
256+
let selectedCheckin = null;
253257
let result = getCheckins(inspectPosition?.lat - .05, inspectPosition?.lat + .05, inspectPosition?.lng - .05, inspectPosition?.lng + .05);
254258
if (inspectPosition != null) {
255259
detailElement = h(
@@ -268,13 +272,26 @@ function WeaverMap({
268272

269273
// TODO: have run depend on changing mapRef
270274
let featuredCheckin = h(FeatureDetails);
275+
let overlay;
271276

272-
let overlay = h(
273-
"div.overlay-div",
274-
[
275-
h(ExpansionPanel, {title: "Selected Checkins"}, selectedCheckin),
276-
h(ExpansionPanel, {title: "Featured Checkins"}, featuredCheckin),
277+
if (selectedCheckin == null || !isOpenSelected) {
278+
overlay = h("div.sidebox", [
279+
h('div.title', h("h1", "Featured Checkins")),
280+
h("div.overlay-div", featuredCheckin),
277281
]);
282+
} else {
283+
overlay = h("div.sidebox", [
284+
h('div.title', [
285+
h("h1", "Selected Checkins"),
286+
h('h3', { className: "coordinates" }, formatCoordinates(inspectPosition.lat, inspectPosition.lng)),
287+
]),
288+
h("button", {
289+
className: "close-btn",
290+
onClick: () => setOpenSelected(false)
291+
}, "X"),
292+
h("div.overlay-div", selectedCheckin)
293+
]);
294+
}
278295

279296
if(style == null) return null;
280297

@@ -285,7 +302,6 @@ function WeaverMap({
285302
h(
286303
MapAreaContainer,
287304
{
288-
detailPanel: detailElement,
289305
contextPanelOpen: isOpen,
290306
},
291307
[
@@ -311,15 +327,15 @@ function getSelectedCheckins(result) {
311327

312328
// Selected checkin
313329
if (result == null) {
314-
return h(Spinner);
330+
return null;
315331
} else {
316332
result = result.success.data;
317333
checkins = createCheckins(result, mapRef, false);
318334

319335
if (checkins.length > 0) {
320336
return h("div", {className: 'checkin-container'}, checkins);
321337
} else {
322-
return h('h1', { className: 'no-checkins' }, "No Checkin(s) Selected");
338+
return null;
323339
}
324340
}
325341
}
@@ -346,4 +362,16 @@ function useMapStyle(type, mapboxToken) {
346362
}, []);
347363

348364
return actualStyle;
365+
}
366+
367+
function formatCoordinates(latitude, longitude) {
368+
// Round latitude and longitude to 4 decimal places
369+
const roundedLatitude = latitude.toFixed(4);
370+
const roundedLongitude = longitude.toFixed(4);
371+
372+
const latitudeDirection = latitude >= 0 ? 'N' : 'S';
373+
const longitudeDirection = longitude >= 0 ? 'E' : 'W';
374+
375+
// Return the formatted string with rounded values
376+
return `${Math.abs(roundedLatitude)}° ${latitudeDirection}, ${Math.abs(roundedLongitude)}° ${longitudeDirection}`;
349377
}

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

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ h3,h4,p
9494

9595
.overlay-div
9696
position: absolute
97-
top: 0
97+
top: 10%
9898
left: 0
9999
z-index: 1000
100-
background: rgba(255, 255, 255, 0.9)
101-
padding: 8px
102100
border-radius: 0 4px 4px 0
103101
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2)
104-
max-height: 100vh
102+
height: 90vh
105103
overflow-y: auto
106-
width: 30%
104+
width 100%
105+
padding 8px
106+
padding-top 0
107107

108108
.overlay-div > *:not(:last-child)
109109
margin-bottom 8px
@@ -133,8 +133,63 @@ h3,h4,p
133133
border-radius: 4px;
134134
width 100%
135135

136-
.no-checkins
137-
color black
136+
.sidebox
137+
position absolute
138+
z-index 1000
139+
height 100vh
140+
width 30%
141+
top 0
142+
left 0
143+
background rgba(255, 255, 255, 0.8)
144+
145+
.title
146+
color black
147+
position fixed
148+
width 30%
149+
background rgba(255, 255, 255, 0.85)
150+
margin 0
151+
height 10vh
152+
display flex
153+
flex-direction column
154+
align-items center
155+
justify-content center
156+
157+
h1
158+
margin-bottom 0
159+
margin-top 0
160+
161+
.close-btn
162+
position absolute
163+
top 10px
164+
right 10px
165+
background-color #333
166+
color white
167+
border none
168+
border-radius 50%
169+
width 30px
170+
height 30px
171+
display flex
172+
justify-content center
173+
align-items center
174+
font-size 15px
175+
cursor pointer
176+
box-shadow 0 4px 8px rgba(0, 0, 0, 0.2)
177+
transition background-color 0.3s, box-shadow 0.3s
178+
179+
.close-btn:hover
180+
background-color #555
181+
box-shadow 0 6px 12px rgba(0, 0, 0, 0.3)
182+
183+
.marker
184+
height 7vh
185+
display grid
186+
margin auto
187+
margin-right 10px
188+
189+
.details-image
190+
width 40px
191+
margin-left 10px
192+
margin-top 4px
138193

139194
.checkin-footer
140195
display flex
@@ -159,14 +214,3 @@ h3,h4,p
159214

160215
.comments-image
161216
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)