Fix popup centering, styling, a bunch of other stuff

This commit is contained in:
Ben Goldsworthy 2022-10-20 18:03:10 +00:00
parent 3e62eb8d37
commit 61d5f69699
2 changed files with 112 additions and 24 deletions

View file

@ -9,7 +9,7 @@ body {
} }
.page-title { .page-title {
font-size: 3em; font-size: 1.5em;
text-align: center; text-align: center;
margin-top: 0; margin-top: 0;
} }
@ -40,12 +40,27 @@ details h2 {
* Layout * Layout
*/ */
body {
border: 5px solid black;
box-sizing: border-box;
height: 100vh;
/* overflow: hidden;*/
display: grid;
grid-template-rows: auto 1fr;
grid-template-columns: 100%;
grid-template-areas:
"header"
"route";
}
.page-header { .page-header {
grid-area: header;
background-color: #a4ecfc; background-color: #a4ecfc;
border-bottom: 5px solid black; border-bottom: 5px solid black;
} }
.other-links { .other-links {
font-size: 1em;
display: block; display: block;
margin: auto; margin: auto;
overflow: auto; overflow: auto;
@ -74,7 +89,7 @@ details h2 {
} }
.other-links li p { .other-links li p {
padding: 0.5em 1em; padding: 0.25em 0.5em;
margin: 0; margin: 0;
} }
@ -87,6 +102,7 @@ details h2 {
.trip-meta { .trip-meta {
display: block; display: block;
width: 100%; width: 100%;
font-size: 0.8em;
text-align: center; text-align: center;
} }
@ -98,22 +114,28 @@ details h2 {
#routeContainer { #routeContainer {
display: grid; display: grid;
grid-area: route;
grid-template-rows: 55% 45%;
grid-template-columns: 100%;
overflow: hidden;
grid-template-areas:
"map"
"checkins";
} }
#mapContainer { #mapContainer {
grid-column-start: 1; grid-area: map;
grid-column-end: 3;
} }
#map { #map {
height: 400px; height: 100%;
} }
#checkinList { #checkinList {
grid-column-start: 1; grid-area: checkins;
grid-column-end: 3;
border-top: 5px solid black; border-top: 5px solid black;
padding: 0 1em; padding: 0 1em;
overflow: scroll;
} }
.checkin { .checkin {
@ -130,6 +152,10 @@ details h2 {
border-bottom: 1px solid gray; border-bottom: 1px solid gray;
} }
.checkin__title {
font-size: 1em;
}
.checkin__meta { .checkin__meta {
margin: 0; margin: 0;
} }
@ -161,50 +187,65 @@ details h2 {
display: block; display: block;
} }
/*
* Medium Display
*/
@media screen and (min-width: 728px) {
.page__title {
font-size: 2em;
}
}
/* /*
* Large Display * Large Display
*/ */
@media screen and (min-width: 1024px) { @media screen and (min-width: 1024px) {
#routeContainer {
grid-template-columns: 60% 40%;
grid-template-rows: 100%;
grid-template-areas:
"map checkins";
}
.page-header { .page-header {
padding: 1em; padding: 1em;
} }
.page-title { .page-title {
font-size: 2.5em;
text-align: left; text-align: left;
display: inline-block; display: inline-block;
margin-bottom: 0; margin-bottom: 0;
} }
.other-links { .other-links {
font-size: 1.2em;
display: inline-block; display: inline-block;
vertical-align: bottom; vertical-align: bottom;
} }
.other-links li a {
padding: 0.5em 1em;
}
.trip-meta { .trip-meta {
text-align: left; text-align: left;
} font-size: 1em;
#routeContainer {
grid-template-columns: 2fr 1fr;
}
#mapContainer {
grid-column-end: 2;
height: fit-content;
border-bottom: 5px solid black;
} }
#map { #map {
height: auto; height: 100%;
min-height: 800px;
} }
#checkinList { #checkinList {
grid-column-start: 2;
border-top: 0; border-top: 0;
border-left: 5px solid black; border-left: 5px solid black;
} }
.section__title {
text-align: center;
}
#checkinList ol { #checkinList ol {
margin-top: 0; margin-top: 0;
margin-right: 1em; margin-right: 1em;
@ -216,7 +257,7 @@ details h2 {
.popup__image { .popup__image {
max-width: 100%; max-width: 100%;
max-height: none; max-height: 60vh;
margin-top: 1em; margin-top: 1em;
} }
} }

View file

@ -28,12 +28,12 @@
</nav> </nav>
<section class="trip-meta"> <section class="trip-meta">
<p> <p>
<span> Tracking started: {{ date('j M Y (G:H)', strtotime($trip->date_start)) }}</span> | <span> Tracking started: {!! render_date_difference($trip->date_start) !!}</span> |
<span class="{{ ($trip->is_active) ? "positive" : "negative" }}">{{ ($trip->is_active) ? "Active" : "Ended" }}</span> | <span class="{{ ($trip->is_active) ? "positive" : "negative" }}">{{ ($trip->is_active) ? "Active" : "Ended" }}</span> |
@if ($trip->is_active) @if ($trip->is_active)
<span class="{{ ($trip->is_tracking) ? "positive" : "negative" }}">{{ ($trip->is_tracking) ? "Currently tracking" : "Not currently tracking" }}</span> <span class="{{ ($trip->is_tracking) ? "positive" : "negative" }}">{{ ($trip->is_tracking) ? "Currently tracking" : "Not currently tracking" }}</span>
@endif @endif
<span class="small">(Last update: {{ date('j M Y (G:H)', strtotime($trip->updated_at)) }})</span> <span class="small">(Last update: {!! render_date_difference($trip->updated_at) !!})</span>
</p> </p>
</section> </section>
</header> </header>
@ -43,6 +43,7 @@
<div id="map"></div> <div id="map"></div>
</section> </section>
<section id="checkinList"> <section id="checkinList">
<h2 class="section__title">@if ($showAllCheckins) Check-ins @else Recent Check-ins @endif</h2>
<ol start="{{ count($trip->checkins) }}" reversed> <ol start="{{ count($trip->checkins) }}" reversed>
@if($showAllCheckins) @if($showAllCheckins)
@php $checkinsList = array_reverse($trip->checkins) @endphp @php $checkinsList = array_reverse($trip->checkins) @endphp
@ -55,7 +56,7 @@
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)"> <details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
<summary class="checkin__summary"> <summary class="checkin__summary">
<h2 class="checkin__title">{{ $checkin->title ?? "[No title]" }}</h2> <h2 class="checkin__title">{{ $checkin->title ?? "[No title]" }}</h2>
<p class="checkin__meta">{{ date('j M Y (G:H)', strtotime($checkin->date)) }}</p> <p class="checkin__meta">{!! render_date_difference($trip->updated_at) !!}</p>
</summary> </summary>
{{ $checkin->note ?? "[No note]" }} {{ $checkin->note ?? "[No note]" }}
@if($checkin->image_url) @if($checkin->image_url)
@ -153,6 +154,8 @@
checkins.forEach(checkin => { checkins.forEach(checkin => {
if (checkin.id != checkinId && checkin.open) checkin.open = false; if (checkin.id != checkinId && checkin.open) checkin.open = false;
}); });
console.log(checkinMarkers[checkinId].getLatLng());
map.setView(new L.LatLng(checkinMarkers[checkinId].getLatLng().lat + 0.03, checkinMarkers[checkinId].getLatLng().lng));
} else { } else {
checkinMarkers[checkinId].closePopup(); checkinMarkers[checkinId].closePopup();
} }
@ -161,3 +164,47 @@
</footer> </footer>
</body> </body>
</html> </html>
@php
function render_date_difference ($start_time) {
$minute = 60;
$hour = 60 * 60;
$day = 3600 * 24;
$week = 86400 * 7;
$month = 604800 * 4;
$year = 2629800 * 12;
$start_time_dt = new DateTime($start_time);
$now = new DateTime();
$trip_start_difference = intval(($now->getTimestamp() - $start_time_dt->getTimestamp()));
$start_tag = '<span title="' . date('j M Y (G:H)', strtotime($start_time)) . '">';
$end_tag = "ago</span>";
$unit = null;
$div = 1;
if ($trip_start_difference < $minute) {
$unit = ' seconds ';
} else if ($trip_start_difference < $hour) {
$div = 60;
$unit = ' minutes ';
} else if ($trip_start_difference < $day) {
$div = 3600;
$unit = ' hours ';
} else if ($trip_start_difference < $week) {
$div = 86400;
$unit = ' days ';
} else if ($trip_start_difference < $month) {
$div = 604800;
$unit = ' weeks ';
} else if ($trip_start_difference < $year) {
$div = 2629800;
$unit = ' months ';
} else {
$div = 31557600;
$unit = ' years ';
}
return $start_tag . (floor( $trip_start_difference / $div )) . $unit . $end_tag;
}
@endphp