Skip to content

Commit f3e3159

Browse files
committed
everything merged, featured checkins show up most times
1 parent c473faa commit f3e3159

File tree

2 files changed

+91
-15
lines changed

2 files changed

+91
-15
lines changed

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

Lines changed: 38 additions & 9 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) {
122+
return h(Spinner)
123123
} else {
124124
let map = mapRef.current;
125125

@@ -241,15 +241,19 @@ function WeaverMap({
241241

242242
const [featuredCheckins, setFeaturedCheckin] = useState(h(Spinner));
243243

244+
// overlay
245+
const [isOpenSelected, setOpenSelected] = useState(true);
246+
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(
@@ -266,15 +270,28 @@ function WeaverMap({
266270
selectedCheckin = getSelectedCheckins(result);
267271
}
268272

269-
// TODO: have run depend on changing mapRef
270273
let featuredCheckin = h(FeatureDetails);
274+
let overlay;
271275

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

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

@@ -346,4 +363,16 @@ function useMapStyle(type, mapboxToken) {
346363
}, []);
347364

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

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

Lines changed: 53 additions & 6 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
@@ -169,4 +169,51 @@ h3,h4,p
169169
.details-image
170170
width 40px
171171
margin-left 10px
172-
margin-top 4px
172+
margin-top 4px
173+
174+
.sidebox
175+
position absolute
176+
z-index 1000
177+
height 100vh
178+
width 30%
179+
top 0
180+
left 0
181+
background rgba(255, 255, 255, 0.8)
182+
183+
.title
184+
color black
185+
position fixed
186+
width 30%
187+
background rgba(255, 255, 255, 0.85)
188+
margin 0
189+
height 10vh
190+
display flex
191+
flex-direction column
192+
align-items center
193+
justify-content center
194+
195+
h1
196+
margin-bottom 0
197+
margin-top 0
198+
199+
.close-btn
200+
position absolute
201+
top 10px
202+
right 10px
203+
background-color #333
204+
color white
205+
border none
206+
border-radius 50%
207+
width 30px
208+
height 30px
209+
display flex
210+
justify-content center
211+
align-items center
212+
font-size 15px
213+
cursor pointer
214+
box-shadow 0 4px 8px rgba(0, 0, 0, 0.2)
215+
transition background-color 0.3s, box-shadow 0.3s
216+
217+
.close-btn:hover
218+
background-color #555
219+
box-shadow 0 6px 12px rgba(0, 0, 0, 0.3)

0 commit comments

Comments
 (0)