ci / check (push) Successful in 55s
- add /cool, /cool?vote=1, /cool/stage and /cool/city on the existing Nuxt/Onyx stack - wire real route/shade metrics and OSM geometry from the route bundle; city-gap data for the city view - show shade % and direct-sun minutes together; recommend Accessible for Ruth with the 15% ramp trade-off - add in-memory time/scene/round state and one anonymous vote per session, polled every 2 s - keep the retail module linked but out of the Cool City story
217 lines
5.5 KiB
Vue
217 lines
5.5 KiB
Vue
<script setup lang="ts">
|
|
import type { CoolRouteBundle, CoolRouteId } from '#shared/cool'
|
|
import { createProjection, pathFromCoordinates } from '~/utils/cool-map'
|
|
|
|
const props = defineProps<{
|
|
bundle: CoolRouteBundle
|
|
selectedRoute?: CoolRouteId | null
|
|
stage?: boolean
|
|
}>()
|
|
|
|
const allPoints = computed(() => {
|
|
const routePoints = props.bundle.routes.flatMap((route) =>
|
|
route.geometry.map(([lon, lat]) => ({ lat, lon })),
|
|
)
|
|
const water = props.bundle.water.map((point) => ({ lat: point.lat, lon: point.lon }))
|
|
return [...routePoints, ...water]
|
|
})
|
|
|
|
const project = computed(() => createProjection(allPoints.value))
|
|
const routes = computed(() =>
|
|
props.bundle.routes.map((route) => ({
|
|
...route,
|
|
path: pathFromCoordinates(route.geometry, project.value),
|
|
isSelected: props.selectedRoute === route.id,
|
|
})),
|
|
)
|
|
const origin = computed(() => {
|
|
const lat = props.bundle.origin.lat
|
|
const lon = props.bundle.origin.lon
|
|
return lat !== undefined && lon !== undefined ? project.value({ lat, lon }) : null
|
|
})
|
|
const destination = computed(() => {
|
|
const lat = props.bundle.destination.lat
|
|
const lon = props.bundle.destination.lon
|
|
return lat !== undefined && lon !== undefined ? project.value({ lat, lon }) : null
|
|
})
|
|
const water = computed(() =>
|
|
props.bundle.water.map((point) => ({ ...point, position: project.value({ lat: point.lat, lon: point.lon }) })),
|
|
)
|
|
</script>
|
|
|
|
<template>
|
|
<figure class="cc-routemap" :class="{ 'cc-routemap--stage': props.stage }">
|
|
<svg
|
|
class="cc-routemap__canvas"
|
|
viewBox="0 0 1200 800"
|
|
preserveAspectRatio="xMidYMid meet"
|
|
role="img"
|
|
:aria-label="`Route map from ${props.bundle.origin.name} to ${props.bundle.destination.name}. Shortest, shaded and accessible routes with modelled shade.`"
|
|
>
|
|
<defs>
|
|
<pattern id="cc-route-grid" width="48" height="48" patternUnits="userSpaceOnUse">
|
|
<circle cx="1" cy="1" r="1" fill="currentColor" />
|
|
</pattern>
|
|
</defs>
|
|
<rect class="cc-routemap__ground" x="0" y="0" width="1200" height="800" />
|
|
<rect class="cc-routemap__grid" x="0" y="0" width="1200" height="800" fill="url(#cc-route-grid)" />
|
|
|
|
<path
|
|
v-for="route in routes"
|
|
:key="route.id"
|
|
class="cc-routemap__route"
|
|
:class="[
|
|
`cc-routemap__route--${route.id}`,
|
|
{ 'is-selected': route.isSelected, 'is-dim': props.selectedRoute && !route.isSelected },
|
|
]"
|
|
:d="route.path"
|
|
pathLength="1"
|
|
fill="none"
|
|
vector-effect="non-scaling-stroke"
|
|
/>
|
|
|
|
<g v-for="point in water" :key="point.name" class="cc-routemap__water">
|
|
<circle :cx="point.position.x" :cy="point.position.y" r="7" />
|
|
</g>
|
|
|
|
<g v-if="origin" class="cc-routemap__endpoint">
|
|
<circle :cx="origin.x" :cy="origin.y" r="16" />
|
|
<text :x="origin.x" :y="origin.y + 5" text-anchor="middle" class="cc-routemap__letter">S</text>
|
|
<text :x="origin.x" :y="origin.y + 44" text-anchor="middle" class="cc-routemap__place">{{ props.bundle.origin.name }}</text>
|
|
</g>
|
|
<g v-if="destination" class="cc-routemap__endpoint">
|
|
<circle :cx="destination.x" :cy="destination.y" r="16" />
|
|
<text :x="destination.x" :y="destination.y + 5" text-anchor="middle" class="cc-routemap__letter">M</text>
|
|
<text :x="destination.x" :y="destination.y - 30" text-anchor="middle" class="cc-routemap__place">{{ props.bundle.destination.name }}</text>
|
|
</g>
|
|
</svg>
|
|
|
|
<p class="cc-routemap__stamp">OSM route geometry · modelled shade · no basemap</p>
|
|
</figure>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.cc-routemap {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
min-height: 24rem;
|
|
margin: 0;
|
|
overflow: hidden;
|
|
color: var(--cc-line);
|
|
}
|
|
|
|
.cc-routemap__canvas {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.cc-routemap__ground {
|
|
fill: var(--cc-ground, #f6f3ee);
|
|
}
|
|
|
|
.cc-routemap__grid {
|
|
color: var(--cc-line, rgba(18, 18, 18, 0.12));
|
|
opacity: 0.55;
|
|
}
|
|
|
|
.cc-routemap__route {
|
|
stroke-linecap: round;
|
|
stroke-linejoin: round;
|
|
opacity: 0.9;
|
|
transition: opacity 240ms ease;
|
|
animation: cc-route-draw 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
}
|
|
|
|
.cc-routemap__route--shortest {
|
|
stroke: var(--cc-heat);
|
|
stroke-width: 5;
|
|
}
|
|
|
|
.cc-routemap__route--shaded {
|
|
stroke: var(--cc-shade);
|
|
stroke-width: 6;
|
|
}
|
|
|
|
.cc-routemap__route--accessible {
|
|
stroke: var(--cc-ink);
|
|
stroke-width: 7;
|
|
}
|
|
|
|
.cc-routemap__route.is-selected {
|
|
opacity: 1;
|
|
stroke-width: 9;
|
|
}
|
|
|
|
.cc-routemap__route.is-dim {
|
|
opacity: 0.38;
|
|
}
|
|
|
|
.cc-routemap__water circle {
|
|
fill: var(--cc-shade);
|
|
stroke: var(--cc-ground, #f6f3ee);
|
|
stroke-width: 3;
|
|
}
|
|
|
|
.cc-routemap__endpoint circle {
|
|
fill: var(--cc-ink);
|
|
stroke: var(--cc-ground, #f6f3ee);
|
|
stroke-width: 4;
|
|
}
|
|
|
|
.cc-routemap__letter {
|
|
fill: var(--cc-ground, #f6f3ee);
|
|
font-size: 16px;
|
|
font-weight: 800;
|
|
}
|
|
|
|
.cc-routemap__place {
|
|
fill: var(--cc-ink);
|
|
font-size: 26px;
|
|
font-weight: 800;
|
|
letter-spacing: -0.03em;
|
|
}
|
|
|
|
.cc-routemap__stamp {
|
|
position: absolute;
|
|
right: 1rem;
|
|
bottom: 0.8rem;
|
|
margin: 0;
|
|
color: var(--cc-muted);
|
|
font-family: var(--cc-font);
|
|
font-size: 0.62rem;
|
|
letter-spacing: 0.03em;
|
|
}
|
|
|
|
.cc-routemap--stage {
|
|
min-height: 100%;
|
|
}
|
|
|
|
.cc-routemap--stage .cc-routemap__place,
|
|
.cc-routemap--stage .cc-routemap__endpoint {
|
|
display: none;
|
|
}
|
|
|
|
.cc-routemap--stage .cc-routemap__letter {
|
|
font-size: 20px;
|
|
}
|
|
|
|
@keyframes cc-route-draw {
|
|
from {
|
|
stroke-dasharray: 1;
|
|
stroke-dashoffset: 1;
|
|
}
|
|
to {
|
|
stroke-dasharray: 1;
|
|
stroke-dashoffset: 0;
|
|
}
|
|
}
|
|
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.cc-routemap__route {
|
|
animation: none;
|
|
}
|
|
}
|
|
</style>
|