trip: redesign itinerary display and add trip list macro
- Add render_trip_element macro to macros.html; use it in trip_item for the trip list page, giving a consistent one-line-per-element format with emoji, route, times, duration, operator, distance, and CO₂ - Redesign trip_page.html itinerary: day headers use date-only (no year), condense check-out to a single accent line, show time-only on transport cards, humanise duration (Xh Ym), km-only distance, add CO₂ for all transport modes, fix seat display for integer seat values - Fix UndefinedError on /trip/past caused by absent 'arrive' key (Jinja2 Undefined is truthy) and date-only depart/arrive fields (no .date()) - Improve mobile map layout: text column before map in HTML order, reduce mobile map heights, hide toggle button on mobile - Add trips.css with design system (Playfair Display / Source Sans 3 / JetBrains Mono, navy/gold/amber palette, card variants by type) - Add tests/test_trip_list_render.py covering the rendering edge cases Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b3975dad3a
commit
574b4feb1f
5 changed files with 935 additions and 338 deletions
|
|
@ -7,6 +7,7 @@
|
|||
{% block style %}
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for("static", filename="leaflet/leaflet.css") }}">
|
||||
<link rel="stylesheet" href="{{ url_for("static", filename="css/trips.css") }}">
|
||||
|
||||
<style>
|
||||
body, html {
|
||||
|
|
@ -37,7 +38,7 @@
|
|||
.map-container {
|
||||
position: relative;
|
||||
top: 0;
|
||||
height: 50vh; /* Adjust as needed */
|
||||
height: 40vh;
|
||||
}
|
||||
.text-content {
|
||||
height: auto;
|
||||
|
|
@ -50,26 +51,32 @@
|
|||
{% macro section(heading, item_list) %}
|
||||
{% if item_list %}
|
||||
{% set items = item_list | list %}
|
||||
<div class="heading"><h2>{{ heading }}</h2></div>
|
||||
<p><a href="{{ url_for("trip_stats") }}">Trip statistics</a></p>
|
||||
<p>{{ items | count }} trips</p>
|
||||
|
||||
<div>Total distance: {{ format_distance(total_distance) }}</div>
|
||||
|
||||
{% for transport_type, distance in distances_by_transport_type %}
|
||||
<div>
|
||||
{{ transport_type | title }}
|
||||
distance: {{format_distance(distance) }}
|
||||
<div class="trip-list-summary">
|
||||
<h2>{{ heading }}</h2>
|
||||
<p class="mb-2"><a href="{{ url_for("trip_stats") }}">Trip statistics</a> · {{ items | count }} trips</p>
|
||||
<div class="summary-stats-row">
|
||||
<div class="summary-stat">
|
||||
<span class="summary-stat-label">Total distance</span>
|
||||
<span class="summary-stat-value">{{ format_distance(total_distance) }}</span>
|
||||
</div>
|
||||
{% for transport_type, distance in distances_by_transport_type %}
|
||||
<div class="summary-stat">
|
||||
<span class="summary-stat-label">{{ transport_type | title }}</span>
|
||||
<span class="summary-stat-value">{{ format_distance(distance) }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="summary-stat">
|
||||
<span class="summary-stat-label">Total CO₂</span>
|
||||
<span class="summary-stat-value">{{ "{:,.1f}".format(total_co2_kg / 1000.0) }} t</span>
|
||||
</div>
|
||||
{% for transport_type, co2_kg in co2_by_transport_type %}
|
||||
<div class="summary-stat">
|
||||
<span class="summary-stat-label">{{ transport_type | title }} CO₂</span>
|
||||
<span class="summary-stat-value">{{ "{:,.1f}".format(co2_kg) }} kg</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div>Total CO₂: {{ "{:,.1f}".format(total_co2_kg / 1000.0) }} tonnes</div>
|
||||
|
||||
{% for transport_type, co2_kg in co2_by_transport_type %}
|
||||
<div>
|
||||
{{ transport_type | title }}
|
||||
CO₂: {{ "{:,.1f}".format(co2_kg) }} kg
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% for trip in items %}
|
||||
{{ trip_item(trip) }}
|
||||
|
|
@ -80,12 +87,12 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="container-fluid d-flex flex-column flex-md-row">
|
||||
<div class="map-container col-12 col-md-6 order-1 order-md-2">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
<div class="text-content col-12 col-md-6 order-2 order-md-1 pe-3">
|
||||
<div class="text-content col-12 col-md-6 pe-3">
|
||||
{{ section(heading, trips) }}
|
||||
</div>
|
||||
<div class="map-container col-12 col-md-6">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue