- 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
This commit is contained in:
1 parent
33063afbdf
commit
2bc52a314d
28 files changed
+8633
-45
No files matched your search
@@ -0,0 +1,155 @@
|
||||
<script setup lang="ts">
|
||||
import type { CoolCityCatchment, CoolCityPlace } from '#shared/cool'
|
||||
import { createProjection, pathFromCoordinates } from '~/utils/cool-map'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
places: CoolCityPlace[]
|
||||
catchments?: CoolCityCatchment[]
|
||||
selectedRank?: number | null
|
||||
showCatchments?: boolean
|
||||
stage?: boolean
|
||||
}>(),
|
||||
{ catchments: () => [], selectedRank: null, showCatchments: false, stage: false },
|
||||
)
|
||||
|
||||
const allPoints = computed(() => {
|
||||
const placePoints = props.places.map((place) => ({ lat: place.lat, lon: place.lon }))
|
||||
const centers = props.catchments.map((catchment) => catchment.center)
|
||||
return [...placePoints, ...centers]
|
||||
})
|
||||
|
||||
const project = computed(() => createProjection(allPoints.value, 1200, 800, 90))
|
||||
const dots = computed(() =>
|
||||
props.places.map((place) => ({
|
||||
...place,
|
||||
position: project.value({ lat: place.lat, lon: place.lon }),
|
||||
})),
|
||||
)
|
||||
const rings = computed(() =>
|
||||
props.catchments.map((catchment) => {
|
||||
const ring = catchment.geometry.coordinates?.[0] ?? []
|
||||
const path = ring.length
|
||||
? pathFromCoordinates(
|
||||
ring.map(([lon, lat]) => [lon, lat] as [number, number]),
|
||||
project.value,
|
||||
)
|
||||
: ''
|
||||
return {
|
||||
...catchment,
|
||||
path,
|
||||
centerPoint: project.value(catchment.center),
|
||||
selected: props.selectedRank === catchment.rank,
|
||||
}
|
||||
}),
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure class="cc-placesmap" :class="{ 'cc-placesmap--stage': props.stage }">
|
||||
<svg
|
||||
class="cc-placesmap__canvas"
|
||||
viewBox="0 0 1200 800"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
role="img"
|
||||
:aria-label="`Map of ${places.length} cool places near the eight Heilbronn sensor catchments.`"
|
||||
>
|
||||
<defs>
|
||||
<pattern id="cc-places-grid" width="44" height="44" patternUnits="userSpaceOnUse">
|
||||
<circle cx="1" cy="1" r="1" fill="currentColor" />
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect class="cc-placesmap__ground" x="0" y="0" width="1200" height="800" />
|
||||
<rect class="cc-placesmap__grid" x="0" y="0" width="1200" height="800" fill="url(#cc-places-grid)" />
|
||||
|
||||
<g v-if="props.showCatchments">
|
||||
<path
|
||||
v-for="ring in rings"
|
||||
:key="ring.sensor_id"
|
||||
class="cc-placesmap__ring"
|
||||
:class="{ 'is-selected': ring.selected }"
|
||||
:d="ring.path"
|
||||
/>
|
||||
<g v-for="ring in rings" :key="`${ring.sensor_id}-label`" class="cc-placesmap__rank">
|
||||
<text :x="ring.centerPoint.x" :y="ring.centerPoint.y + 6" text-anchor="middle">{{ ring.rank }}</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<g class="cc-placesmap__dots">
|
||||
<circle
|
||||
v-for="dot in dots"
|
||||
:key="`${dot.name}-${dot.lat}-${dot.lon}`"
|
||||
:cx="dot.position.x"
|
||||
:cy="dot.position.y"
|
||||
:r="props.stage ? 9 : 6"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<p class="cc-placesmap__stamp">Relative map · OSM cool places · no heatmap</p>
|
||||
</figure>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-placesmap {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 24rem;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: var(--cc-line);
|
||||
}
|
||||
|
||||
.cc-placesmap__canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cc-placesmap__ground {
|
||||
fill: var(--cc-ground, #f6f3ee);
|
||||
}
|
||||
|
||||
.cc-placesmap__grid {
|
||||
color: var(--cc-line, rgba(18, 18, 18, 0.12));
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.cc-placesmap__ring {
|
||||
fill: color-mix(in srgb, var(--cc-shade) 8%, transparent);
|
||||
stroke: var(--cc-line);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.cc-placesmap__ring.is-selected {
|
||||
fill: color-mix(in srgb, var(--cc-heat) 14%, transparent);
|
||||
stroke: var(--cc-heat);
|
||||
stroke-width: 3;
|
||||
}
|
||||
|
||||
.cc-placesmap__rank text {
|
||||
fill: var(--cc-muted);
|
||||
font-size: 17px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.cc-placesmap__dots circle {
|
||||
fill: var(--cc-shade);
|
||||
stroke: var(--cc-ground, #f6f3ee);
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
.cc-placesmap__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;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,200 @@
|
||||
<script setup lang="ts">
|
||||
import type { CoolRouteOption, CoolRouteValues } from '#shared/cool'
|
||||
import { coolDistance, coolMinutes, coolShade, coolStops, coolValues, coolYesNo } from '~/utils/cool'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
route: CoolRouteOption
|
||||
values: CoolRouteValues | null
|
||||
recommended?: boolean
|
||||
selected?: boolean
|
||||
selectable?: boolean
|
||||
}>(),
|
||||
{ recommended: false, selected: false, selectable: false },
|
||||
)
|
||||
|
||||
const emit = defineEmits<{ select: [id: CoolRouteOption['id']] }>()
|
||||
const data = computed(() => coolValues(props.values))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="selectable ? 'button' : 'article'"
|
||||
class="cc-route-card"
|
||||
:class="[
|
||||
`cc-route-card--${route.id}`,
|
||||
{ 'cc-route-card--recommended': recommended, 'cc-route-card--selected': selected },
|
||||
]"
|
||||
:type="selectable ? 'button' : undefined"
|
||||
:aria-pressed="selectable ? selected : undefined"
|
||||
@click="selectable ? emit('select', route.id) : undefined"
|
||||
>
|
||||
<span class="cc-route-card__line" aria-hidden="true" />
|
||||
<span class="cc-route-card__head">
|
||||
<span class="cc-route-card__label">{{ route.label }}</span>
|
||||
<span v-if="recommended" class="cc-route-card__tag">Accessible for Ruth</span>
|
||||
<span v-else-if="selected" class="cc-route-card__tag cc-route-card__tag--quiet">Selected</span>
|
||||
</span>
|
||||
<span class="cc-route-card__desc">{{ route.description }}</span>
|
||||
|
||||
<span class="cc-route-card__primary">
|
||||
<strong>{{ coolShade(data.shadePct) }}</strong> shade
|
||||
<span class="cc-route-card__modeled">modelled</span>
|
||||
<span class="cc-route-card__divider">·</span>
|
||||
<strong>{{ coolMinutes(data.directSunMin) }}</strong> direct sun
|
||||
</span>
|
||||
|
||||
<span class="cc-route-card__secondary">
|
||||
{{ coolDistance(data.distanceM) }} · {{ coolMinutes(data.durationMin) }} ·
|
||||
<template v-if="route.ramp">{{ route.ramp.incline.replace('.0%', '%') }} ramp</template>
|
||||
<template v-else>no ramp</template>
|
||||
</span>
|
||||
|
||||
<span class="cc-route-card__access">
|
||||
Step-free {{ coolYesNo(data.stepFree) }} · Water {{ coolStops(data.waterStops) }} ·
|
||||
Benches {{ coolStops(data.benchStops) }}
|
||||
</span>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-route-card {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
padding: 0.95rem 1rem 0.85rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface, rgba(255, 255, 255, 0.86));
|
||||
box-shadow: var(--cc-shadow-soft);
|
||||
color: var(--cc-ink);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
button.cc-route-card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.cc-route-card:hover {
|
||||
border-color: var(--cc-line-strong);
|
||||
}
|
||||
|
||||
.cc-route-card:focus-visible {
|
||||
outline: 3px solid var(--cc-focus);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.cc-route-card--selected {
|
||||
border-color: var(--cc-ink);
|
||||
box-shadow: 0 0 0 2px var(--cc-ink), var(--cc-shadow-soft);
|
||||
}
|
||||
|
||||
.cc-route-card--recommended {
|
||||
border-color: var(--cc-shade);
|
||||
}
|
||||
|
||||
.cc-route-card__line {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
margin-bottom: 0.25rem;
|
||||
border-radius: 999px;
|
||||
background: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-route-card--shortest .cc-route-card__line {
|
||||
background: var(--cc-heat);
|
||||
}
|
||||
|
||||
.cc-route-card--shaded .cc-route-card__line {
|
||||
background: var(--cc-shade);
|
||||
}
|
||||
|
||||
.cc-route-card--accessible .cc-route-card__line {
|
||||
background: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-route-card__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.cc-route-card__label {
|
||||
font-size: 1.18rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.cc-route-card__tag {
|
||||
margin-inline-start: auto;
|
||||
padding: 0.16rem 0.42rem;
|
||||
border-radius: 999px;
|
||||
background: var(--cc-shade);
|
||||
color: #fff;
|
||||
font-size: 0.6rem;
|
||||
font-weight: 750;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.cc-route-card__tag--quiet {
|
||||
background: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-route-card__desc {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.cc-route-card__primary {
|
||||
margin-top: 0.25rem;
|
||||
color: var(--cc-ink);
|
||||
font-size: 1.05rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-route-card__primary strong {
|
||||
font-size: 1.35rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.cc-route-card__modeled {
|
||||
margin-inline-start: 0.2rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.58rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-route-card__divider {
|
||||
margin-inline: 0.25rem;
|
||||
color: var(--cc-line-strong);
|
||||
}
|
||||
|
||||
.cc-route-card__secondary,
|
||||
.cc-route-card__access {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.4;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-route-card__access {
|
||||
font-size: 0.68rem;
|
||||
}
|
||||
|
||||
@media (min-width: 760px) {
|
||||
.cc-route-card {
|
||||
padding: 1.05rem 1.1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,216 @@
|
||||
<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>
|
||||
Reference in new issue
Block a user