Compare commits
3 commits
3cbde0db03
...
fac44484b4
Author | SHA1 | Date | |
---|---|---|---|
Ben Goldsworthy | fac44484b4 | ||
Ben Goldsworthy | 5d33b2b4ca | ||
Ben Goldsworthy | 97eb397a8e |
|
@ -5,11 +5,13 @@
|
|||
body {
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 3em;
|
||||
text-align: center;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
details h2 {
|
||||
|
@ -38,6 +40,11 @@ details h2 {
|
|||
* Layout
|
||||
*/
|
||||
|
||||
.page-header {
|
||||
background-color: #a4ecfc;
|
||||
border-bottom: 5px solid black;
|
||||
}
|
||||
|
||||
.other-links {
|
||||
display: block;
|
||||
margin: auto;
|
||||
|
@ -51,8 +58,30 @@ details h2 {
|
|||
}
|
||||
|
||||
.other-links li {
|
||||
background-color: #5adefc;
|
||||
float: left;
|
||||
margin-right: 1.5em;
|
||||
border: 2px solid white;
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
.other-links li:first-of-type {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.other-links li:hover {
|
||||
background-color: #2389a0;
|
||||
}
|
||||
|
||||
.other-links li p {
|
||||
padding: 0.5em 1em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.other-links li p a {
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.trip-meta {
|
||||
|
@ -69,7 +98,6 @@ details h2 {
|
|||
|
||||
#routeContainer {
|
||||
display: grid;
|
||||
grid-gap: 20px;
|
||||
}
|
||||
|
||||
#mapContainer {
|
||||
|
@ -84,18 +112,32 @@ details h2 {
|
|||
#checkinList {
|
||||
grid-column-start: 1;
|
||||
grid-column-end: 3;
|
||||
border-top: 5px solid black;
|
||||
}
|
||||
|
||||
details {
|
||||
.checkin {
|
||||
border-top: 1px solid black;
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
||||
details[open] summary {
|
||||
.checkin__summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checkin[open] .checkin__summary {
|
||||
margin-bottom: 1em;
|
||||
border-bottom: 1px solid gray;
|
||||
}
|
||||
|
||||
.checkin__meta {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.checkin[open] .checkin__meta {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
#checkinList li:first-child details {
|
||||
#checkinList li:first-child .checkin {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
|
@ -113,22 +155,42 @@ details[open] summary {
|
|||
width: auto;
|
||||
height: auto;
|
||||
max-width: 70vw;
|
||||
max-height: 45vh;
|
||||
margin-top: 1em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Large Display
|
||||
*/
|
||||
@media screen and (min-width: 1024px) {
|
||||
.page-header {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
text-align: left;
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.other-links {
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.trip-meta {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#routeContainer {
|
||||
grid-template-columns: 3fr 1fr;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
}
|
||||
|
||||
#mapContainer {
|
||||
grid-column-end: 2;
|
||||
height: fit-content;
|
||||
border-bottom: 5px solid black;
|
||||
}
|
||||
|
||||
#map {
|
||||
|
@ -138,6 +200,13 @@ details[open] summary {
|
|||
|
||||
#checkinList {
|
||||
grid-column-start: 2;
|
||||
border-top: 0;
|
||||
border-left: 5px solid black;
|
||||
}
|
||||
|
||||
#checkinList ol {
|
||||
margin-top: 0;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.leaflet-popup {
|
||||
|
@ -145,6 +214,8 @@ details[open] summary {
|
|||
}
|
||||
|
||||
.popup__image {
|
||||
max-width: 50vw;
|
||||
max-width: 100%;
|
||||
max-height: none;
|
||||
margin-top: 1em;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<header class="page-header">
|
||||
<h1 class="page-title">Where in the World is Ben?</h1>
|
||||
<nav class="other-links">
|
||||
<ul>
|
||||
|
@ -44,8 +44,11 @@
|
|||
<ol start="{{ count($trip->checkins) }}" reversed>
|
||||
@foreach(array_slice(array_reverse($trip->checkins), 0, 15) as $checkin)
|
||||
<li>
|
||||
<details id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
|
||||
<summary><h2>{{ $checkin->title ?? "[No title]" }}</h2> <span>{{ date('j M Y (G:H)', strtotime($checkin->date)) }}</span></summary>
|
||||
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
|
||||
<summary class="checkin__summary">
|
||||
<h2 class="checkin__title">{{ $checkin->title ?? "[No title]" }}</h2>
|
||||
<p class="checkin__meta">{{ date('j M Y (G:H)', strtotime($checkin->date)) }}</p>
|
||||
</summary>
|
||||
{{ $checkin->note ?? "[No note]" }}
|
||||
@if($checkin->image_url)
|
||||
<img class="popup__image" loading="lazy" src="{{ $checkin->image_url }}">
|
||||
|
@ -59,20 +62,28 @@
|
|||
|
||||
<footer>
|
||||
<script>
|
||||
var map = L.map('map').setView([{{ end($trip->locations)->latitude }}, {{ end($trip->locations)->longitude }}], 7);
|
||||
/*
|
||||
* Initialise the map
|
||||
*/
|
||||
var map = L.map('map');//.setView([{{ end($trip->locations)->latitude }}, {{ end($trip->locations)->longitude }}], 7);
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution: 'OpenStreetMap'
|
||||
}).addTo(map);
|
||||
|
||||
/*
|
||||
* Populate the route line.
|
||||
*/
|
||||
var routePoints = L.polyline([
|
||||
@foreach($trip->locations as $location)
|
||||
[{{ $location->latitude }}, {{ $location->longitude }}],
|
||||
@endforeach
|
||||
]).addTo(map);
|
||||
|
||||
/*
|
||||
* Populate all the checkins and popup texts.
|
||||
*/
|
||||
var checkinMarkers = [];
|
||||
|
||||
var marker = null, popupMarkup = null;
|
||||
@foreach($trip->checkins as $checkin)
|
||||
marker = L.marker([{{ $checkin->location->latitude }}, {{ $checkin->location->longitude }}]).addTo(map);
|
||||
|
@ -85,11 +96,37 @@
|
|||
checkinMarkers[{{ $checkin->id }}] = marker;
|
||||
@endforeach
|
||||
|
||||
/*
|
||||
* Fit the map to the last 25 locations, and then zoom out
|
||||
* (to help provide context).
|
||||
*/
|
||||
map.fitBounds([
|
||||
@foreach(array_slice(array_reverse($trip->locations), 0, 25) as $location)
|
||||
[{{ $location->latitude }}, {{$location->longitude }}],
|
||||
@endforeach
|
||||
]);
|
||||
map.zoomOut(2);
|
||||
|
||||
/*
|
||||
* Add the current location marker.
|
||||
*
|
||||
* If this goes before the `fitBounds()`, it ends up uncentered.
|
||||
* TODO: Revisit once fixed with other popups.
|
||||
*/
|
||||
var currLocationMarker = L.icon({
|
||||
iconUrl: 'current-location-icon.png',
|
||||
iconSize: [30, 45],
|
||||
});
|
||||
|
||||
var currLocation = L.marker(
|
||||
[{{ end($trip->locations)->latitude }}, {{ end($trip->locations)->longitude }}],
|
||||
{icon: currLocationMarker}
|
||||
).addTo(map).setZIndexOffset(1000);
|
||||
currLocation.bindPopup('<p>Current location</p>').openPopup();
|
||||
|
||||
/*
|
||||
* Changes the currently-selected popup.
|
||||
*/
|
||||
function toggleCheckin(isOpen, checkinId) {
|
||||
if (isOpen) {
|
||||
var checkins = document.querySelectorAll('details');
|
||||
|
|
Loading…
Reference in a new issue